Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index bc516ff..326bcd3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf403=['rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','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','sendStatus','status','json','undefined','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','end','name','send','SugarcrmConfiguration','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','options','findAll','rows','params','includeAll','include','catch','create','body','find','findOne','order','getFields','SugarcrmField','getSubjects','getDescriptions'];(function(_0x3dd64c,_0x24763e){var _0x537931=function(_0x30c12b){while(--_0x30c12b){_0x3dd64c['push'](_0x3dd64c['shift']());}};_0x537931(++_0x24763e);}(_0xf403,0x1ec));var _0x3f40=function(_0x599b4c,_0x20c1e9){_0x599b4c=_0x599b4c-0x0;var _0x8f82c4=_0xf403[_0x599b4c];return _0x8f82c4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x3f40('0x0'));var zipdir=require(_0x3f40('0x1'));var jsonpatch=require(_0x3f40('0x2'));var rp=require(_0x3f40('0x3'));var moment=require(_0x3f40('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x3f40('0x5'));var util=require(_0x3f40('0x6'));var path=require('path');var sox=require(_0x3f40('0x7'));var csv=require('to-csv');var ejs=require(_0x3f40('0x8'));var fs=require('fs');var fs_extra=require(_0x3f40('0x9'));var _=require(_0x3f40('0xa'));var squel=require(_0x3f40('0xb'));var crypto=require(_0x3f40('0xc'));var jsforce=require(_0x3f40('0xd'));var deskjs=require(_0x3f40('0xe'));var toCsv=require(_0x3f40('0xf'));var querystring=require('querystring');var Papa=require(_0x3f40('0x10'));var Redis=require(_0x3f40('0x11'));var authService=require(_0x3f40('0x12'));var qs=require(_0x3f40('0x13'));var as=require(_0x3f40('0x14'));var hardwareService=require(_0x3f40('0x15'));var logger=require(_0x3f40('0x16'))(_0x3f40('0x17'));var utils=require(_0x3f40('0x18'));var config=require(_0x3f40('0x19'));var licenseUtil=require(_0x3f40('0x1a'));var db=require(_0x3f40('0x1b'))['db'];function respondWithStatusCode(_0x273795,_0xa49bc1){_0xa49bc1=_0xa49bc1||0xcc;return function(_0x4b5b7f){if(_0x4b5b7f){return _0x273795[_0x3f40('0x1c')](_0xa49bc1);}return _0x273795[_0x3f40('0x1d')](_0xa49bc1)['end']();};}function respondWithResult(_0x52ccd7,_0xaa0cfd){_0xaa0cfd=_0xaa0cfd||0xc8;return function(_0x589e5b){if(_0x589e5b){return _0x52ccd7[_0x3f40('0x1d')](_0xaa0cfd)[_0x3f40('0x1e')](_0x589e5b);}};}function respondWithFilteredResult(_0x190cd2,_0x2a4cfd){return function(_0x10319e){if(_0x10319e){var _0x561c1f=typeof _0x2a4cfd['offset']===_0x3f40('0x1f')&&typeof _0x2a4cfd['limit']===_0x3f40('0x1f');var _0x30ed7a=_0x10319e[_0x3f40('0x20')];var _0x277182=_0x561c1f?0x0:_0x2a4cfd[_0x3f40('0x21')];var _0x13253b=_0x561c1f?_0x10319e[_0x3f40('0x20')]:_0x2a4cfd[_0x3f40('0x21')]+_0x2a4cfd[_0x3f40('0x22')];var _0x42399c;if(_0x13253b>=_0x30ed7a){_0x13253b=_0x30ed7a;_0x42399c=0xc8;}else{_0x42399c=0xce;}_0x190cd2[_0x3f40('0x1d')](_0x42399c);return _0x190cd2[_0x3f40('0x23')](_0x3f40('0x24'),_0x277182+'-'+_0x13253b+'/'+_0x30ed7a)['json'](_0x10319e);}return null;};}function patchUpdates(_0x6deda7){return function(_0x114a78){try{jsonpatch['apply'](_0x114a78,_0x6deda7,!![]);}catch(_0x105063){return BPromise[_0x3f40('0x25')](_0x105063);}return _0x114a78[_0x3f40('0x26')]();};}function saveUpdates(_0x19425c,_0x5a2dcd){return function(_0xa2d3a7){if(_0xa2d3a7){return _0xa2d3a7[_0x3f40('0x27')](_0x19425c)[_0x3f40('0x28')](function(_0x309295){return _0x309295;});}return null;};}function removeEntity(_0x5447dc,_0x164abb){return function(_0x2afe44){if(_0x2afe44){return _0x2afe44[_0x3f40('0x29')]()['then'](function(){_0x5447dc[_0x3f40('0x1d')](0xcc)[_0x3f40('0x2a')]();});}};}function handleEntityNotFound(_0x269448,_0x50f3ad){return function(_0x4a8af4){if(!_0x4a8af4){_0x269448[_0x3f40('0x1c')](0x194);}return _0x4a8af4;};}function handleError(_0x72044d,_0x1e49ea){_0x1e49ea=_0x1e49ea||0x1f4;return function(_0x1d38af){logger['error'](_0x1d38af['stack']);if(_0x1d38af['name']){delete _0x1d38af[_0x3f40('0x2b')];}_0x72044d['status'](_0x1e49ea)[_0x3f40('0x2c')](_0x1d38af);};}exports['index']=function(_0x4fdaba,_0x2182f1){var _0x34ca93={},_0x26a017={},_0x332a14={'count':0x0,'rows':[]};var _0x1a58ef=_['map'](db[_0x3f40('0x2d')][_0x3f40('0x2e')],function(_0x246e37){return{'name':_0x246e37[_0x3f40('0x2f')],'type':_0x246e37[_0x3f40('0x30')][_0x3f40('0x31')]};});_0x26a017[_0x3f40('0x32')]=_[_0x3f40('0x33')](_0x1a58ef,_0x3f40('0x2b'));_0x26a017[_0x3f40('0x34')]=_[_0x3f40('0x35')](_0x4fdaba['query']);_0x26a017[_0x3f40('0x36')]=_[_0x3f40('0x37')](_0x26a017[_0x3f40('0x32')],_0x26a017[_0x3f40('0x34')]);_0x34ca93['attributes']=_[_0x3f40('0x37')](_0x26a017[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x4fdaba['query'][_0x3f40('0x38')]));_0x34ca93['attributes']=_0x34ca93[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x34ca93['attributes']:_0x26a017['model'];if(!_0x4fdaba['query'][_0x3f40('0x3b')](_0x3f40('0x3c'))){_0x34ca93[_0x3f40('0x22')]=qs[_0x3f40('0x22')](_0x4fdaba[_0x3f40('0x34')]['limit']);_0x34ca93['offset']=qs[_0x3f40('0x21')](_0x4fdaba['query']['offset']);}_0x34ca93['order']=qs['sort'](_0x4fdaba[_0x3f40('0x34')][_0x3f40('0x3d')]);_0x34ca93['where']=qs[_0x3f40('0x36')](_[_0x3f40('0x3e')](_0x4fdaba['query'],_0x26a017[_0x3f40('0x36')]),_0x1a58ef);if(_0x4fdaba[_0x3f40('0x34')][_0x3f40('0x3f')]){_0x34ca93[_0x3f40('0x40')]=_[_0x3f40('0x41')](_0x34ca93['where'],{'$or':_[_0x3f40('0x33')](_0x1a58ef,function(_0xa8462){if(_0xa8462[_0x3f40('0x30')]!=='VIRTUAL'){var _0x2857e3={};_0x2857e3[_0xa8462['name']]={'$like':'%'+_0x4fdaba[_0x3f40('0x34')][_0x3f40('0x3f')]+'%'};return _0x2857e3;}})});}_0x34ca93=_[_0x3f40('0x41')]({},_0x34ca93,_0x4fdaba[_0x3f40('0x42')]);var _0x1366c9={'where':_0x34ca93[_0x3f40('0x40')]};return db[_0x3f40('0x2d')][_0x3f40('0x20')](_0x1366c9)[_0x3f40('0x28')](function(_0x2b44d2){_0x332a14['count']=_0x2b44d2;if(_0x4fdaba[_0x3f40('0x34')]['includeAll']){_0x34ca93['include']=[{'all':!![]}];}return db[_0x3f40('0x2d')][_0x3f40('0x43')](_0x34ca93);})[_0x3f40('0x28')](function(_0x424ff8){_0x332a14[_0x3f40('0x44')]=_0x424ff8;return _0x332a14;})[_0x3f40('0x28')](respondWithFilteredResult(_0x2182f1,_0x34ca93))['catch'](handleError(_0x2182f1,null));};exports['show']=function(_0x540375,_0xdd2f44){var _0x29fdee={'raw':![],'where':{'id':_0x540375[_0x3f40('0x45')]['id']}},_0x4b9d3f={};_0x4b9d3f['model']=_['keys'](db[_0x3f40('0x2d')][_0x3f40('0x2e')]);_0x4b9d3f[_0x3f40('0x34')]=_[_0x3f40('0x35')](_0x540375[_0x3f40('0x34')]);_0x4b9d3f[_0x3f40('0x36')]=_[_0x3f40('0x37')](_0x4b9d3f[_0x3f40('0x32')],_0x4b9d3f[_0x3f40('0x34')]);_0x29fdee[_0x3f40('0x39')]=_[_0x3f40('0x37')](_0x4b9d3f[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x540375['query']['fields']));_0x29fdee['attributes']=_0x29fdee[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x29fdee[_0x3f40('0x39')]:_0x4b9d3f[_0x3f40('0x32')];if(_0x540375['query'][_0x3f40('0x46')]){_0x29fdee[_0x3f40('0x47')]=[{'all':!![]}];}_0x29fdee=_[_0x3f40('0x41')]({},_0x29fdee,_0x540375[_0x3f40('0x42')]);return db[_0x3f40('0x2d')]['find'](_0x29fdee)[_0x3f40('0x28')](handleEntityNotFound(_0xdd2f44,null))[_0x3f40('0x28')](respondWithResult(_0xdd2f44,null))[_0x3f40('0x48')](handleError(_0xdd2f44,null));};exports['create']=function(_0x122bcc,_0x24e8d6){return db[_0x3f40('0x2d')][_0x3f40('0x49')](_0x122bcc[_0x3f40('0x4a')],{})['then'](respondWithResult(_0x24e8d6,0xc9))[_0x3f40('0x48')](handleError(_0x24e8d6,null));};exports[_0x3f40('0x27')]=function(_0x45bdd6,_0x103ce6){if(_0x45bdd6[_0x3f40('0x4a')]['id']){delete _0x45bdd6[_0x3f40('0x4a')]['id'];}return db[_0x3f40('0x2d')][_0x3f40('0x4b')]({'where':{'id':_0x45bdd6[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x103ce6,null))[_0x3f40('0x28')](saveUpdates(_0x45bdd6[_0x3f40('0x4a')],null))[_0x3f40('0x28')](respondWithResult(_0x103ce6,null))['catch'](handleError(_0x103ce6,null));};exports[_0x3f40('0x29')]=function(_0x3ae4b4,_0x22bd2d){return db['SugarcrmConfiguration'][_0x3f40('0x4b')]({'where':{'id':_0x3ae4b4[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x22bd2d,null))[_0x3f40('0x28')](removeEntity(_0x22bd2d,null))[_0x3f40('0x48')](handleError(_0x22bd2d,null));};exports['getFields']=function(_0x41739d,_0x452fbb,_0x57d2c7){var _0x5d8074={};var _0x4770fd={};var _0x5a2568;var _0x56f7ce;return db['SugarcrmConfiguration'][_0x3f40('0x4c')]({'where':{'id':_0x41739d[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x452fbb,null))['then'](function(_0x3829a8){if(_0x3829a8){_0x5a2568=_0x3829a8;_0x4770fd[_0x3f40('0x32')]=_[_0x3f40('0x35')](db['SugarcrmField'][_0x3f40('0x2e')]);_0x4770fd[_0x3f40('0x34')]=_[_0x3f40('0x35')](_0x41739d[_0x3f40('0x34')]);_0x4770fd['filters']=_['intersection'](_0x4770fd['model'],_0x4770fd[_0x3f40('0x34')]);_0x5d8074['attributes']=_[_0x3f40('0x37')](_0x4770fd[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x41739d['query']['fields']));_0x5d8074[_0x3f40('0x39')]=_0x5d8074[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x5d8074['attributes']:_0x4770fd[_0x3f40('0x32')];_0x5d8074[_0x3f40('0x4d')]=qs[_0x3f40('0x3d')](_0x41739d[_0x3f40('0x34')][_0x3f40('0x3d')]);_0x5d8074['where']=qs[_0x3f40('0x36')](_[_0x3f40('0x3e')](_0x41739d[_0x3f40('0x34')],_0x4770fd['filters']));if(_0x41739d['query']['filter']){_0x5d8074[_0x3f40('0x40')]=_['merge'](_0x5d8074['where'],{'$or':_[_0x3f40('0x33')](_0x5d8074['attributes'],function(_0x3284e7){var _0x173313={};_0x173313[_0x3284e7]={'$like':'%'+_0x41739d[_0x3f40('0x34')]['filter']+'%'};return _0x173313;})});}_0x5d8074=_['merge']({},_0x5d8074,_0x41739d[_0x3f40('0x42')]);return _0x5a2568[_0x3f40('0x4e')](_0x5d8074);}})[_0x3f40('0x28')](function(_0x823fff){if(_0x823fff){_0x56f7ce=_0x823fff[_0x3f40('0x3a')];if(!_0x41739d[_0x3f40('0x34')][_0x3f40('0x3b')]('nolimit')){_0x5d8074[_0x3f40('0x22')]=qs['limit'](_0x41739d[_0x3f40('0x34')][_0x3f40('0x22')]);_0x5d8074[_0x3f40('0x21')]=qs['offset'](_0x41739d[_0x3f40('0x34')][_0x3f40('0x21')]);}return _0x5a2568['getFields'](_0x5d8074);}})[_0x3f40('0x28')](function(_0x551056){if(_0x551056){return _0x551056?{'count':_0x56f7ce,'rows':_0x551056}:null;}})[_0x3f40('0x28')](respondWithResult(_0x452fbb,null))['catch'](handleError(_0x452fbb,null));};exports['getSubjects']=function(_0x3b6d3a,_0x4a2b4c,_0x326664){var _0x4e5372={};var _0x3b4214={};var _0x3a50d5;var _0x3259bb;return db[_0x3f40('0x2d')][_0x3f40('0x4c')]({'where':{'id':_0x3b6d3a[_0x3f40('0x45')]['id']}})['then'](handleEntityNotFound(_0x4a2b4c,null))[_0x3f40('0x28')](function(_0x26a869){if(_0x26a869){_0x3a50d5=_0x26a869;_0x3b4214[_0x3f40('0x32')]=_[_0x3f40('0x35')](db[_0x3f40('0x4f')][_0x3f40('0x2e')]);_0x3b4214[_0x3f40('0x34')]=_['keys'](_0x3b6d3a[_0x3f40('0x34')]);_0x3b4214['filters']=_[_0x3f40('0x37')](_0x3b4214['model'],_0x3b4214[_0x3f40('0x34')]);_0x4e5372[_0x3f40('0x39')]=_[_0x3f40('0x37')](_0x3b4214[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x38')]));_0x4e5372['attributes']=_0x4e5372[_0x3f40('0x39')]['length']?_0x4e5372[_0x3f40('0x39')]:_0x3b4214[_0x3f40('0x32')];_0x4e5372['order']=qs['sort'](_0x3b6d3a['query'][_0x3f40('0x3d')]);_0x4e5372[_0x3f40('0x40')]=qs[_0x3f40('0x36')](_[_0x3f40('0x3e')](_0x3b6d3a[_0x3f40('0x34')],_0x3b4214[_0x3f40('0x36')]));if(_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x3f')]){_0x4e5372[_0x3f40('0x40')]=_['merge'](_0x4e5372[_0x3f40('0x40')],{'$or':_[_0x3f40('0x33')](_0x4e5372[_0x3f40('0x39')],function(_0x37e398){var _0x3adca9={};_0x3adca9[_0x37e398]={'$like':'%'+_0x3b6d3a[_0x3f40('0x34')]['filter']+'%'};return _0x3adca9;})});}_0x4e5372=_[_0x3f40('0x41')]({},_0x4e5372,_0x3b6d3a[_0x3f40('0x42')]);return _0x3a50d5[_0x3f40('0x50')](_0x4e5372);}})['then'](function(_0x267d7c){if(_0x267d7c){_0x3259bb=_0x267d7c[_0x3f40('0x3a')];if(!_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x3b')](_0x3f40('0x3c'))){_0x4e5372['limit']=qs[_0x3f40('0x22')](_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x22')]);_0x4e5372[_0x3f40('0x21')]=qs[_0x3f40('0x21')](_0x3b6d3a[_0x3f40('0x34')]['offset']);}return _0x3a50d5[_0x3f40('0x50')](_0x4e5372);}})[_0x3f40('0x28')](function(_0x3290bc){if(_0x3290bc){return _0x3290bc?{'count':_0x3259bb,'rows':_0x3290bc}:null;}})[_0x3f40('0x28')](respondWithResult(_0x4a2b4c,null))['catch'](handleError(_0x4a2b4c,null));};exports[_0x3f40('0x51')]=function(_0x576623,_0x5b00ed,_0x5e6739){var _0x2a8700={};var _0x2f419f={};var _0x31dbdb;var _0x5bde61;return db[_0x3f40('0x2d')][_0x3f40('0x4c')]({'where':{'id':_0x576623[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x5b00ed,null))['then'](function(_0x58ab58){if(_0x58ab58){_0x31dbdb=_0x58ab58;_0x2f419f[_0x3f40('0x32')]=_['keys'](db['SugarcrmField']['rawAttributes']);_0x2f419f['query']=_[_0x3f40('0x35')](_0x576623[_0x3f40('0x34')]);_0x2f419f[_0x3f40('0x36')]=_[_0x3f40('0x37')](_0x2f419f[_0x3f40('0x32')],_0x2f419f[_0x3f40('0x34')]);_0x2a8700[_0x3f40('0x39')]=_[_0x3f40('0x37')](_0x2f419f['model'],qs[_0x3f40('0x38')](_0x576623['query']['fields']));_0x2a8700[_0x3f40('0x39')]=_0x2a8700[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x2a8700[_0x3f40('0x39')]:_0x2f419f[_0x3f40('0x32')];_0x2a8700[_0x3f40('0x4d')]=qs['sort'](_0x576623[_0x3f40('0x34')][_0x3f40('0x3d')]);_0x2a8700['where']=qs['filters'](_['pick'](_0x576623[_0x3f40('0x34')],_0x2f419f[_0x3f40('0x36')]));if(_0x576623[_0x3f40('0x34')][_0x3f40('0x3f')]){_0x2a8700[_0x3f40('0x40')]=_[_0x3f40('0x41')](_0x2a8700[_0x3f40('0x40')],{'$or':_['map'](_0x2a8700[_0x3f40('0x39')],function(_0x3094b3){var _0x51fa47={};_0x51fa47[_0x3094b3]={'$like':'%'+_0x576623[_0x3f40('0x34')][_0x3f40('0x3f')]+'%'};return _0x51fa47;})});}_0x2a8700=_[_0x3f40('0x41')]({},_0x2a8700,_0x576623[_0x3f40('0x42')]);return _0x31dbdb[_0x3f40('0x51')](_0x2a8700);}})[_0x3f40('0x28')](function(_0x3c6f05){if(_0x3c6f05){_0x5bde61=_0x3c6f05[_0x3f40('0x3a')];if(!_0x576623[_0x3f40('0x34')]['hasOwnProperty'](_0x3f40('0x3c'))){_0x2a8700[_0x3f40('0x22')]=qs[_0x3f40('0x22')](_0x576623[_0x3f40('0x34')][_0x3f40('0x22')]);_0x2a8700['offset']=qs[_0x3f40('0x21')](_0x576623[_0x3f40('0x34')][_0x3f40('0x21')]);}return _0x31dbdb[_0x3f40('0x51')](_0x2a8700);}})[_0x3f40('0x28')](function(_0x49ea08){if(_0x49ea08){return _0x49ea08?{'count':_0x5bde61,'rows':_0x49ea08}:null;}})[_0x3f40('0x28')](respondWithResult(_0x5b00ed,null))[_0x3f40('0x48')](handleError(_0x5b00ed,null));};
\ No newline at end of file
+var _0x6bb1=['getDescriptions','rimraf','zip-dir','fast-json-patch','mustache','sox','to-csv','ejs','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','json','undefined','offset','count','limit','status','set','Content-Range','apply','save','then','destroy','error','stack','name','send','index','map','SugarcrmConfiguration','rawAttributes','fieldName','type','model','keys','filters','intersection','query','attributes','length','hasOwnProperty','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','fields','find','create','body','params','getFields','findOne','SugarcrmField','pick','nolimit','getSubjects'];(function(_0x187ee1,_0x3fd1e6){var _0x388160=function(_0x542dd2){while(--_0x542dd2){_0x187ee1['push'](_0x187ee1['shift']());}};_0x388160(++_0x3fd1e6);}(_0x6bb1,0x1cf));var _0x16bb=function(_0x3bf80d,_0x2650df){_0x3bf80d=_0x3bf80d-0x0;var _0x505f21=_0x6bb1[_0x3bf80d];return _0x505f21;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x16bb('0x0'));var zipdir=require(_0x16bb('0x1'));var jsonpatch=require(_0x16bb('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x16bb('0x3'));var util=require('util');var path=require('path');var sox=require(_0x16bb('0x4'));var csv=require(_0x16bb('0x5'));var ejs=require(_0x16bb('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require('squel');var crypto=require(_0x16bb('0x7'));var jsforce=require(_0x16bb('0x8'));var deskjs=require(_0x16bb('0x9'));var toCsv=require(_0x16bb('0x5'));var querystring=require(_0x16bb('0xa'));var Papa=require(_0x16bb('0xb'));var Redis=require('ioredis');var authService=require(_0x16bb('0xc'));var qs=require(_0x16bb('0xd'));var as=require(_0x16bb('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x16bb('0xf'))('api');var utils=require(_0x16bb('0x10'));var config=require(_0x16bb('0x11'));var licenseUtil=require(_0x16bb('0x12'));var db=require(_0x16bb('0x13'))['db'];function respondWithStatusCode(_0x461c2e,_0x5c5763){_0x5c5763=_0x5c5763||0xcc;return function(_0x20fef8){if(_0x20fef8){return _0x461c2e[_0x16bb('0x14')](_0x5c5763);}return _0x461c2e['status'](_0x5c5763)[_0x16bb('0x15')]();};}function respondWithResult(_0x34d0a5,_0x1c3e6b){_0x1c3e6b=_0x1c3e6b||0xc8;return function(_0x231d61){if(_0x231d61){return _0x34d0a5['status'](_0x1c3e6b)[_0x16bb('0x16')](_0x231d61);}};}function respondWithFilteredResult(_0x2c2f45,_0x3160d2){return function(_0x16d8d8){if(_0x16d8d8){var _0xeba497=typeof _0x3160d2['offset']===_0x16bb('0x17')&&typeof _0x3160d2['limit']===_0x16bb('0x17');var _0x14bba5=_0x16d8d8['count'];var _0x34d25b=_0xeba497?0x0:_0x3160d2[_0x16bb('0x18')];var _0x4385c2=_0xeba497?_0x16d8d8[_0x16bb('0x19')]:_0x3160d2['offset']+_0x3160d2[_0x16bb('0x1a')];var _0x53bd98;if(_0x4385c2>=_0x14bba5){_0x4385c2=_0x14bba5;_0x53bd98=0xc8;}else{_0x53bd98=0xce;}_0x2c2f45[_0x16bb('0x1b')](_0x53bd98);return _0x2c2f45[_0x16bb('0x1c')](_0x16bb('0x1d'),_0x34d25b+'-'+_0x4385c2+'/'+_0x14bba5)[_0x16bb('0x16')](_0x16d8d8);}return null;};}function patchUpdates(_0x505ab2){return function(_0x3c4a07){try{jsonpatch[_0x16bb('0x1e')](_0x3c4a07,_0x505ab2,!![]);}catch(_0x3affe0){return BPromise['reject'](_0x3affe0);}return _0x3c4a07[_0x16bb('0x1f')]();};}function saveUpdates(_0x1c80a2,_0x39a881){return function(_0x4145a2){if(_0x4145a2){return _0x4145a2['update'](_0x1c80a2)[_0x16bb('0x20')](function(_0x2fb83c){return _0x2fb83c;});}return null;};}function removeEntity(_0x2c5ad6,_0x3717cc){return function(_0x46d7c8){if(_0x46d7c8){return _0x46d7c8[_0x16bb('0x21')]()[_0x16bb('0x20')](function(){_0x2c5ad6[_0x16bb('0x1b')](0xcc)[_0x16bb('0x15')]();});}};}function handleEntityNotFound(_0x14d6cb,_0x517a28){return function(_0x5b2b08){if(!_0x5b2b08){_0x14d6cb[_0x16bb('0x14')](0x194);}return _0x5b2b08;};}function handleError(_0x12f436,_0x534ac7){_0x534ac7=_0x534ac7||0x1f4;return function(_0x15dfc5){logger[_0x16bb('0x22')](_0x15dfc5[_0x16bb('0x23')]);if(_0x15dfc5[_0x16bb('0x24')]){delete _0x15dfc5[_0x16bb('0x24')];}_0x12f436[_0x16bb('0x1b')](_0x534ac7)[_0x16bb('0x25')](_0x15dfc5);};}exports[_0x16bb('0x26')]=function(_0x56a155,_0x21307b){var _0x10d324={},_0x25ca6f={},_0x554f7c={'count':0x0,'rows':[]};var _0x25a731=_[_0x16bb('0x27')](db[_0x16bb('0x28')][_0x16bb('0x29')],function(_0x1fe89f){return{'name':_0x1fe89f[_0x16bb('0x2a')],'type':_0x1fe89f[_0x16bb('0x2b')]['key']};});_0x25ca6f[_0x16bb('0x2c')]=_[_0x16bb('0x27')](_0x25a731,_0x16bb('0x24'));_0x25ca6f['query']=_[_0x16bb('0x2d')](_0x56a155['query']);_0x25ca6f[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x25ca6f[_0x16bb('0x2c')],_0x25ca6f[_0x16bb('0x30')]);_0x10d324[_0x16bb('0x31')]=_['intersection'](_0x25ca6f[_0x16bb('0x2c')],qs['fields'](_0x56a155['query']['fields']));_0x10d324[_0x16bb('0x31')]=_0x10d324[_0x16bb('0x31')][_0x16bb('0x32')]?_0x10d324[_0x16bb('0x31')]:_0x25ca6f[_0x16bb('0x2c')];if(!_0x56a155[_0x16bb('0x30')][_0x16bb('0x33')]('nolimit')){_0x10d324[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0x56a155[_0x16bb('0x30')][_0x16bb('0x1a')]);_0x10d324['offset']=qs[_0x16bb('0x18')](_0x56a155['query'][_0x16bb('0x18')]);}_0x10d324[_0x16bb('0x34')]=qs[_0x16bb('0x35')](_0x56a155[_0x16bb('0x30')][_0x16bb('0x35')]);_0x10d324[_0x16bb('0x36')]=qs[_0x16bb('0x2e')](_['pick'](_0x56a155[_0x16bb('0x30')],_0x25ca6f[_0x16bb('0x2e')]),_0x25a731);if(_0x56a155[_0x16bb('0x30')][_0x16bb('0x37')]){_0x10d324[_0x16bb('0x36')]=_['merge'](_0x10d324['where'],{'$or':_[_0x16bb('0x27')](_0x25a731,function(_0x4c5ccb){if(_0x4c5ccb[_0x16bb('0x2b')]!==_0x16bb('0x38')){var _0x2c5d1a={};_0x2c5d1a[_0x4c5ccb[_0x16bb('0x24')]]={'$like':'%'+_0x56a155[_0x16bb('0x30')]['filter']+'%'};return _0x2c5d1a;}})});}_0x10d324=_[_0x16bb('0x39')]({},_0x10d324,_0x56a155[_0x16bb('0x3a')]);var _0x5a164c={'where':_0x10d324['where']};return db[_0x16bb('0x28')]['count'](_0x5a164c)[_0x16bb('0x20')](function(_0x62e3f0){_0x554f7c[_0x16bb('0x19')]=_0x62e3f0;if(_0x56a155['query'][_0x16bb('0x3b')]){_0x10d324[_0x16bb('0x3c')]=[{'all':!![]}];}return db[_0x16bb('0x28')][_0x16bb('0x3d')](_0x10d324);})[_0x16bb('0x20')](function(_0x28ef2f){_0x554f7c[_0x16bb('0x3e')]=_0x28ef2f;return _0x554f7c;})[_0x16bb('0x20')](respondWithFilteredResult(_0x21307b,_0x10d324))[_0x16bb('0x3f')](handleError(_0x21307b,null));};exports[_0x16bb('0x40')]=function(_0x4cd7d6,_0x30332c){var _0x517bed={'raw':![],'where':{'id':_0x4cd7d6['params']['id']}},_0x387a79={};_0x387a79[_0x16bb('0x2c')]=_[_0x16bb('0x2d')](db[_0x16bb('0x28')]['rawAttributes']);_0x387a79[_0x16bb('0x30')]=_[_0x16bb('0x2d')](_0x4cd7d6[_0x16bb('0x30')]);_0x387a79[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x387a79[_0x16bb('0x2c')],_0x387a79[_0x16bb('0x30')]);_0x517bed[_0x16bb('0x31')]=_['intersection'](_0x387a79[_0x16bb('0x2c')],qs[_0x16bb('0x41')](_0x4cd7d6[_0x16bb('0x30')][_0x16bb('0x41')]));_0x517bed[_0x16bb('0x31')]=_0x517bed[_0x16bb('0x31')][_0x16bb('0x32')]?_0x517bed['attributes']:_0x387a79[_0x16bb('0x2c')];if(_0x4cd7d6[_0x16bb('0x30')][_0x16bb('0x3b')]){_0x517bed[_0x16bb('0x3c')]=[{'all':!![]}];}_0x517bed=_[_0x16bb('0x39')]({},_0x517bed,_0x4cd7d6[_0x16bb('0x3a')]);return db['SugarcrmConfiguration'][_0x16bb('0x42')](_0x517bed)['then'](handleEntityNotFound(_0x30332c,null))[_0x16bb('0x20')](respondWithResult(_0x30332c,null))[_0x16bb('0x3f')](handleError(_0x30332c,null));};exports['create']=function(_0x10e66e,_0x7eb48e){return db[_0x16bb('0x28')][_0x16bb('0x43')](_0x10e66e[_0x16bb('0x44')],{})[_0x16bb('0x20')](respondWithResult(_0x7eb48e,0xc9))[_0x16bb('0x3f')](handleError(_0x7eb48e,null));};exports['update']=function(_0xd4985,_0x400933){if(_0xd4985[_0x16bb('0x44')]['id']){delete _0xd4985['body']['id'];}return db[_0x16bb('0x28')][_0x16bb('0x42')]({'where':{'id':_0xd4985[_0x16bb('0x45')]['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x400933,null))['then'](saveUpdates(_0xd4985[_0x16bb('0x44')],null))[_0x16bb('0x20')](respondWithResult(_0x400933,null))[_0x16bb('0x3f')](handleError(_0x400933,null));};exports[_0x16bb('0x21')]=function(_0x4eb48f,_0x136de1){return db[_0x16bb('0x28')][_0x16bb('0x42')]({'where':{'id':_0x4eb48f['params']['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x136de1,null))[_0x16bb('0x20')](removeEntity(_0x136de1,null))[_0x16bb('0x3f')](handleError(_0x136de1,null));};exports[_0x16bb('0x46')]=function(_0x269ae3,_0x38b131,_0x37ead1){var _0x17ed8a={};var _0x224ef5={};var _0x4eede6;var _0x5abef4;return db[_0x16bb('0x28')][_0x16bb('0x47')]({'where':{'id':_0x269ae3['params']['id']}})['then'](handleEntityNotFound(_0x38b131,null))['then'](function(_0x1ea100){if(_0x1ea100){_0x4eede6=_0x1ea100;_0x224ef5[_0x16bb('0x2c')]=_[_0x16bb('0x2d')](db[_0x16bb('0x48')][_0x16bb('0x29')]);_0x224ef5[_0x16bb('0x30')]=_[_0x16bb('0x2d')](_0x269ae3[_0x16bb('0x30')]);_0x224ef5[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x224ef5[_0x16bb('0x2c')],_0x224ef5[_0x16bb('0x30')]);_0x17ed8a['attributes']=_[_0x16bb('0x2f')](_0x224ef5[_0x16bb('0x2c')],qs[_0x16bb('0x41')](_0x269ae3[_0x16bb('0x30')][_0x16bb('0x41')]));_0x17ed8a[_0x16bb('0x31')]=_0x17ed8a['attributes'][_0x16bb('0x32')]?_0x17ed8a[_0x16bb('0x31')]:_0x224ef5[_0x16bb('0x2c')];_0x17ed8a[_0x16bb('0x34')]=qs['sort'](_0x269ae3['query'][_0x16bb('0x35')]);_0x17ed8a[_0x16bb('0x36')]=qs[_0x16bb('0x2e')](_[_0x16bb('0x49')](_0x269ae3[_0x16bb('0x30')],_0x224ef5[_0x16bb('0x2e')]));if(_0x269ae3[_0x16bb('0x30')][_0x16bb('0x37')]){_0x17ed8a[_0x16bb('0x36')]=_[_0x16bb('0x39')](_0x17ed8a[_0x16bb('0x36')],{'$or':_['map'](_0x17ed8a[_0x16bb('0x31')],function(_0x428868){var _0x591663={};_0x591663[_0x428868]={'$like':'%'+_0x269ae3[_0x16bb('0x30')]['filter']+'%'};return _0x591663;})});}_0x17ed8a=_[_0x16bb('0x39')]({},_0x17ed8a,_0x269ae3[_0x16bb('0x3a')]);return _0x4eede6['getFields'](_0x17ed8a);}})[_0x16bb('0x20')](function(_0x720210){if(_0x720210){_0x5abef4=_0x720210['length'];if(!_0x269ae3[_0x16bb('0x30')]['hasOwnProperty'](_0x16bb('0x4a'))){_0x17ed8a[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0x269ae3[_0x16bb('0x30')][_0x16bb('0x1a')]);_0x17ed8a[_0x16bb('0x18')]=qs[_0x16bb('0x18')](_0x269ae3[_0x16bb('0x30')][_0x16bb('0x18')]);}return _0x4eede6[_0x16bb('0x46')](_0x17ed8a);}})[_0x16bb('0x20')](function(_0x1e1fb1){if(_0x1e1fb1){return _0x1e1fb1?{'count':_0x5abef4,'rows':_0x1e1fb1}:null;}})['then'](respondWithResult(_0x38b131,null))[_0x16bb('0x3f')](handleError(_0x38b131,null));};exports['getSubjects']=function(_0xcd21dc,_0x2b4062,_0x47387a){var _0x5a5fdd={};var _0x43cec={};var _0x27a378;var _0x466d37;return db[_0x16bb('0x28')][_0x16bb('0x47')]({'where':{'id':_0xcd21dc[_0x16bb('0x45')]['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x2b4062,null))[_0x16bb('0x20')](function(_0x573bf){if(_0x573bf){_0x27a378=_0x573bf;_0x43cec[_0x16bb('0x2c')]=_['keys'](db[_0x16bb('0x48')]['rawAttributes']);_0x43cec['query']=_['keys'](_0xcd21dc[_0x16bb('0x30')]);_0x43cec[_0x16bb('0x2e')]=_[_0x16bb('0x2f')](_0x43cec['model'],_0x43cec[_0x16bb('0x30')]);_0x5a5fdd[_0x16bb('0x31')]=_[_0x16bb('0x2f')](_0x43cec[_0x16bb('0x2c')],qs[_0x16bb('0x41')](_0xcd21dc['query'][_0x16bb('0x41')]));_0x5a5fdd[_0x16bb('0x31')]=_0x5a5fdd[_0x16bb('0x31')][_0x16bb('0x32')]?_0x5a5fdd[_0x16bb('0x31')]:_0x43cec[_0x16bb('0x2c')];_0x5a5fdd[_0x16bb('0x34')]=qs['sort'](_0xcd21dc['query'][_0x16bb('0x35')]);_0x5a5fdd['where']=qs[_0x16bb('0x2e')](_['pick'](_0xcd21dc['query'],_0x43cec['filters']));if(_0xcd21dc[_0x16bb('0x30')]['filter']){_0x5a5fdd[_0x16bb('0x36')]=_[_0x16bb('0x39')](_0x5a5fdd[_0x16bb('0x36')],{'$or':_[_0x16bb('0x27')](_0x5a5fdd[_0x16bb('0x31')],function(_0x5d626){var _0x24e521={};_0x24e521[_0x5d626]={'$like':'%'+_0xcd21dc[_0x16bb('0x30')]['filter']+'%'};return _0x24e521;})});}_0x5a5fdd=_[_0x16bb('0x39')]({},_0x5a5fdd,_0xcd21dc['options']);return _0x27a378['getSubjects'](_0x5a5fdd);}})[_0x16bb('0x20')](function(_0x499a43){if(_0x499a43){_0x466d37=_0x499a43[_0x16bb('0x32')];if(!_0xcd21dc[_0x16bb('0x30')][_0x16bb('0x33')](_0x16bb('0x4a'))){_0x5a5fdd[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0xcd21dc['query']['limit']);_0x5a5fdd['offset']=qs['offset'](_0xcd21dc['query'][_0x16bb('0x18')]);}return _0x27a378[_0x16bb('0x4b')](_0x5a5fdd);}})['then'](function(_0x3702d7){if(_0x3702d7){return _0x3702d7?{'count':_0x466d37,'rows':_0x3702d7}:null;}})[_0x16bb('0x20')](respondWithResult(_0x2b4062,null))[_0x16bb('0x3f')](handleError(_0x2b4062,null));};exports[_0x16bb('0x4c')]=function(_0x3ee984,_0x1a7013,_0x5c401e){var _0xf80464={};var _0x1d6d06={};var _0xd77c89;var _0x3d38b9;return db[_0x16bb('0x28')][_0x16bb('0x47')]({'where':{'id':_0x3ee984[_0x16bb('0x45')]['id']}})[_0x16bb('0x20')](handleEntityNotFound(_0x1a7013,null))[_0x16bb('0x20')](function(_0xa8e26b){if(_0xa8e26b){_0xd77c89=_0xa8e26b;_0x1d6d06[_0x16bb('0x2c')]=_['keys'](db[_0x16bb('0x48')][_0x16bb('0x29')]);_0x1d6d06[_0x16bb('0x30')]=_['keys'](_0x3ee984[_0x16bb('0x30')]);_0x1d6d06[_0x16bb('0x2e')]=_['intersection'](_0x1d6d06['model'],_0x1d6d06[_0x16bb('0x30')]);_0xf80464[_0x16bb('0x31')]=_[_0x16bb('0x2f')](_0x1d6d06['model'],qs[_0x16bb('0x41')](_0x3ee984[_0x16bb('0x30')][_0x16bb('0x41')]));_0xf80464[_0x16bb('0x31')]=_0xf80464[_0x16bb('0x31')][_0x16bb('0x32')]?_0xf80464[_0x16bb('0x31')]:_0x1d6d06[_0x16bb('0x2c')];_0xf80464['order']=qs[_0x16bb('0x35')](_0x3ee984[_0x16bb('0x30')]['sort']);_0xf80464[_0x16bb('0x36')]=qs['filters'](_[_0x16bb('0x49')](_0x3ee984['query'],_0x1d6d06['filters']));if(_0x3ee984['query'][_0x16bb('0x37')]){_0xf80464[_0x16bb('0x36')]=_[_0x16bb('0x39')](_0xf80464[_0x16bb('0x36')],{'$or':_[_0x16bb('0x27')](_0xf80464[_0x16bb('0x31')],function(_0x4ad651){var _0x527392={};_0x527392[_0x4ad651]={'$like':'%'+_0x3ee984[_0x16bb('0x30')][_0x16bb('0x37')]+'%'};return _0x527392;})});}_0xf80464=_[_0x16bb('0x39')]({},_0xf80464,_0x3ee984['options']);return _0xd77c89[_0x16bb('0x4c')](_0xf80464);}})['then'](function(_0x4a8674){if(_0x4a8674){_0x3d38b9=_0x4a8674[_0x16bb('0x32')];if(!_0x3ee984[_0x16bb('0x30')][_0x16bb('0x33')](_0x16bb('0x4a'))){_0xf80464[_0x16bb('0x1a')]=qs[_0x16bb('0x1a')](_0x3ee984[_0x16bb('0x30')][_0x16bb('0x1a')]);_0xf80464[_0x16bb('0x18')]=qs[_0x16bb('0x18')](_0x3ee984[_0x16bb('0x30')]['offset']);}return _0xd77c89[_0x16bb('0x4c')](_0xf80464);}})[_0x16bb('0x20')](function(_0x1b7cdf){if(_0x1b7cdf){return _0x1b7cdf?{'count':_0x3d38b9,'rows':_0x1b7cdf}:null;}})['then'](respondWithResult(_0x1a7013,null))[_0x16bb('0x3f')](handleError(_0x1a7013,null));};
\ No newline at end of file