Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index cdc1161..0b7f2e4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf036=['request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','jayson/promise','client','http','request','then','VtigerConfiguration,\x20%s,\x20%s','request\x20sent','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','sendStatus','end','status','count','offset','limit','set','Content-Range','json','apply','reject','save','update','destroy','name','send','index','VtigerConfiguration','rawAttributes','fieldName','type','map','keys','query','filters','attributes','intersection','model','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','create','body','find','getFields','findOne','VtigerField','order','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x1837f6,_0x2daff9){var _0x487418=function(_0x1a25ec){while(--_0x1a25ec){_0x1837f6['push'](_0x1837f6['shift']());}};_0x487418(++_0x2daff9);}(_0xf036,0x174));var _0x6f03=function(_0x4065eb,_0x9f4169){_0x4065eb=_0x4065eb-0x0;var _0xe695c1=_0xf036[_0x4065eb];return _0xe695c1;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x6f03('0x0'));var rimraf=require(_0x6f03('0x1'));var zipdir=require(_0x6f03('0x2'));var jsonpatch=require(_0x6f03('0x3'));var rp=require(_0x6f03('0x4'));var moment=require('moment');var BPromise=require(_0x6f03('0x5'));var Mustache=require(_0x6f03('0x6'));var util=require(_0x6f03('0x7'));var path=require(_0x6f03('0x8'));var sox=require(_0x6f03('0x9'));var csv=require(_0x6f03('0xa'));var ejs=require(_0x6f03('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x6f03('0xc'));var crypto=require('crypto');var jsforce=require(_0x6f03('0xd'));var deskjs=require(_0x6f03('0xe'));var toCsv=require(_0x6f03('0xa'));var querystring=require(_0x6f03('0xf'));var Papa=require(_0x6f03('0x10'));var Redis=require(_0x6f03('0x11'));var authService=require(_0x6f03('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x6f03('0x13'));var hardwareService=require(_0x6f03('0x14'));var logger=require(_0x6f03('0x15'))(_0x6f03('0x16'));var utils=require(_0x6f03('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x6f03('0x18'))['db'];var jayson=require(_0x6f03('0x19'));var client=jayson[_0x6f03('0x1a')][_0x6f03('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x5732bc,_0x3954ed,_0x2d62d8,_0x5c4579){return new BPromise(function(_0xae8102,_0x238c82){var _0xcf65aa=_0x5c4579||client;return _0xcf65aa[_0x6f03('0x1c')](_0x5732bc,_0x2d62d8)[_0x6f03('0x1d')](function(_0x1fac75){logger['info'](_0x6f03('0x1e'),_0x3954ed,_0x6f03('0x1f'));logger[_0x6f03('0x20')](_0x6f03('0x21'),_0x3954ed,_0x6f03('0x1f'),JSON[_0x6f03('0x22')](_0x1fac75));if(_0x1fac75[_0x6f03('0x23')]){if(_0x1fac75[_0x6f03('0x23')][_0x6f03('0x24')]===0x1f4){logger[_0x6f03('0x23')](_0x6f03('0x1e'),_0x3954ed,_0x1fac75[_0x6f03('0x23')][_0x6f03('0x25')]);return _0x238c82(_0x1fac75[_0x6f03('0x23')][_0x6f03('0x25')]);}logger[_0x6f03('0x23')]('VtigerConfiguration,\x20%s,\x20%s',_0x3954ed,_0x1fac75[_0x6f03('0x23')]['message']);return _0xae8102(_0x1fac75[_0x6f03('0x23')]['message']);}else{logger[_0x6f03('0x26')](_0x6f03('0x1e'),_0x3954ed,_0x6f03('0x1f'));_0xae8102(_0x1fac75['result'][_0x6f03('0x25')]);}})[_0x6f03('0x27')](function(_0xa668f2){logger[_0x6f03('0x23')](_0x6f03('0x1e'),_0x3954ed,_0xa668f2);_0x238c82(_0xa668f2);});});}function respondWithStatusCode(_0x458bdc,_0xf4bb55){_0xf4bb55=_0xf4bb55||0xcc;return function(_0x1fa39b){if(_0x1fa39b){return _0x458bdc[_0x6f03('0x28')](_0xf4bb55);}return _0x458bdc['status'](_0xf4bb55)[_0x6f03('0x29')]();};}function respondWithResult(_0x3694c6,_0x12f84a){_0x12f84a=_0x12f84a||0xc8;return function(_0x1c9584){if(_0x1c9584){return _0x3694c6[_0x6f03('0x2a')](_0x12f84a)['json'](_0x1c9584);}};}function respondWithFilteredResult(_0x5a7735,_0x5f071f){return function(_0x92f319){if(_0x92f319){var _0x425dbb=_0x92f319[_0x6f03('0x2b')],_0x1af00b=_0x5f071f[_0x6f03('0x2c')],_0x4ab8b5=_0x5f071f[_0x6f03('0x2c')]+_0x5f071f[_0x6f03('0x2d')],_0x5c0857;if(_0x4ab8b5>=_0x425dbb){_0x4ab8b5=_0x425dbb;_0x5c0857=0xc8;}else{_0x5c0857=0xce;}_0x5a7735[_0x6f03('0x2a')](_0x5c0857);return _0x5a7735[_0x6f03('0x2e')](_0x6f03('0x2f'),_0x1af00b+'-'+_0x4ab8b5+'/'+_0x425dbb)[_0x6f03('0x30')](_0x92f319);}return null;};}function patchUpdates(_0x13361c){return function(_0x309259){try{jsonpatch[_0x6f03('0x31')](_0x309259,_0x13361c,!![]);}catch(_0x2192fa){return BPromise[_0x6f03('0x32')](_0x2192fa);}return _0x309259[_0x6f03('0x33')]();};}function saveUpdates(_0x21811b,_0x5f5c93){return function(_0x1dfea8){if(_0x1dfea8){return _0x1dfea8[_0x6f03('0x34')](_0x21811b)[_0x6f03('0x1d')](function(_0x55d433){return _0x55d433;});}return null;};}function removeEntity(_0x441db0,_0x4d079f){return function(_0xf82f07){if(_0xf82f07){return _0xf82f07[_0x6f03('0x35')]()[_0x6f03('0x1d')](function(){_0x441db0[_0x6f03('0x2a')](0xcc)[_0x6f03('0x29')]();});}};}function handleEntityNotFound(_0x18084e,_0x149782){return function(_0x52915a){if(!_0x52915a){_0x18084e['sendStatus'](0x194);}return _0x52915a;};}function handleError(_0x11ae27,_0x8385c9){_0x8385c9=_0x8385c9||0x1f4;return function(_0x170ef2){logger['error'](_0x170ef2['stack']);if(_0x170ef2[_0x6f03('0x36')]){delete _0x170ef2[_0x6f03('0x36')];}_0x11ae27['status'](_0x8385c9)[_0x6f03('0x37')](_0x170ef2);};}exports[_0x6f03('0x38')]=function(_0x27550a,_0x3bb769){var _0x241207={},_0x161079={},_0x15971d={'count':0x0,'rows':[]};var _0x2729d3=_['map'](db[_0x6f03('0x39')][_0x6f03('0x3a')],function(_0x50ed60){return{'name':_0x50ed60[_0x6f03('0x3b')],'type':_0x50ed60[_0x6f03('0x3c')]['key']};});_0x161079['model']=_[_0x6f03('0x3d')](_0x2729d3,_0x6f03('0x36'));_0x161079['query']=_[_0x6f03('0x3e')](_0x27550a[_0x6f03('0x3f')]);_0x161079[_0x6f03('0x40')]=_['intersection'](_0x161079['model'],_0x161079['query']);_0x241207[_0x6f03('0x41')]=_[_0x6f03('0x42')](_0x161079[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x27550a[_0x6f03('0x3f')]['fields']));_0x241207['attributes']=_0x241207[_0x6f03('0x41')][_0x6f03('0x45')]?_0x241207[_0x6f03('0x41')]:_0x161079[_0x6f03('0x43')];if(!_0x27550a[_0x6f03('0x3f')][_0x6f03('0x46')](_0x6f03('0x47'))){_0x241207[_0x6f03('0x2d')]=qs[_0x6f03('0x2d')](_0x27550a[_0x6f03('0x3f')][_0x6f03('0x2d')]);_0x241207[_0x6f03('0x2c')]=qs[_0x6f03('0x2c')](_0x27550a[_0x6f03('0x3f')]['offset']);}_0x241207['order']=qs['sort'](_0x27550a[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x241207[_0x6f03('0x49')]=qs[_0x6f03('0x40')](_[_0x6f03('0x4a')](_0x27550a[_0x6f03('0x3f')],_0x161079[_0x6f03('0x40')]),_0x2729d3);if(_0x27550a['query'][_0x6f03('0x4b')]){_0x241207[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x241207[_0x6f03('0x49')],{'$or':_[_0x6f03('0x3d')](_0x2729d3,function(_0x2e5e08){if(_0x2e5e08[_0x6f03('0x3c')]!==_0x6f03('0x4d')){var _0x2adab4={};_0x2adab4[_0x2e5e08[_0x6f03('0x36')]]={'$like':'%'+_0x27550a['query'][_0x6f03('0x4b')]+'%'};return _0x2adab4;}})});}_0x241207=_[_0x6f03('0x4c')]({},_0x241207,_0x27550a[_0x6f03('0x4e')]);var _0x5d9a0c={'where':_0x241207[_0x6f03('0x49')]};return db[_0x6f03('0x39')][_0x6f03('0x2b')](_0x5d9a0c)[_0x6f03('0x1d')](function(_0x4144d1){_0x15971d[_0x6f03('0x2b')]=_0x4144d1;if(_0x27550a[_0x6f03('0x3f')][_0x6f03('0x4f')]){_0x241207[_0x6f03('0x50')]=[{'all':!![]}];}return db['VtigerConfiguration'][_0x6f03('0x51')](_0x241207);})['then'](function(_0x2f2a23){_0x15971d[_0x6f03('0x52')]=_0x2f2a23;return _0x15971d;})[_0x6f03('0x1d')](respondWithFilteredResult(_0x3bb769,_0x241207))[_0x6f03('0x27')](handleError(_0x3bb769,null));};exports[_0x6f03('0x53')]=function(_0x103134,_0x212846){var _0x468a75={'raw':![],'where':{'id':_0x103134[_0x6f03('0x54')]['id']}},_0x104c74={};_0x104c74[_0x6f03('0x43')]=_[_0x6f03('0x3e')](db[_0x6f03('0x39')][_0x6f03('0x3a')]);_0x104c74[_0x6f03('0x3f')]=_[_0x6f03('0x3e')](_0x103134['query']);_0x104c74[_0x6f03('0x40')]=_[_0x6f03('0x42')](_0x104c74[_0x6f03('0x43')],_0x104c74[_0x6f03('0x3f')]);_0x468a75['attributes']=_[_0x6f03('0x42')](_0x104c74[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x103134[_0x6f03('0x3f')][_0x6f03('0x44')]));_0x468a75[_0x6f03('0x41')]=_0x468a75[_0x6f03('0x41')][_0x6f03('0x45')]?_0x468a75[_0x6f03('0x41')]:_0x104c74[_0x6f03('0x43')];if(_0x103134['query'][_0x6f03('0x4f')]){_0x468a75[_0x6f03('0x50')]=[{'all':!![]}];}_0x468a75=_[_0x6f03('0x4c')]({},_0x468a75,_0x103134[_0x6f03('0x4e')]);return db[_0x6f03('0x39')]['find'](_0x468a75)['then'](handleEntityNotFound(_0x212846,null))[_0x6f03('0x1d')](respondWithResult(_0x212846,null))[_0x6f03('0x27')](handleError(_0x212846,null));};exports[_0x6f03('0x55')]=function(_0xccb399,_0x133592){return db[_0x6f03('0x39')][_0x6f03('0x55')](_0xccb399[_0x6f03('0x56')],{})[_0x6f03('0x1d')](respondWithResult(_0x133592,0xc9))[_0x6f03('0x27')](handleError(_0x133592,null));};exports[_0x6f03('0x34')]=function(_0x29a346,_0x438606){if(_0x29a346[_0x6f03('0x56')]['id']){delete _0x29a346[_0x6f03('0x56')]['id'];}return db[_0x6f03('0x39')][_0x6f03('0x57')]({'where':{'id':_0x29a346[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x438606,null))[_0x6f03('0x1d')](saveUpdates(_0x29a346[_0x6f03('0x56')],null))['then'](respondWithResult(_0x438606,null))[_0x6f03('0x27')](handleError(_0x438606,null));};exports['destroy']=function(_0x28f67d,_0x9175d3){return db[_0x6f03('0x39')][_0x6f03('0x57')]({'where':{'id':_0x28f67d[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x9175d3,null))[_0x6f03('0x1d')](removeEntity(_0x9175d3,null))[_0x6f03('0x27')](handleError(_0x9175d3,null));};exports[_0x6f03('0x58')]=function(_0x2308fa,_0x214555,_0x5f5402){var _0x3028e1={};var _0x52532f={};var _0x44b8e1;var _0x1c4243;return db['VtigerConfiguration'][_0x6f03('0x59')]({'where':{'id':_0x2308fa[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x214555,null))['then'](function(_0x4362a0){if(_0x4362a0){_0x44b8e1=_0x4362a0;_0x52532f['model']=_[_0x6f03('0x3e')](db[_0x6f03('0x5a')][_0x6f03('0x3a')]);_0x52532f[_0x6f03('0x3f')]=_[_0x6f03('0x3e')](_0x2308fa[_0x6f03('0x3f')]);_0x52532f[_0x6f03('0x40')]=_['intersection'](_0x52532f['model'],_0x52532f[_0x6f03('0x3f')]);_0x3028e1[_0x6f03('0x41')]=_[_0x6f03('0x42')](_0x52532f['model'],qs[_0x6f03('0x44')](_0x2308fa[_0x6f03('0x3f')]['fields']));_0x3028e1[_0x6f03('0x41')]=_0x3028e1[_0x6f03('0x41')][_0x6f03('0x45')]?_0x3028e1[_0x6f03('0x41')]:_0x52532f[_0x6f03('0x43')];_0x3028e1[_0x6f03('0x5b')]=qs[_0x6f03('0x48')](_0x2308fa[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x3028e1[_0x6f03('0x49')]=qs['filters'](_[_0x6f03('0x4a')](_0x2308fa[_0x6f03('0x3f')],_0x52532f[_0x6f03('0x40')]));if(_0x2308fa[_0x6f03('0x3f')]['filter']){_0x3028e1[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x3028e1['where'],{'$or':_[_0x6f03('0x3d')](_0x3028e1['attributes'],function(_0x4df7d8){var _0x956210={};_0x956210[_0x4df7d8]={'$like':'%'+_0x2308fa['query'][_0x6f03('0x4b')]+'%'};return _0x956210;})});}_0x3028e1=_[_0x6f03('0x4c')]({},_0x3028e1,_0x2308fa[_0x6f03('0x4e')]);return _0x44b8e1['getFields'](_0x3028e1);}})['then'](function(_0x100dd3){if(_0x100dd3){_0x1c4243=_0x100dd3['length'];if(!_0x2308fa[_0x6f03('0x3f')][_0x6f03('0x46')]('nolimit')){_0x3028e1[_0x6f03('0x2d')]=qs[_0x6f03('0x2d')](_0x2308fa['query'][_0x6f03('0x2d')]);_0x3028e1[_0x6f03('0x2c')]=qs[_0x6f03('0x2c')](_0x2308fa[_0x6f03('0x3f')][_0x6f03('0x2c')]);}return _0x44b8e1[_0x6f03('0x58')](_0x3028e1);}})[_0x6f03('0x1d')](function(_0x2040ac){if(_0x2040ac){return _0x2040ac?{'count':_0x1c4243,'rows':_0x2040ac}:null;}})[_0x6f03('0x1d')](respondWithResult(_0x214555,null))[_0x6f03('0x27')](handleError(_0x214555,null));};exports[_0x6f03('0x5c')]=function(_0x134e3e,_0x507096,_0x156b37){var _0x2a8723={};var _0x2b78e4={};var _0x4b5ed8;var _0x3f98f9;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x134e3e[_0x6f03('0x54')]['id']}})[_0x6f03('0x1d')](handleEntityNotFound(_0x507096,null))[_0x6f03('0x1d')](function(_0x4bbbea){if(_0x4bbbea){_0x4b5ed8=_0x4bbbea;_0x2b78e4[_0x6f03('0x43')]=_[_0x6f03('0x3e')](db[_0x6f03('0x5a')]['rawAttributes']);_0x2b78e4[_0x6f03('0x3f')]=_[_0x6f03('0x3e')](_0x134e3e[_0x6f03('0x3f')]);_0x2b78e4[_0x6f03('0x40')]=_[_0x6f03('0x42')](_0x2b78e4[_0x6f03('0x43')],_0x2b78e4[_0x6f03('0x3f')]);_0x2a8723[_0x6f03('0x41')]=_['intersection'](_0x2b78e4[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x134e3e[_0x6f03('0x3f')][_0x6f03('0x44')]));_0x2a8723[_0x6f03('0x41')]=_0x2a8723['attributes']['length']?_0x2a8723['attributes']:_0x2b78e4[_0x6f03('0x43')];_0x2a8723[_0x6f03('0x5b')]=qs[_0x6f03('0x48')](_0x134e3e[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x2a8723['where']=qs[_0x6f03('0x40')](_[_0x6f03('0x4a')](_0x134e3e[_0x6f03('0x3f')],_0x2b78e4[_0x6f03('0x40')]));if(_0x134e3e[_0x6f03('0x3f')]['filter']){_0x2a8723[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x2a8723[_0x6f03('0x49')],{'$or':_['map'](_0x2a8723[_0x6f03('0x41')],function(_0x33d11a){var _0xf05ddb={};_0xf05ddb[_0x33d11a]={'$like':'%'+_0x134e3e['query']['filter']+'%'};return _0xf05ddb;})});}_0x2a8723=_['merge']({},_0x2a8723,_0x134e3e[_0x6f03('0x4e')]);return _0x4b5ed8[_0x6f03('0x5c')](_0x2a8723);}})[_0x6f03('0x1d')](function(_0x3a6bcf){if(_0x3a6bcf){_0x3f98f9=_0x3a6bcf['length'];if(!_0x134e3e['query']['hasOwnProperty'](_0x6f03('0x47'))){_0x2a8723['limit']=qs['limit'](_0x134e3e[_0x6f03('0x3f')][_0x6f03('0x2d')]);_0x2a8723['offset']=qs[_0x6f03('0x2c')](_0x134e3e[_0x6f03('0x3f')]['offset']);}return _0x4b5ed8[_0x6f03('0x5c')](_0x2a8723);}})[_0x6f03('0x1d')](function(_0x1105b6){if(_0x1105b6){return _0x1105b6?{'count':_0x3f98f9,'rows':_0x1105b6}:null;}})[_0x6f03('0x1d')](respondWithResult(_0x507096,null))[_0x6f03('0x27')](handleError(_0x507096,null));};exports[_0x6f03('0x5d')]=function(_0x163fc9,_0xf4b166,_0x1650da){var _0x13ce94={};var _0x273096={};var _0x42a944;var _0x4c09f2;return db[_0x6f03('0x39')][_0x6f03('0x59')]({'where':{'id':_0x163fc9[_0x6f03('0x54')]['id']}})['then'](handleEntityNotFound(_0xf4b166,null))['then'](function(_0x440bac){if(_0x440bac){_0x42a944=_0x440bac;_0x273096[_0x6f03('0x43')]=_[_0x6f03('0x3e')](db[_0x6f03('0x5a')][_0x6f03('0x3a')]);_0x273096[_0x6f03('0x3f')]=_['keys'](_0x163fc9[_0x6f03('0x3f')]);_0x273096[_0x6f03('0x40')]=_[_0x6f03('0x42')](_0x273096[_0x6f03('0x43')],_0x273096[_0x6f03('0x3f')]);_0x13ce94[_0x6f03('0x41')]=_[_0x6f03('0x42')](_0x273096[_0x6f03('0x43')],qs[_0x6f03('0x44')](_0x163fc9[_0x6f03('0x3f')][_0x6f03('0x44')]));_0x13ce94['attributes']=_0x13ce94['attributes'][_0x6f03('0x45')]?_0x13ce94[_0x6f03('0x41')]:_0x273096['model'];_0x13ce94[_0x6f03('0x5b')]=qs[_0x6f03('0x48')](_0x163fc9[_0x6f03('0x3f')][_0x6f03('0x48')]);_0x13ce94[_0x6f03('0x49')]=qs[_0x6f03('0x40')](_[_0x6f03('0x4a')](_0x163fc9[_0x6f03('0x3f')],_0x273096[_0x6f03('0x40')]));if(_0x163fc9[_0x6f03('0x3f')]['filter']){_0x13ce94[_0x6f03('0x49')]=_[_0x6f03('0x4c')](_0x13ce94['where'],{'$or':_[_0x6f03('0x3d')](_0x13ce94[_0x6f03('0x41')],function(_0x75914a){var _0x1e9def={};_0x1e9def[_0x75914a]={'$like':'%'+_0x163fc9[_0x6f03('0x3f')]['filter']+'%'};return _0x1e9def;})});}_0x13ce94=_[_0x6f03('0x4c')]({},_0x13ce94,_0x163fc9[_0x6f03('0x4e')]);return _0x42a944[_0x6f03('0x5d')](_0x13ce94);}})[_0x6f03('0x1d')](function(_0x46af2c){if(_0x46af2c){_0x4c09f2=_0x46af2c[_0x6f03('0x45')];if(!_0x163fc9[_0x6f03('0x3f')]['hasOwnProperty'](_0x6f03('0x47'))){_0x13ce94[_0x6f03('0x2d')]=qs['limit'](_0x163fc9['query'][_0x6f03('0x2d')]);_0x13ce94[_0x6f03('0x2c')]=qs[_0x6f03('0x2c')](_0x163fc9[_0x6f03('0x3f')][_0x6f03('0x2c')]);}return _0x42a944['getDescriptions'](_0x13ce94);}})[_0x6f03('0x1d')](function(_0x18a8e5){if(_0x18a8e5){return _0x18a8e5?{'count':_0x4c09f2,'rows':_0x18a8e5}:null;}})['then'](respondWithResult(_0xf4b166,null))[_0x6f03('0x27')](handleError(_0xf4b166,null));};
\ No newline at end of file
+var _0xfa1e=['rows','show','params','keys','include','create','body','catch','update','getFields','VtigerField','hasOwnProperty','findOne','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','then','destroy','sendStatus','error','stack','name','map','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','nolimit','order','sort','pick','filter','where','VIRTUAL','merge','options','VtigerConfiguration','includeAll','findAll'];(function(_0x187399,_0x40c56d){var _0x40fa92=function(_0x36058c){while(--_0x36058c){_0x187399['push'](_0x187399['shift']());}};_0x40fa92(++_0x40c56d);}(_0xfa1e,0x102));var _0xefa1=function(_0x53c4f8,_0x44ccaf){_0x53c4f8=_0x53c4f8-0x0;var _0x416458=_0xfa1e[_0x53c4f8];return _0x416458;};'use strict';var emlformat=require(_0xefa1('0x0'));var rimraf=require(_0xefa1('0x1'));var zipdir=require(_0xefa1('0x2'));var jsonpatch=require(_0xefa1('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xefa1('0x4'));var Mustache=require('mustache');var util=require(_0xefa1('0x5'));var path=require(_0xefa1('0x6'));var sox=require(_0xefa1('0x7'));var csv=require(_0xefa1('0x8'));var ejs=require(_0xefa1('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xefa1('0xa'));var crypto=require(_0xefa1('0xb'));var jsforce=require(_0xefa1('0xc'));var deskjs=require(_0xefa1('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xefa1('0xe'));var Redis=require(_0xefa1('0xf'));var authService=require(_0xefa1('0x10'));var qs=require(_0xefa1('0x11'));var as=require(_0xefa1('0x12'));var hardwareService=require(_0xefa1('0x13'));var logger=require(_0xefa1('0x14'))(_0xefa1('0x15'));var utils=require(_0xefa1('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xefa1('0x17'))['db'];function respondWithStatusCode(_0x2fa691,_0x25fc05){_0x25fc05=_0x25fc05||0xcc;return function(_0x3b1212){if(_0x3b1212){return _0x2fa691['sendStatus'](_0x25fc05);}return _0x2fa691[_0xefa1('0x18')](_0x25fc05)[_0xefa1('0x19')]();};}function respondWithResult(_0x906eb5,_0x68f189){_0x68f189=_0x68f189||0xc8;return function(_0x477b4a){if(_0x477b4a){return _0x906eb5[_0xefa1('0x18')](_0x68f189)['json'](_0x477b4a);}};}function respondWithFilteredResult(_0x109735,_0x15eb71){return function(_0x40867a){if(_0x40867a){var _0x53b033=typeof _0x15eb71[_0xefa1('0x1a')]===_0xefa1('0x1b')&&typeof _0x15eb71[_0xefa1('0x1c')]===_0xefa1('0x1b');var _0x299943=_0x40867a[_0xefa1('0x1d')];var _0x3d11fd=_0x53b033?0x0:_0x15eb71[_0xefa1('0x1a')];var _0x68c032=_0x53b033?_0x40867a[_0xefa1('0x1d')]:_0x15eb71[_0xefa1('0x1a')]+_0x15eb71[_0xefa1('0x1c')];var _0xa43af1;if(_0x68c032>=_0x299943){_0x68c032=_0x299943;_0xa43af1=0xc8;}else{_0xa43af1=0xce;}_0x109735[_0xefa1('0x18')](_0xa43af1);return _0x109735[_0xefa1('0x1e')](_0xefa1('0x1f'),_0x3d11fd+'-'+_0x68c032+'/'+_0x299943)[_0xefa1('0x20')](_0x40867a);}return null;};}function patchUpdates(_0x507e98){return function(_0x4b13ce){try{jsonpatch[_0xefa1('0x21')](_0x4b13ce,_0x507e98,!![]);}catch(_0x2be731){return BPromise[_0xefa1('0x22')](_0x2be731);}return _0x4b13ce[_0xefa1('0x23')]();};}function saveUpdates(_0x29ff37,_0x3bad0b){return function(_0x2182d5){if(_0x2182d5){return _0x2182d5['update'](_0x29ff37)[_0xefa1('0x24')](function(_0x584cb4){return _0x584cb4;});}return null;};}function removeEntity(_0x29d00f,_0x57b5fb){return function(_0x187c13){if(_0x187c13){return _0x187c13[_0xefa1('0x25')]()[_0xefa1('0x24')](function(){_0x29d00f[_0xefa1('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0xb95fbe,_0x4e4472){return function(_0x557c70){if(!_0x557c70){_0xb95fbe[_0xefa1('0x26')](0x194);}return _0x557c70;};}function handleError(_0x4ebaa4,_0x2a8045){_0x2a8045=_0x2a8045||0x1f4;return function(_0x1e642a){logger[_0xefa1('0x27')](_0x1e642a[_0xefa1('0x28')]);if(_0x1e642a[_0xefa1('0x29')]){delete _0x1e642a[_0xefa1('0x29')];}_0x4ebaa4[_0xefa1('0x18')](_0x2a8045)['send'](_0x1e642a);};}exports['index']=function(_0x1e400a,_0x18b2b2){var _0x512f9d={},_0x533c68={},_0x3d7052={'count':0x0,'rows':[]};var _0x484243=_[_0xefa1('0x2a')](db['VtigerConfiguration'][_0xefa1('0x2b')],function(_0x42fe98){return{'name':_0x42fe98[_0xefa1('0x2c')],'type':_0x42fe98[_0xefa1('0x2d')][_0xefa1('0x2e')]};});_0x533c68[_0xefa1('0x2f')]=_[_0xefa1('0x2a')](_0x484243,'name');_0x533c68[_0xefa1('0x30')]=_['keys'](_0x1e400a[_0xefa1('0x30')]);_0x533c68[_0xefa1('0x31')]=_[_0xefa1('0x32')](_0x533c68['model'],_0x533c68[_0xefa1('0x30')]);_0x512f9d['attributes']=_[_0xefa1('0x32')](_0x533c68[_0xefa1('0x2f')],qs[_0xefa1('0x33')](_0x1e400a[_0xefa1('0x30')][_0xefa1('0x33')]));_0x512f9d['attributes']=_0x512f9d[_0xefa1('0x34')][_0xefa1('0x35')]?_0x512f9d['attributes']:_0x533c68['model'];if(!_0x1e400a['query']['hasOwnProperty'](_0xefa1('0x36'))){_0x512f9d[_0xefa1('0x1c')]=qs[_0xefa1('0x1c')](_0x1e400a[_0xefa1('0x30')]['limit']);_0x512f9d[_0xefa1('0x1a')]=qs['offset'](_0x1e400a[_0xefa1('0x30')][_0xefa1('0x1a')]);}_0x512f9d[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x1e400a[_0xefa1('0x30')]['sort']);_0x512f9d['where']=qs['filters'](_[_0xefa1('0x39')](_0x1e400a[_0xefa1('0x30')],_0x533c68[_0xefa1('0x31')]),_0x484243);if(_0x1e400a['query'][_0xefa1('0x3a')]){_0x512f9d[_0xefa1('0x3b')]=_['merge'](_0x512f9d[_0xefa1('0x3b')],{'$or':_[_0xefa1('0x2a')](_0x484243,function(_0xcd995){if(_0xcd995[_0xefa1('0x2d')]!==_0xefa1('0x3c')){var _0x5beb72={};_0x5beb72[_0xcd995[_0xefa1('0x29')]]={'$like':'%'+_0x1e400a[_0xefa1('0x30')][_0xefa1('0x3a')]+'%'};return _0x5beb72;}})});}_0x512f9d=_[_0xefa1('0x3d')]({},_0x512f9d,_0x1e400a[_0xefa1('0x3e')]);var _0x1db0c1={'where':_0x512f9d['where']};return db[_0xefa1('0x3f')][_0xefa1('0x1d')](_0x1db0c1)[_0xefa1('0x24')](function(_0x120094){_0x3d7052[_0xefa1('0x1d')]=_0x120094;if(_0x1e400a['query'][_0xefa1('0x40')]){_0x512f9d['include']=[{'all':!![]}];}return db[_0xefa1('0x3f')][_0xefa1('0x41')](_0x512f9d);})['then'](function(_0x208b83){_0x3d7052[_0xefa1('0x42')]=_0x208b83;return _0x3d7052;})[_0xefa1('0x24')](respondWithFilteredResult(_0x18b2b2,_0x512f9d))['catch'](handleError(_0x18b2b2,null));};exports[_0xefa1('0x43')]=function(_0x4bd962,_0x1eb4dc){var _0x4d59ac={'raw':![],'where':{'id':_0x4bd962[_0xefa1('0x44')]['id']}},_0x51a68c={};_0x51a68c['model']=_[_0xefa1('0x45')](db[_0xefa1('0x3f')][_0xefa1('0x2b')]);_0x51a68c[_0xefa1('0x30')]=_[_0xefa1('0x45')](_0x4bd962[_0xefa1('0x30')]);_0x51a68c[_0xefa1('0x31')]=_['intersection'](_0x51a68c['model'],_0x51a68c[_0xefa1('0x30')]);_0x4d59ac[_0xefa1('0x34')]=_[_0xefa1('0x32')](_0x51a68c[_0xefa1('0x2f')],qs[_0xefa1('0x33')](_0x4bd962[_0xefa1('0x30')][_0xefa1('0x33')]));_0x4d59ac[_0xefa1('0x34')]=_0x4d59ac[_0xefa1('0x34')][_0xefa1('0x35')]?_0x4d59ac[_0xefa1('0x34')]:_0x51a68c[_0xefa1('0x2f')];if(_0x4bd962['query']['includeAll']){_0x4d59ac[_0xefa1('0x46')]=[{'all':!![]}];}_0x4d59ac=_[_0xefa1('0x3d')]({},_0x4d59ac,_0x4bd962[_0xefa1('0x3e')]);return db[_0xefa1('0x3f')]['find'](_0x4d59ac)[_0xefa1('0x24')](handleEntityNotFound(_0x1eb4dc,null))[_0xefa1('0x24')](respondWithResult(_0x1eb4dc,null))['catch'](handleError(_0x1eb4dc,null));};exports[_0xefa1('0x47')]=function(_0x5bb5b5,_0x48fc36){return db[_0xefa1('0x3f')][_0xefa1('0x47')](_0x5bb5b5[_0xefa1('0x48')],{})[_0xefa1('0x24')](respondWithResult(_0x48fc36,0xc9))[_0xefa1('0x49')](handleError(_0x48fc36,null));};exports[_0xefa1('0x4a')]=function(_0x33aa4f,_0x13d34d){if(_0x33aa4f[_0xefa1('0x48')]['id']){delete _0x33aa4f['body']['id'];}return db[_0xefa1('0x3f')]['find']({'where':{'id':_0x33aa4f['params']['id']}})[_0xefa1('0x24')](handleEntityNotFound(_0x13d34d,null))[_0xefa1('0x24')](saveUpdates(_0x33aa4f[_0xefa1('0x48')],null))['then'](respondWithResult(_0x13d34d,null))[_0xefa1('0x49')](handleError(_0x13d34d,null));};exports['destroy']=function(_0x45c784,_0x2be606){return db[_0xefa1('0x3f')]['find']({'where':{'id':_0x45c784[_0xefa1('0x44')]['id']}})['then'](handleEntityNotFound(_0x2be606,null))[_0xefa1('0x24')](removeEntity(_0x2be606,null))['catch'](handleError(_0x2be606,null));};exports[_0xefa1('0x4b')]=function(_0x3d0324,_0xad4fc2,_0x187223){var _0x288965={};var _0x29fed4={};var _0x1c6584;var _0x19c9ec;return db[_0xefa1('0x3f')]['findOne']({'where':{'id':_0x3d0324[_0xefa1('0x44')]['id']}})[_0xefa1('0x24')](handleEntityNotFound(_0xad4fc2,null))[_0xefa1('0x24')](function(_0x5d7e6c){if(_0x5d7e6c){_0x1c6584=_0x5d7e6c;_0x29fed4[_0xefa1('0x2f')]=_[_0xefa1('0x45')](db[_0xefa1('0x4c')][_0xefa1('0x2b')]);_0x29fed4[_0xefa1('0x30')]=_['keys'](_0x3d0324['query']);_0x29fed4[_0xefa1('0x31')]=_[_0xefa1('0x32')](_0x29fed4[_0xefa1('0x2f')],_0x29fed4[_0xefa1('0x30')]);_0x288965[_0xefa1('0x34')]=_[_0xefa1('0x32')](_0x29fed4['model'],qs['fields'](_0x3d0324[_0xefa1('0x30')]['fields']));_0x288965[_0xefa1('0x34')]=_0x288965[_0xefa1('0x34')][_0xefa1('0x35')]?_0x288965['attributes']:_0x29fed4[_0xefa1('0x2f')];_0x288965[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x3d0324[_0xefa1('0x30')][_0xefa1('0x38')]);_0x288965['where']=qs['filters'](_[_0xefa1('0x39')](_0x3d0324[_0xefa1('0x30')],_0x29fed4[_0xefa1('0x31')]));if(_0x3d0324['query']['filter']){_0x288965['where']=_[_0xefa1('0x3d')](_0x288965[_0xefa1('0x3b')],{'$or':_[_0xefa1('0x2a')](_0x288965[_0xefa1('0x34')],function(_0x572d7d){var _0x502127={};_0x502127[_0x572d7d]={'$like':'%'+_0x3d0324[_0xefa1('0x30')]['filter']+'%'};return _0x502127;})});}_0x288965=_['merge']({},_0x288965,_0x3d0324[_0xefa1('0x3e')]);return _0x1c6584['getFields'](_0x288965);}})['then'](function(_0x3e3277){if(_0x3e3277){_0x19c9ec=_0x3e3277[_0xefa1('0x35')];if(!_0x3d0324[_0xefa1('0x30')][_0xefa1('0x4d')]('nolimit')){_0x288965['limit']=qs[_0xefa1('0x1c')](_0x3d0324[_0xefa1('0x30')][_0xefa1('0x1c')]);_0x288965[_0xefa1('0x1a')]=qs['offset'](_0x3d0324[_0xefa1('0x30')]['offset']);}return _0x1c6584[_0xefa1('0x4b')](_0x288965);}})['then'](function(_0x5bf047){if(_0x5bf047){return _0x5bf047?{'count':_0x19c9ec,'rows':_0x5bf047}:null;}})['then'](respondWithResult(_0xad4fc2,null))[_0xefa1('0x49')](handleError(_0xad4fc2,null));};exports['getSubjects']=function(_0x248a3d,_0x1a78bd,_0x25e5e0){var _0x4617b2={};var _0x170d32={};var _0x10d753;var _0x1fc608;return db['VtigerConfiguration'][_0xefa1('0x4e')]({'where':{'id':_0x248a3d[_0xefa1('0x44')]['id']}})[_0xefa1('0x24')](handleEntityNotFound(_0x1a78bd,null))[_0xefa1('0x24')](function(_0x4677ef){if(_0x4677ef){_0x10d753=_0x4677ef;_0x170d32['model']=_[_0xefa1('0x45')](db[_0xefa1('0x4c')][_0xefa1('0x2b')]);_0x170d32['query']=_[_0xefa1('0x45')](_0x248a3d['query']);_0x170d32[_0xefa1('0x31')]=_['intersection'](_0x170d32[_0xefa1('0x2f')],_0x170d32[_0xefa1('0x30')]);_0x4617b2[_0xefa1('0x34')]=_['intersection'](_0x170d32[_0xefa1('0x2f')],qs[_0xefa1('0x33')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x33')]));_0x4617b2[_0xefa1('0x34')]=_0x4617b2['attributes'][_0xefa1('0x35')]?_0x4617b2['attributes']:_0x170d32[_0xefa1('0x2f')];_0x4617b2[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x38')]);_0x4617b2['where']=qs[_0xefa1('0x31')](_['pick'](_0x248a3d[_0xefa1('0x30')],_0x170d32[_0xefa1('0x31')]));if(_0x248a3d['query'][_0xefa1('0x3a')]){_0x4617b2['where']=_[_0xefa1('0x3d')](_0x4617b2[_0xefa1('0x3b')],{'$or':_[_0xefa1('0x2a')](_0x4617b2[_0xefa1('0x34')],function(_0x162979){var _0xeb8194={};_0xeb8194[_0x162979]={'$like':'%'+_0x248a3d[_0xefa1('0x30')]['filter']+'%'};return _0xeb8194;})});}_0x4617b2=_[_0xefa1('0x3d')]({},_0x4617b2,_0x248a3d[_0xefa1('0x3e')]);return _0x10d753[_0xefa1('0x4f')](_0x4617b2);}})['then'](function(_0x5de3e3){if(_0x5de3e3){_0x1fc608=_0x5de3e3[_0xefa1('0x35')];if(!_0x248a3d[_0xefa1('0x30')][_0xefa1('0x4d')](_0xefa1('0x36'))){_0x4617b2['limit']=qs[_0xefa1('0x1c')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x1c')]);_0x4617b2[_0xefa1('0x1a')]=qs[_0xefa1('0x1a')](_0x248a3d[_0xefa1('0x30')][_0xefa1('0x1a')]);}return _0x10d753[_0xefa1('0x4f')](_0x4617b2);}})[_0xefa1('0x24')](function(_0x193be8){if(_0x193be8){return _0x193be8?{'count':_0x1fc608,'rows':_0x193be8}:null;}})['then'](respondWithResult(_0x1a78bd,null))['catch'](handleError(_0x1a78bd,null));};exports[_0xefa1('0x50')]=function(_0x7fddfd,_0x31141b,_0x3abd59){var _0x498dc4={};var _0x5732d0={};var _0x39da19;var _0xdb3e94;return db[_0xefa1('0x3f')][_0xefa1('0x4e')]({'where':{'id':_0x7fddfd[_0xefa1('0x44')]['id']}})['then'](handleEntityNotFound(_0x31141b,null))[_0xefa1('0x24')](function(_0xe45e9b){if(_0xe45e9b){_0x39da19=_0xe45e9b;_0x5732d0[_0xefa1('0x2f')]=_[_0xefa1('0x45')](db[_0xefa1('0x4c')][_0xefa1('0x2b')]);_0x5732d0[_0xefa1('0x30')]=_[_0xefa1('0x45')](_0x7fddfd[_0xefa1('0x30')]);_0x5732d0[_0xefa1('0x31')]=_[_0xefa1('0x32')](_0x5732d0['model'],_0x5732d0[_0xefa1('0x30')]);_0x498dc4[_0xefa1('0x34')]=_[_0xefa1('0x32')](_0x5732d0['model'],qs['fields'](_0x7fddfd[_0xefa1('0x30')][_0xefa1('0x33')]));_0x498dc4[_0xefa1('0x34')]=_0x498dc4['attributes'][_0xefa1('0x35')]?_0x498dc4[_0xefa1('0x34')]:_0x5732d0[_0xefa1('0x2f')];_0x498dc4[_0xefa1('0x37')]=qs[_0xefa1('0x38')](_0x7fddfd['query']['sort']);_0x498dc4[_0xefa1('0x3b')]=qs[_0xefa1('0x31')](_[_0xefa1('0x39')](_0x7fddfd[_0xefa1('0x30')],_0x5732d0[_0xefa1('0x31')]));if(_0x7fddfd[_0xefa1('0x30')][_0xefa1('0x3a')]){_0x498dc4[_0xefa1('0x3b')]=_['merge'](_0x498dc4[_0xefa1('0x3b')],{'$or':_['map'](_0x498dc4[_0xefa1('0x34')],function(_0x2a2a00){var _0x53fd0b={};_0x53fd0b[_0x2a2a00]={'$like':'%'+_0x7fddfd[_0xefa1('0x30')]['filter']+'%'};return _0x53fd0b;})});}_0x498dc4=_[_0xefa1('0x3d')]({},_0x498dc4,_0x7fddfd[_0xefa1('0x3e')]);return _0x39da19[_0xefa1('0x50')](_0x498dc4);}})['then'](function(_0x45808){if(_0x45808){_0xdb3e94=_0x45808['length'];if(!_0x7fddfd['query']['hasOwnProperty'](_0xefa1('0x36'))){_0x498dc4[_0xefa1('0x1c')]=qs['limit'](_0x7fddfd[_0xefa1('0x30')][_0xefa1('0x1c')]);_0x498dc4[_0xefa1('0x1a')]=qs['offset'](_0x7fddfd['query'][_0xefa1('0x1a')]);}return _0x39da19[_0xefa1('0x50')](_0x498dc4);}})[_0xefa1('0x24')](function(_0x14add8){if(_0x14add8){return _0x14add8?{'count':_0xdb3e94,'rows':_0x14add8}:null;}})[_0xefa1('0x24')](respondWithResult(_0x31141b,null))['catch'](handleError(_0x31141b,null));};
\ No newline at end of file