Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 9e17d71..6d0cbd0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x123b=['zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','sendStatus','status','end','json','undefined','offset','count','limit','set','Content-Range','apply','save','update','destroy','error','stack','name','send','index','map','FreshsalesConfiguration','rawAttributes','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','then','includeAll','include','findAll','rows','catch','show','params','find','create','body','getSubjects','FreshsalesField','getDescriptions','findOne','getFields'];(function(_0x44b362,_0x1b5fd9){var _0x38b45c=function(_0x163919){while(--_0x163919){_0x44b362['push'](_0x44b362['shift']());}};_0x38b45c(++_0x1b5fd9);}(_0x123b,0x195));var _0xb123=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0x123b[_0x40a045];return _0x1a687c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xb123('0x0'));var jsonpatch=require(_0xb123('0x1'));var rp=require(_0xb123('0x2'));var moment=require('moment');var BPromise=require(_0xb123('0x3'));var Mustache=require(_0xb123('0x4'));var util=require(_0xb123('0x5'));var path=require(_0xb123('0x6'));var sox=require('sox');var csv=require(_0xb123('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb123('0x8'));var _=require(_0xb123('0x9'));var squel=require(_0xb123('0xa'));var crypto=require(_0xb123('0xb'));var jsforce=require(_0xb123('0xc'));var deskjs=require(_0xb123('0xd'));var toCsv=require(_0xb123('0x7'));var querystring=require(_0xb123('0xe'));var Papa=require('papaparse');var Redis=require(_0xb123('0xf'));var authService=require(_0xb123('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xb123('0x11'));var hardwareService=require(_0xb123('0x12'));var logger=require(_0xb123('0x13'))('api');var utils=require('../../config/utils');var config=require(_0xb123('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xb123('0x15'))['db'];function respondWithStatusCode(_0x5a9d02,_0x96a298){_0x96a298=_0x96a298||0xcc;return function(_0x4c5153){if(_0x4c5153){return _0x5a9d02[_0xb123('0x16')](_0x96a298);}return _0x5a9d02[_0xb123('0x17')](_0x96a298)[_0xb123('0x18')]();};}function respondWithResult(_0x30955d,_0x5b9db3){_0x5b9db3=_0x5b9db3||0xc8;return function(_0x1e5c9b){if(_0x1e5c9b){return _0x30955d[_0xb123('0x17')](_0x5b9db3)[_0xb123('0x19')](_0x1e5c9b);}};}function respondWithFilteredResult(_0x1cfb93,_0x56855a){return function(_0x17155d){if(_0x17155d){var _0xfe3250=typeof _0x56855a['offset']===_0xb123('0x1a')&&typeof _0x56855a['limit']===_0xb123('0x1a');var _0x121e0d=_0x17155d['count'];var _0x45312e=_0xfe3250?0x0:_0x56855a[_0xb123('0x1b')];var _0x1506c1=_0xfe3250?_0x17155d[_0xb123('0x1c')]:_0x56855a[_0xb123('0x1b')]+_0x56855a[_0xb123('0x1d')];var _0x488906;if(_0x1506c1>=_0x121e0d){_0x1506c1=_0x121e0d;_0x488906=0xc8;}else{_0x488906=0xce;}_0x1cfb93[_0xb123('0x17')](_0x488906);return _0x1cfb93[_0xb123('0x1e')](_0xb123('0x1f'),_0x45312e+'-'+_0x1506c1+'/'+_0x121e0d)[_0xb123('0x19')](_0x17155d);}return null;};}function patchUpdates(_0x39f883){return function(_0x2f5ac8){try{jsonpatch[_0xb123('0x20')](_0x2f5ac8,_0x39f883,!![]);}catch(_0x4ef7bc){return BPromise['reject'](_0x4ef7bc);}return _0x2f5ac8[_0xb123('0x21')]();};}function saveUpdates(_0x547830,_0x2e332d){return function(_0x41ffbd){if(_0x41ffbd){return _0x41ffbd[_0xb123('0x22')](_0x547830)['then'](function(_0x37e3f6){return _0x37e3f6;});}return null;};}function removeEntity(_0x3ff831,_0x56c4de){return function(_0x1335ec){if(_0x1335ec){return _0x1335ec[_0xb123('0x23')]()['then'](function(){_0x3ff831[_0xb123('0x17')](0xcc)[_0xb123('0x18')]();});}};}function handleEntityNotFound(_0x545508,_0x4f0c9d){return function(_0x591876){if(!_0x591876){_0x545508[_0xb123('0x16')](0x194);}return _0x591876;};}function handleError(_0x587047,_0x2a41d1){_0x2a41d1=_0x2a41d1||0x1f4;return function(_0x39e603){logger[_0xb123('0x24')](_0x39e603[_0xb123('0x25')]);if(_0x39e603[_0xb123('0x26')]){delete _0x39e603[_0xb123('0x26')];}_0x587047[_0xb123('0x17')](_0x2a41d1)[_0xb123('0x27')](_0x39e603);};}exports[_0xb123('0x28')]=function(_0x168508,_0x1dbaec){var _0x193e6c={},_0x36084e={},_0x10a6fd={'count':0x0,'rows':[]};var _0x11cfd4=_[_0xb123('0x29')](db[_0xb123('0x2a')][_0xb123('0x2b')],function(_0x1f022a){return{'name':_0x1f022a[_0xb123('0x2c')],'type':_0x1f022a[_0xb123('0x2d')][_0xb123('0x2e')]};});_0x36084e[_0xb123('0x2f')]=_[_0xb123('0x29')](_0x11cfd4,_0xb123('0x26'));_0x36084e[_0xb123('0x30')]=_[_0xb123('0x31')](_0x168508[_0xb123('0x30')]);_0x36084e[_0xb123('0x32')]=_['intersection'](_0x36084e[_0xb123('0x2f')],_0x36084e['query']);_0x193e6c[_0xb123('0x33')]=_[_0xb123('0x34')](_0x36084e[_0xb123('0x2f')],qs[_0xb123('0x35')](_0x168508[_0xb123('0x30')][_0xb123('0x35')]));_0x193e6c[_0xb123('0x33')]=_0x193e6c[_0xb123('0x33')][_0xb123('0x36')]?_0x193e6c[_0xb123('0x33')]:_0x36084e[_0xb123('0x2f')];if(!_0x168508[_0xb123('0x30')][_0xb123('0x37')](_0xb123('0x38'))){_0x193e6c[_0xb123('0x1d')]=qs['limit'](_0x168508[_0xb123('0x30')][_0xb123('0x1d')]);_0x193e6c['offset']=qs['offset'](_0x168508[_0xb123('0x30')]['offset']);}_0x193e6c[_0xb123('0x39')]=qs[_0xb123('0x3a')](_0x168508[_0xb123('0x30')][_0xb123('0x3a')]);_0x193e6c[_0xb123('0x3b')]=qs[_0xb123('0x32')](_[_0xb123('0x3c')](_0x168508['query'],_0x36084e[_0xb123('0x32')]),_0x11cfd4);if(_0x168508['query'][_0xb123('0x3d')]){_0x193e6c[_0xb123('0x3b')]=_[_0xb123('0x3e')](_0x193e6c[_0xb123('0x3b')],{'$or':_[_0xb123('0x29')](_0x11cfd4,function(_0xf9654b){if(_0xf9654b['type']!==_0xb123('0x3f')){var _0x425d30={};_0x425d30[_0xf9654b['name']]={'$like':'%'+_0x168508[_0xb123('0x30')][_0xb123('0x3d')]+'%'};return _0x425d30;}})});}_0x193e6c=_[_0xb123('0x3e')]({},_0x193e6c,_0x168508[_0xb123('0x40')]);var _0x3860e9={'where':_0x193e6c[_0xb123('0x3b')]};return db[_0xb123('0x2a')]['count'](_0x3860e9)[_0xb123('0x41')](function(_0x473a26){_0x10a6fd[_0xb123('0x1c')]=_0x473a26;if(_0x168508[_0xb123('0x30')][_0xb123('0x42')]){_0x193e6c[_0xb123('0x43')]=[{'all':!![]}];}return db[_0xb123('0x2a')][_0xb123('0x44')](_0x193e6c);})[_0xb123('0x41')](function(_0x4553c5){_0x10a6fd[_0xb123('0x45')]=_0x4553c5;return _0x10a6fd;})[_0xb123('0x41')](respondWithFilteredResult(_0x1dbaec,_0x193e6c))[_0xb123('0x46')](handleError(_0x1dbaec,null));};exports[_0xb123('0x47')]=function(_0x20b22d,_0x464cb3){var _0x4b853c={'raw':![],'where':{'id':_0x20b22d[_0xb123('0x48')]['id']}},_0x5d3919={};_0x5d3919['model']=_[_0xb123('0x31')](db[_0xb123('0x2a')][_0xb123('0x2b')]);_0x5d3919[_0xb123('0x30')]=_[_0xb123('0x31')](_0x20b22d[_0xb123('0x30')]);_0x5d3919[_0xb123('0x32')]=_[_0xb123('0x34')](_0x5d3919[_0xb123('0x2f')],_0x5d3919[_0xb123('0x30')]);_0x4b853c[_0xb123('0x33')]=_[_0xb123('0x34')](_0x5d3919[_0xb123('0x2f')],qs['fields'](_0x20b22d[_0xb123('0x30')][_0xb123('0x35')]));_0x4b853c[_0xb123('0x33')]=_0x4b853c[_0xb123('0x33')][_0xb123('0x36')]?_0x4b853c[_0xb123('0x33')]:_0x5d3919[_0xb123('0x2f')];if(_0x20b22d[_0xb123('0x30')]['includeAll']){_0x4b853c[_0xb123('0x43')]=[{'all':!![]}];}_0x4b853c=_[_0xb123('0x3e')]({},_0x4b853c,_0x20b22d[_0xb123('0x40')]);return db[_0xb123('0x2a')][_0xb123('0x49')](_0x4b853c)['then'](handleEntityNotFound(_0x464cb3,null))[_0xb123('0x41')](respondWithResult(_0x464cb3,null))[_0xb123('0x46')](handleError(_0x464cb3,null));};exports['create']=function(_0x2a9089,_0x3d9608){return db[_0xb123('0x2a')][_0xb123('0x4a')](_0x2a9089[_0xb123('0x4b')],{})['then'](respondWithResult(_0x3d9608,0xc9))[_0xb123('0x46')](handleError(_0x3d9608,null));};exports['update']=function(_0x178ed1,_0x32c61f){if(_0x178ed1[_0xb123('0x4b')]['id']){delete _0x178ed1[_0xb123('0x4b')]['id'];}return db[_0xb123('0x2a')][_0xb123('0x49')]({'where':{'id':_0x178ed1[_0xb123('0x48')]['id']}})[_0xb123('0x41')](handleEntityNotFound(_0x32c61f,null))[_0xb123('0x41')](saveUpdates(_0x178ed1[_0xb123('0x4b')],null))[_0xb123('0x41')](respondWithResult(_0x32c61f,null))[_0xb123('0x46')](handleError(_0x32c61f,null));};exports[_0xb123('0x23')]=function(_0x479ca1,_0x5c290e){return db[_0xb123('0x2a')]['find']({'where':{'id':_0x479ca1[_0xb123('0x48')]['id']}})['then'](handleEntityNotFound(_0x5c290e,null))[_0xb123('0x41')](removeEntity(_0x5c290e,null))[_0xb123('0x46')](handleError(_0x5c290e,null));};exports[_0xb123('0x4c')]=function(_0x2c966a,_0x56ea7d,_0x1f13d6){var _0x4faf9a={};var _0x5197df={};var _0x5d4566;var _0x1b1266;return db[_0xb123('0x2a')]['findOne']({'where':{'id':_0x2c966a[_0xb123('0x48')]['id']}})[_0xb123('0x41')](handleEntityNotFound(_0x56ea7d,null))[_0xb123('0x41')](function(_0x24f725){if(_0x24f725){_0x5d4566=_0x24f725;_0x5197df[_0xb123('0x2f')]=_['keys'](db[_0xb123('0x4d')][_0xb123('0x2b')]);_0x5197df[_0xb123('0x30')]=_['keys'](_0x2c966a['query']);_0x5197df[_0xb123('0x32')]=_['intersection'](_0x5197df['model'],_0x5197df[_0xb123('0x30')]);_0x4faf9a[_0xb123('0x33')]=_[_0xb123('0x34')](_0x5197df['model'],qs[_0xb123('0x35')](_0x2c966a[_0xb123('0x30')][_0xb123('0x35')]));_0x4faf9a[_0xb123('0x33')]=_0x4faf9a['attributes']['length']?_0x4faf9a[_0xb123('0x33')]:_0x5197df['model'];_0x4faf9a[_0xb123('0x39')]=qs[_0xb123('0x3a')](_0x2c966a[_0xb123('0x30')][_0xb123('0x3a')]);_0x4faf9a[_0xb123('0x3b')]=qs[_0xb123('0x32')](_['pick'](_0x2c966a[_0xb123('0x30')],_0x5197df[_0xb123('0x32')]));if(_0x2c966a['query'][_0xb123('0x3d')]){_0x4faf9a[_0xb123('0x3b')]=_[_0xb123('0x3e')](_0x4faf9a[_0xb123('0x3b')],{'$or':_['map'](_0x4faf9a[_0xb123('0x33')],function(_0x482508){var _0x3e127={};_0x3e127[_0x482508]={'$like':'%'+_0x2c966a[_0xb123('0x30')]['filter']+'%'};return _0x3e127;})});}_0x4faf9a=_['merge']({},_0x4faf9a,_0x2c966a[_0xb123('0x40')]);return _0x5d4566[_0xb123('0x4c')](_0x4faf9a);}})[_0xb123('0x41')](function(_0x2f1ba6){if(_0x2f1ba6){_0x1b1266=_0x2f1ba6[_0xb123('0x36')];if(!_0x2c966a[_0xb123('0x30')]['hasOwnProperty']('nolimit')){_0x4faf9a[_0xb123('0x1d')]=qs[_0xb123('0x1d')](_0x2c966a['query'][_0xb123('0x1d')]);_0x4faf9a[_0xb123('0x1b')]=qs[_0xb123('0x1b')](_0x2c966a[_0xb123('0x30')][_0xb123('0x1b')]);}return _0x5d4566[_0xb123('0x4c')](_0x4faf9a);}})[_0xb123('0x41')](function(_0x45e00c){if(_0x45e00c){return _0x45e00c?{'count':_0x1b1266,'rows':_0x45e00c}:null;}})[_0xb123('0x41')](respondWithResult(_0x56ea7d,null))[_0xb123('0x46')](handleError(_0x56ea7d,null));};exports[_0xb123('0x4e')]=function(_0x197a0d,_0x27c476,_0x5933a6){var _0x1abcba={};var _0x1c4f97={};var _0x53270b;var _0x4af326;return db[_0xb123('0x2a')][_0xb123('0x4f')]({'where':{'id':_0x197a0d['params']['id']}})['then'](handleEntityNotFound(_0x27c476,null))['then'](function(_0x11297b){if(_0x11297b){_0x53270b=_0x11297b;_0x1c4f97[_0xb123('0x2f')]=_[_0xb123('0x31')](db[_0xb123('0x4d')]['rawAttributes']);_0x1c4f97[_0xb123('0x30')]=_['keys'](_0x197a0d[_0xb123('0x30')]);_0x1c4f97[_0xb123('0x32')]=_[_0xb123('0x34')](_0x1c4f97[_0xb123('0x2f')],_0x1c4f97[_0xb123('0x30')]);_0x1abcba[_0xb123('0x33')]=_[_0xb123('0x34')](_0x1c4f97[_0xb123('0x2f')],qs['fields'](_0x197a0d[_0xb123('0x30')]['fields']));_0x1abcba['attributes']=_0x1abcba[_0xb123('0x33')]['length']?_0x1abcba['attributes']:_0x1c4f97[_0xb123('0x2f')];_0x1abcba[_0xb123('0x39')]=qs['sort'](_0x197a0d[_0xb123('0x30')][_0xb123('0x3a')]);_0x1abcba[_0xb123('0x3b')]=qs[_0xb123('0x32')](_[_0xb123('0x3c')](_0x197a0d[_0xb123('0x30')],_0x1c4f97[_0xb123('0x32')]));if(_0x197a0d[_0xb123('0x30')][_0xb123('0x3d')]){_0x1abcba['where']=_[_0xb123('0x3e')](_0x1abcba[_0xb123('0x3b')],{'$or':_[_0xb123('0x29')](_0x1abcba[_0xb123('0x33')],function(_0x2772ec){var _0x3465e1={};_0x3465e1[_0x2772ec]={'$like':'%'+_0x197a0d[_0xb123('0x30')]['filter']+'%'};return _0x3465e1;})});}_0x1abcba=_['merge']({},_0x1abcba,_0x197a0d['options']);return _0x53270b['getDescriptions'](_0x1abcba);}})[_0xb123('0x41')](function(_0x4b6084){if(_0x4b6084){_0x4af326=_0x4b6084[_0xb123('0x36')];if(!_0x197a0d[_0xb123('0x30')][_0xb123('0x37')]('nolimit')){_0x1abcba[_0xb123('0x1d')]=qs[_0xb123('0x1d')](_0x197a0d[_0xb123('0x30')]['limit']);_0x1abcba[_0xb123('0x1b')]=qs['offset'](_0x197a0d[_0xb123('0x30')][_0xb123('0x1b')]);}return _0x53270b[_0xb123('0x4e')](_0x1abcba);}})[_0xb123('0x41')](function(_0xd3b3f){if(_0xd3b3f){return _0xd3b3f?{'count':_0x4af326,'rows':_0xd3b3f}:null;}})[_0xb123('0x41')](respondWithResult(_0x27c476,null))[_0xb123('0x46')](handleError(_0x27c476,null));};exports[_0xb123('0x50')]=function(_0x4892f8,_0xfaf4a9,_0x465475){var _0x949a6c={};var _0x1839ab={};var _0x5eb879;var _0x4daa8c;return db[_0xb123('0x2a')][_0xb123('0x4f')]({'where':{'id':_0x4892f8[_0xb123('0x48')]['id']}})['then'](handleEntityNotFound(_0xfaf4a9,null))[_0xb123('0x41')](function(_0x3fbc9f){if(_0x3fbc9f){_0x5eb879=_0x3fbc9f;_0x1839ab[_0xb123('0x2f')]=_[_0xb123('0x31')](db['FreshsalesField'][_0xb123('0x2b')]);_0x1839ab[_0xb123('0x30')]=_[_0xb123('0x31')](_0x4892f8['query']);_0x1839ab['filters']=_[_0xb123('0x34')](_0x1839ab['model'],_0x1839ab['query']);_0x949a6c[_0xb123('0x33')]=_[_0xb123('0x34')](_0x1839ab['model'],qs[_0xb123('0x35')](_0x4892f8[_0xb123('0x30')]['fields']));_0x949a6c[_0xb123('0x33')]=_0x949a6c[_0xb123('0x33')]['length']?_0x949a6c[_0xb123('0x33')]:_0x1839ab[_0xb123('0x2f')];_0x949a6c[_0xb123('0x39')]=qs[_0xb123('0x3a')](_0x4892f8[_0xb123('0x30')][_0xb123('0x3a')]);_0x949a6c[_0xb123('0x3b')]=qs[_0xb123('0x32')](_[_0xb123('0x3c')](_0x4892f8[_0xb123('0x30')],_0x1839ab[_0xb123('0x32')]));if(_0x4892f8[_0xb123('0x30')]['filter']){_0x949a6c['where']=_[_0xb123('0x3e')](_0x949a6c[_0xb123('0x3b')],{'$or':_[_0xb123('0x29')](_0x949a6c[_0xb123('0x33')],function(_0x19e236){var _0x4eb7ff={};_0x4eb7ff[_0x19e236]={'$like':'%'+_0x4892f8[_0xb123('0x30')][_0xb123('0x3d')]+'%'};return _0x4eb7ff;})});}_0x949a6c=_['merge']({},_0x949a6c,_0x4892f8[_0xb123('0x40')]);return _0x5eb879[_0xb123('0x50')](_0x949a6c);}})[_0xb123('0x41')](function(_0x54406c){if(_0x54406c){_0x4daa8c=_0x54406c[_0xb123('0x36')];if(!_0x4892f8[_0xb123('0x30')][_0xb123('0x37')](_0xb123('0x38'))){_0x949a6c[_0xb123('0x1d')]=qs['limit'](_0x4892f8[_0xb123('0x30')][_0xb123('0x1d')]);_0x949a6c['offset']=qs[_0xb123('0x1b')](_0x4892f8[_0xb123('0x30')][_0xb123('0x1b')]);}return _0x5eb879[_0xb123('0x50')](_0x949a6c);}})[_0xb123('0x41')](function(_0x3957d6){if(_0x3957d6){return _0x3957d6?{'count':_0x4daa8c,'rows':_0x3957d6}:null;}})[_0xb123('0x41')](respondWithResult(_0xfaf4a9,null))[_0xb123('0x46')](handleError(_0xfaf4a9,null));};
\ No newline at end of file
+var _0x8cfa=['eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','error','stack','name','send','index','FreshsalesConfiguration','rawAttributes','fieldName','key','query','keys','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','merge','where','map','type','VIRTUAL','filter','options','includeAll','include','rows','catch','show','params','create','body','find','getSubjects','findOne','FreshsalesField','length','getDescriptions','getFields'];(function(_0xb8493a,_0x5a7636){var _0x1be485=function(_0x37df3b){while(--_0x37df3b){_0xb8493a['push'](_0xb8493a['shift']());}};_0x1be485(++_0x5a7636);}(_0x8cfa,0x1ec));var _0xa8cf=function(_0x5bec6f,_0x26e692){_0x5bec6f=_0x5bec6f-0x0;var _0x35b36d=_0x8cfa[_0x5bec6f];return _0x35b36d;};'use strict';var emlformat=require(_0xa8cf('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xa8cf('0x1'));var jsonpatch=require(_0xa8cf('0x2'));var rp=require(_0xa8cf('0x3'));var moment=require(_0xa8cf('0x4'));var BPromise=require(_0xa8cf('0x5'));var Mustache=require(_0xa8cf('0x6'));var util=require('util');var path=require(_0xa8cf('0x7'));var sox=require(_0xa8cf('0x8'));var csv=require(_0xa8cf('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa8cf('0xa'));var squel=require(_0xa8cf('0xb'));var crypto=require(_0xa8cf('0xc'));var jsforce=require(_0xa8cf('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xa8cf('0x9'));var querystring=require(_0xa8cf('0xe'));var Papa=require('papaparse');var Redis=require(_0xa8cf('0xf'));var authService=require(_0xa8cf('0x10'));var qs=require(_0xa8cf('0x11'));var as=require(_0xa8cf('0x12'));var hardwareService=require(_0xa8cf('0x13'));var logger=require(_0xa8cf('0x14'))(_0xa8cf('0x15'));var utils=require(_0xa8cf('0x16'));var config=require(_0xa8cf('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xa8cf('0x18'))['db'];function respondWithStatusCode(_0x1f2c50,_0x1cda72){_0x1cda72=_0x1cda72||0xcc;return function(_0x3364d8){if(_0x3364d8){return _0x1f2c50[_0xa8cf('0x19')](_0x1cda72);}return _0x1f2c50[_0xa8cf('0x1a')](_0x1cda72)[_0xa8cf('0x1b')]();};}function respondWithResult(_0x1e8c6f,_0x4e9647){_0x4e9647=_0x4e9647||0xc8;return function(_0x1a9b12){if(_0x1a9b12){return _0x1e8c6f[_0xa8cf('0x1a')](_0x4e9647)[_0xa8cf('0x1c')](_0x1a9b12);}};}function respondWithFilteredResult(_0x321c48,_0x3cddec){return function(_0x273a67){if(_0x273a67){var _0xa1328a=typeof _0x3cddec[_0xa8cf('0x1d')]===_0xa8cf('0x1e')&&typeof _0x3cddec[_0xa8cf('0x1f')]===_0xa8cf('0x1e');var _0x465c97=_0x273a67[_0xa8cf('0x20')];var _0x3f6e7f=_0xa1328a?0x0:_0x3cddec[_0xa8cf('0x1d')];var _0x4647cd=_0xa1328a?_0x273a67['count']:_0x3cddec[_0xa8cf('0x1d')]+_0x3cddec[_0xa8cf('0x1f')];var _0x3ea358;if(_0x4647cd>=_0x465c97){_0x4647cd=_0x465c97;_0x3ea358=0xc8;}else{_0x3ea358=0xce;}_0x321c48[_0xa8cf('0x1a')](_0x3ea358);return _0x321c48['set'](_0xa8cf('0x21'),_0x3f6e7f+'-'+_0x4647cd+'/'+_0x465c97)['json'](_0x273a67);}return null;};}function patchUpdates(_0x21ed08){return function(_0x363c15){try{jsonpatch[_0xa8cf('0x22')](_0x363c15,_0x21ed08,!![]);}catch(_0x1abbb4){return BPromise[_0xa8cf('0x23')](_0x1abbb4);}return _0x363c15[_0xa8cf('0x24')]();};}function saveUpdates(_0x424985,_0x4297a4){return function(_0x29ed49){if(_0x29ed49){return _0x29ed49[_0xa8cf('0x25')](_0x424985)['then'](function(_0x59e106){return _0x59e106;});}return null;};}function removeEntity(_0x12e242,_0x1b24d5){return function(_0xff7389){if(_0xff7389){return _0xff7389['destroy']()[_0xa8cf('0x26')](function(){_0x12e242[_0xa8cf('0x1a')](0xcc)[_0xa8cf('0x1b')]();});}};}function handleEntityNotFound(_0x3a1e03,_0x5219ec){return function(_0x385ee0){if(!_0x385ee0){_0x3a1e03[_0xa8cf('0x19')](0x194);}return _0x385ee0;};}function handleError(_0x4ae74b,_0x45d1fb){_0x45d1fb=_0x45d1fb||0x1f4;return function(_0xfbfdff){logger[_0xa8cf('0x27')](_0xfbfdff[_0xa8cf('0x28')]);if(_0xfbfdff[_0xa8cf('0x29')]){delete _0xfbfdff[_0xa8cf('0x29')];}_0x4ae74b['status'](_0x45d1fb)[_0xa8cf('0x2a')](_0xfbfdff);};}exports[_0xa8cf('0x2b')]=function(_0x237338,_0x4fcc9e){var _0x5a743c={},_0x312a36={},_0x58a08f={'count':0x0,'rows':[]};var _0x10625b=_['map'](db[_0xa8cf('0x2c')][_0xa8cf('0x2d')],function(_0x42f181){return{'name':_0x42f181[_0xa8cf('0x2e')],'type':_0x42f181['type'][_0xa8cf('0x2f')]};});_0x312a36['model']=_['map'](_0x10625b,_0xa8cf('0x29'));_0x312a36[_0xa8cf('0x30')]=_[_0xa8cf('0x31')](_0x237338[_0xa8cf('0x30')]);_0x312a36[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x312a36[_0xa8cf('0x34')],_0x312a36['query']);_0x5a743c[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x312a36['model'],qs['fields'](_0x237338['query'][_0xa8cf('0x36')]));_0x5a743c[_0xa8cf('0x35')]=_0x5a743c[_0xa8cf('0x35')]['length']?_0x5a743c[_0xa8cf('0x35')]:_0x312a36[_0xa8cf('0x34')];if(!_0x237338[_0xa8cf('0x30')][_0xa8cf('0x37')](_0xa8cf('0x38'))){_0x5a743c[_0xa8cf('0x1f')]=qs['limit'](_0x237338[_0xa8cf('0x30')][_0xa8cf('0x1f')]);_0x5a743c[_0xa8cf('0x1d')]=qs[_0xa8cf('0x1d')](_0x237338[_0xa8cf('0x30')][_0xa8cf('0x1d')]);}_0x5a743c[_0xa8cf('0x39')]=qs['sort'](_0x237338[_0xa8cf('0x30')][_0xa8cf('0x3a')]);_0x5a743c['where']=qs['filters'](_[_0xa8cf('0x3b')](_0x237338['query'],_0x312a36[_0xa8cf('0x32')]),_0x10625b);if(_0x237338[_0xa8cf('0x30')]['filter']){_0x5a743c['where']=_[_0xa8cf('0x3c')](_0x5a743c[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x10625b,function(_0xc4b4f3){if(_0xc4b4f3[_0xa8cf('0x3f')]!==_0xa8cf('0x40')){var _0x1837d5={};_0x1837d5[_0xc4b4f3[_0xa8cf('0x29')]]={'$like':'%'+_0x237338[_0xa8cf('0x30')][_0xa8cf('0x41')]+'%'};return _0x1837d5;}})});}_0x5a743c=_[_0xa8cf('0x3c')]({},_0x5a743c,_0x237338[_0xa8cf('0x42')]);var _0x3efe44={'where':_0x5a743c[_0xa8cf('0x3d')]};return db['FreshsalesConfiguration'][_0xa8cf('0x20')](_0x3efe44)[_0xa8cf('0x26')](function(_0x1d4f5c){_0x58a08f[_0xa8cf('0x20')]=_0x1d4f5c;if(_0x237338[_0xa8cf('0x30')][_0xa8cf('0x43')]){_0x5a743c[_0xa8cf('0x44')]=[{'all':!![]}];}return db[_0xa8cf('0x2c')]['findAll'](_0x5a743c);})[_0xa8cf('0x26')](function(_0xe08b7d){_0x58a08f[_0xa8cf('0x45')]=_0xe08b7d;return _0x58a08f;})[_0xa8cf('0x26')](respondWithFilteredResult(_0x4fcc9e,_0x5a743c))[_0xa8cf('0x46')](handleError(_0x4fcc9e,null));};exports[_0xa8cf('0x47')]=function(_0x1891d8,_0x4d3297){var _0x146285={'raw':![],'where':{'id':_0x1891d8[_0xa8cf('0x48')]['id']}},_0x2c03e7={};_0x2c03e7[_0xa8cf('0x34')]=_[_0xa8cf('0x31')](db[_0xa8cf('0x2c')][_0xa8cf('0x2d')]);_0x2c03e7[_0xa8cf('0x30')]=_[_0xa8cf('0x31')](_0x1891d8[_0xa8cf('0x30')]);_0x2c03e7[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x2c03e7[_0xa8cf('0x34')],_0x2c03e7['query']);_0x146285['attributes']=_[_0xa8cf('0x33')](_0x2c03e7[_0xa8cf('0x34')],qs[_0xa8cf('0x36')](_0x1891d8[_0xa8cf('0x30')][_0xa8cf('0x36')]));_0x146285['attributes']=_0x146285[_0xa8cf('0x35')]['length']?_0x146285['attributes']:_0x2c03e7['model'];if(_0x1891d8[_0xa8cf('0x30')][_0xa8cf('0x43')]){_0x146285['include']=[{'all':!![]}];}_0x146285=_[_0xa8cf('0x3c')]({},_0x146285,_0x1891d8[_0xa8cf('0x42')]);return db[_0xa8cf('0x2c')]['find'](_0x146285)[_0xa8cf('0x26')](handleEntityNotFound(_0x4d3297,null))[_0xa8cf('0x26')](respondWithResult(_0x4d3297,null))[_0xa8cf('0x46')](handleError(_0x4d3297,null));};exports[_0xa8cf('0x49')]=function(_0x5a87df,_0x54fdf7){return db['FreshsalesConfiguration'][_0xa8cf('0x49')](_0x5a87df[_0xa8cf('0x4a')],{})[_0xa8cf('0x26')](respondWithResult(_0x54fdf7,0xc9))[_0xa8cf('0x46')](handleError(_0x54fdf7,null));};exports[_0xa8cf('0x25')]=function(_0xbc0448,_0x4cbdcd){if(_0xbc0448[_0xa8cf('0x4a')]['id']){delete _0xbc0448['body']['id'];}return db['FreshsalesConfiguration'][_0xa8cf('0x4b')]({'where':{'id':_0xbc0448['params']['id']}})['then'](handleEntityNotFound(_0x4cbdcd,null))[_0xa8cf('0x26')](saveUpdates(_0xbc0448[_0xa8cf('0x4a')],null))[_0xa8cf('0x26')](respondWithResult(_0x4cbdcd,null))['catch'](handleError(_0x4cbdcd,null));};exports['destroy']=function(_0x100fc1,_0x5896f5){return db[_0xa8cf('0x2c')][_0xa8cf('0x4b')]({'where':{'id':_0x100fc1['params']['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x5896f5,null))['then'](removeEntity(_0x5896f5,null))[_0xa8cf('0x46')](handleError(_0x5896f5,null));};exports[_0xa8cf('0x4c')]=function(_0x4775ea,_0x1dcaa0,_0x378c88){var _0x47b4d6={};var _0x53bc55={};var _0x6ac78b;var _0xeebc95;return db[_0xa8cf('0x2c')][_0xa8cf('0x4d')]({'where':{'id':_0x4775ea[_0xa8cf('0x48')]['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x1dcaa0,null))[_0xa8cf('0x26')](function(_0x265a1b){if(_0x265a1b){_0x6ac78b=_0x265a1b;_0x53bc55[_0xa8cf('0x34')]=_[_0xa8cf('0x31')](db[_0xa8cf('0x4e')][_0xa8cf('0x2d')]);_0x53bc55['query']=_[_0xa8cf('0x31')](_0x4775ea[_0xa8cf('0x30')]);_0x53bc55[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x53bc55['model'],_0x53bc55['query']);_0x47b4d6[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x53bc55[_0xa8cf('0x34')],qs['fields'](_0x4775ea[_0xa8cf('0x30')][_0xa8cf('0x36')]));_0x47b4d6['attributes']=_0x47b4d6[_0xa8cf('0x35')][_0xa8cf('0x4f')]?_0x47b4d6[_0xa8cf('0x35')]:_0x53bc55[_0xa8cf('0x34')];_0x47b4d6[_0xa8cf('0x39')]=qs[_0xa8cf('0x3a')](_0x4775ea[_0xa8cf('0x30')]['sort']);_0x47b4d6[_0xa8cf('0x3d')]=qs[_0xa8cf('0x32')](_[_0xa8cf('0x3b')](_0x4775ea[_0xa8cf('0x30')],_0x53bc55[_0xa8cf('0x32')]));if(_0x4775ea[_0xa8cf('0x30')][_0xa8cf('0x41')]){_0x47b4d6[_0xa8cf('0x3d')]=_[_0xa8cf('0x3c')](_0x47b4d6[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x47b4d6[_0xa8cf('0x35')],function(_0x382193){var _0x2ccce6={};_0x2ccce6[_0x382193]={'$like':'%'+_0x4775ea['query']['filter']+'%'};return _0x2ccce6;})});}_0x47b4d6=_[_0xa8cf('0x3c')]({},_0x47b4d6,_0x4775ea['options']);return _0x6ac78b[_0xa8cf('0x4c')](_0x47b4d6);}})[_0xa8cf('0x26')](function(_0x39f5f4){if(_0x39f5f4){_0xeebc95=_0x39f5f4[_0xa8cf('0x4f')];if(!_0x4775ea['query'][_0xa8cf('0x37')](_0xa8cf('0x38'))){_0x47b4d6['limit']=qs[_0xa8cf('0x1f')](_0x4775ea[_0xa8cf('0x30')]['limit']);_0x47b4d6['offset']=qs[_0xa8cf('0x1d')](_0x4775ea['query'][_0xa8cf('0x1d')]);}return _0x6ac78b[_0xa8cf('0x4c')](_0x47b4d6);}})[_0xa8cf('0x26')](function(_0x1f2ab3){if(_0x1f2ab3){return _0x1f2ab3?{'count':_0xeebc95,'rows':_0x1f2ab3}:null;}})[_0xa8cf('0x26')](respondWithResult(_0x1dcaa0,null))[_0xa8cf('0x46')](handleError(_0x1dcaa0,null));};exports['getDescriptions']=function(_0x320b6c,_0x27d7c7,_0x22863d){var _0x3b32b9={};var _0x41d5aa={};var _0x565d3b;var _0x4376ed;return db[_0xa8cf('0x2c')][_0xa8cf('0x4d')]({'where':{'id':_0x320b6c['params']['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x27d7c7,null))[_0xa8cf('0x26')](function(_0x290989){if(_0x290989){_0x565d3b=_0x290989;_0x41d5aa[_0xa8cf('0x34')]=_[_0xa8cf('0x31')](db['FreshsalesField']['rawAttributes']);_0x41d5aa['query']=_['keys'](_0x320b6c[_0xa8cf('0x30')]);_0x41d5aa[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x41d5aa['model'],_0x41d5aa[_0xa8cf('0x30')]);_0x3b32b9[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x41d5aa['model'],qs[_0xa8cf('0x36')](_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x36')]));_0x3b32b9[_0xa8cf('0x35')]=_0x3b32b9[_0xa8cf('0x35')][_0xa8cf('0x4f')]?_0x3b32b9['attributes']:_0x41d5aa[_0xa8cf('0x34')];_0x3b32b9['order']=qs[_0xa8cf('0x3a')](_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x3a')]);_0x3b32b9[_0xa8cf('0x3d')]=qs[_0xa8cf('0x32')](_['pick'](_0x320b6c[_0xa8cf('0x30')],_0x41d5aa['filters']));if(_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x41')]){_0x3b32b9[_0xa8cf('0x3d')]=_[_0xa8cf('0x3c')](_0x3b32b9[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x3b32b9[_0xa8cf('0x35')],function(_0x3c8a32){var _0x5a06a1={};_0x5a06a1[_0x3c8a32]={'$like':'%'+_0x320b6c[_0xa8cf('0x30')]['filter']+'%'};return _0x5a06a1;})});}_0x3b32b9=_[_0xa8cf('0x3c')]({},_0x3b32b9,_0x320b6c[_0xa8cf('0x42')]);return _0x565d3b[_0xa8cf('0x50')](_0x3b32b9);}})[_0xa8cf('0x26')](function(_0x5e7452){if(_0x5e7452){_0x4376ed=_0x5e7452[_0xa8cf('0x4f')];if(!_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x37')](_0xa8cf('0x38'))){_0x3b32b9[_0xa8cf('0x1f')]=qs[_0xa8cf('0x1f')](_0x320b6c[_0xa8cf('0x30')]['limit']);_0x3b32b9[_0xa8cf('0x1d')]=qs[_0xa8cf('0x1d')](_0x320b6c[_0xa8cf('0x30')][_0xa8cf('0x1d')]);}return _0x565d3b['getDescriptions'](_0x3b32b9);}})[_0xa8cf('0x26')](function(_0xe2c32e){if(_0xe2c32e){return _0xe2c32e?{'count':_0x4376ed,'rows':_0xe2c32e}:null;}})['then'](respondWithResult(_0x27d7c7,null))['catch'](handleError(_0x27d7c7,null));};exports[_0xa8cf('0x51')]=function(_0x8601dd,_0x795fd4,_0x2f5db0){var _0x50ad8={};var _0x4c5db8={};var _0x66ae94;var _0x1ff835;return db[_0xa8cf('0x2c')]['findOne']({'where':{'id':_0x8601dd[_0xa8cf('0x48')]['id']}})[_0xa8cf('0x26')](handleEntityNotFound(_0x795fd4,null))['then'](function(_0x5421ad){if(_0x5421ad){_0x66ae94=_0x5421ad;_0x4c5db8[_0xa8cf('0x34')]=_['keys'](db[_0xa8cf('0x4e')]['rawAttributes']);_0x4c5db8['query']=_[_0xa8cf('0x31')](_0x8601dd['query']);_0x4c5db8[_0xa8cf('0x32')]=_[_0xa8cf('0x33')](_0x4c5db8['model'],_0x4c5db8[_0xa8cf('0x30')]);_0x50ad8[_0xa8cf('0x35')]=_[_0xa8cf('0x33')](_0x4c5db8['model'],qs[_0xa8cf('0x36')](_0x8601dd['query']['fields']));_0x50ad8[_0xa8cf('0x35')]=_0x50ad8[_0xa8cf('0x35')][_0xa8cf('0x4f')]?_0x50ad8['attributes']:_0x4c5db8[_0xa8cf('0x34')];_0x50ad8[_0xa8cf('0x39')]=qs[_0xa8cf('0x3a')](_0x8601dd[_0xa8cf('0x30')][_0xa8cf('0x3a')]);_0x50ad8['where']=qs[_0xa8cf('0x32')](_[_0xa8cf('0x3b')](_0x8601dd[_0xa8cf('0x30')],_0x4c5db8['filters']));if(_0x8601dd['query'][_0xa8cf('0x41')]){_0x50ad8['where']=_[_0xa8cf('0x3c')](_0x50ad8[_0xa8cf('0x3d')],{'$or':_[_0xa8cf('0x3e')](_0x50ad8[_0xa8cf('0x35')],function(_0x29264b){var _0x3a0f04={};_0x3a0f04[_0x29264b]={'$like':'%'+_0x8601dd[_0xa8cf('0x30')][_0xa8cf('0x41')]+'%'};return _0x3a0f04;})});}_0x50ad8=_[_0xa8cf('0x3c')]({},_0x50ad8,_0x8601dd[_0xa8cf('0x42')]);return _0x66ae94[_0xa8cf('0x51')](_0x50ad8);}})['then'](function(_0x502a72){if(_0x502a72){_0x1ff835=_0x502a72[_0xa8cf('0x4f')];if(!_0x8601dd['query'][_0xa8cf('0x37')]('nolimit')){_0x50ad8[_0xa8cf('0x1f')]=qs[_0xa8cf('0x1f')](_0x8601dd[_0xa8cf('0x30')][_0xa8cf('0x1f')]);_0x50ad8['offset']=qs[_0xa8cf('0x1d')](_0x8601dd[_0xa8cf('0x30')]['offset']);}return _0x66ae94[_0xa8cf('0x51')](_0x50ad8);}})['then'](function(_0x486f02){if(_0x486f02){return _0x486f02?{'count':_0x1ff835,'rows':_0x486f02}:null;}})['then'](respondWithResult(_0x795fd4,null))[_0xa8cf('0x46')](handleError(_0x795fd4,null));};
\ No newline at end of file