Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intDynamics365Field / intDynamics365Field.controller.js
index b91d615..c907ebb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x67b6=['attributes','fields','length','hasOwnProperty','sort','where','filters','pick','filter','merge','options','includeAll','rows','catch','show','params','keys','rawAttributes','find','create','body','update','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','ejs','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','save','then','destroy','end','error','stack','name','send','index','Dynamics365Field','type','key','map','query','intersection','model'];(function(_0x28d18d,_0x55896b){var _0x470640=function(_0x57e78b){while(--_0x57e78b){_0x28d18d['push'](_0x28d18d['shift']());}};_0x470640(++_0x55896b);}(_0x67b6,0x12a));var _0x667b=function(_0x302f7b,_0x5e0795){_0x302f7b=_0x302f7b-0x0;var _0x2fb8eb=_0x67b6[_0x302f7b];return _0x2fb8eb;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x667b('0x0'));var zipdir=require(_0x667b('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x667b('0x2'));var BPromise=require(_0x667b('0x3'));var Mustache=require(_0x667b('0x4'));var util=require(_0x667b('0x5'));var path=require(_0x667b('0x6'));var sox=require(_0x667b('0x7'));var csv=require('to-csv');var ejs=require(_0x667b('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0x667b('0x9'));var crypto=require(_0x667b('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x667b('0xb'));var toCsv=require('to-csv');var querystring=require(_0x667b('0xc'));var Papa=require(_0x667b('0xd'));var Redis=require(_0x667b('0xe'));var authService=require(_0x667b('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x667b('0x10'));var logger=require(_0x667b('0x11'))(_0x667b('0x12'));var utils=require(_0x667b('0x13'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x667b('0x14'))['db'];function respondWithStatusCode(_0x431e02,_0x47afe1){_0x47afe1=_0x47afe1||0xcc;return function(_0x56ebb2){if(_0x56ebb2){return _0x431e02[_0x667b('0x15')](_0x47afe1);}return _0x431e02[_0x667b('0x16')](_0x47afe1)['end']();};}function respondWithResult(_0x1ad9c4,_0x443215){_0x443215=_0x443215||0xc8;return function(_0x237a79){if(_0x237a79){return _0x1ad9c4[_0x667b('0x16')](_0x443215)[_0x667b('0x17')](_0x237a79);}};}function respondWithFilteredResult(_0x11f76d,_0x258b12){return function(_0x7408bf){if(_0x7408bf){var _0x35f35d=_0x7408bf[_0x667b('0x18')],_0xcc44a3=_0x258b12[_0x667b('0x19')],_0x27bfa8=_0x258b12[_0x667b('0x19')]+_0x258b12[_0x667b('0x1a')],_0x5406b9;if(_0x27bfa8>=_0x35f35d){_0x27bfa8=_0x35f35d;_0x5406b9=0xc8;}else{_0x5406b9=0xce;}_0x11f76d[_0x667b('0x16')](_0x5406b9);return _0x11f76d[_0x667b('0x1b')](_0x667b('0x1c'),_0xcc44a3+'-'+_0x27bfa8+'/'+_0x35f35d)[_0x667b('0x17')](_0x7408bf);}return null;};}function patchUpdates(_0x30889d){return function(_0x329f9a){try{jsonpatch[_0x667b('0x1d')](_0x329f9a,_0x30889d,!![]);}catch(_0x4867e5){return BPromise[_0x667b('0x1e')](_0x4867e5);}return _0x329f9a[_0x667b('0x1f')]();};}function saveUpdates(_0x1035cf,_0x20a95c){return function(_0x106736){if(_0x106736){return _0x106736['update'](_0x1035cf)[_0x667b('0x20')](function(_0x122b8b){return _0x122b8b;});}return null;};}function removeEntity(_0x75a02f,_0x27b51f){return function(_0xda97da){if(_0xda97da){return _0xda97da[_0x667b('0x21')]()[_0x667b('0x20')](function(){_0x75a02f[_0x667b('0x16')](0xcc)[_0x667b('0x22')]();});}};}function handleEntityNotFound(_0x3cddcf,_0x1f1393){return function(_0x3e26d6){if(!_0x3e26d6){_0x3cddcf[_0x667b('0x15')](0x194);}return _0x3e26d6;};}function handleError(_0x36adda,_0x37bae0){_0x37bae0=_0x37bae0||0x1f4;return function(_0x48861e){logger[_0x667b('0x23')](_0x48861e[_0x667b('0x24')]);if(_0x48861e[_0x667b('0x25')]){delete _0x48861e[_0x667b('0x25')];}_0x36adda['status'](_0x37bae0)[_0x667b('0x26')](_0x48861e);};}exports[_0x667b('0x27')]=function(_0x25a6c9,_0x371708){var _0x28f4fb={},_0x511f06={},_0x3d72ea={'count':0x0,'rows':[]};var _0x690ecf=_['map'](db[_0x667b('0x28')]['rawAttributes'],function(_0x47f873){return{'name':_0x47f873['fieldName'],'type':_0x47f873[_0x667b('0x29')][_0x667b('0x2a')]};});_0x511f06['model']=_[_0x667b('0x2b')](_0x690ecf,_0x667b('0x25'));_0x511f06[_0x667b('0x2c')]=_['keys'](_0x25a6c9['query']);_0x511f06['filters']=_[_0x667b('0x2d')](_0x511f06[_0x667b('0x2e')],_0x511f06[_0x667b('0x2c')]);_0x28f4fb[_0x667b('0x2f')]=_['intersection'](_0x511f06['model'],qs[_0x667b('0x30')](_0x25a6c9[_0x667b('0x2c')][_0x667b('0x30')]));_0x28f4fb[_0x667b('0x2f')]=_0x28f4fb[_0x667b('0x2f')][_0x667b('0x31')]?_0x28f4fb[_0x667b('0x2f')]:_0x511f06[_0x667b('0x2e')];if(!_0x25a6c9['query'][_0x667b('0x32')]('nolimit')){_0x28f4fb[_0x667b('0x1a')]=qs['limit'](_0x25a6c9[_0x667b('0x2c')][_0x667b('0x1a')]);_0x28f4fb['offset']=qs[_0x667b('0x19')](_0x25a6c9[_0x667b('0x2c')]['offset']);}_0x28f4fb['order']=qs[_0x667b('0x33')](_0x25a6c9[_0x667b('0x2c')]['sort']);_0x28f4fb[_0x667b('0x34')]=qs[_0x667b('0x35')](_[_0x667b('0x36')](_0x25a6c9['query'],_0x511f06[_0x667b('0x35')]),_0x690ecf);if(_0x25a6c9[_0x667b('0x2c')][_0x667b('0x37')]){_0x28f4fb['where']=_[_0x667b('0x38')](_0x28f4fb['where'],{'$or':_['map'](_0x690ecf,function(_0x1bee31){if(_0x1bee31[_0x667b('0x29')]!=='VIRTUAL'){var _0x564f28={};_0x564f28[_0x1bee31[_0x667b('0x25')]]={'$like':'%'+_0x25a6c9[_0x667b('0x2c')]['filter']+'%'};return _0x564f28;}})});}_0x28f4fb=_['merge']({},_0x28f4fb,_0x25a6c9[_0x667b('0x39')]);var _0x49711e={'where':_0x28f4fb['where']};return db[_0x667b('0x28')][_0x667b('0x18')](_0x49711e)[_0x667b('0x20')](function(_0x30f8de){_0x3d72ea[_0x667b('0x18')]=_0x30f8de;if(_0x25a6c9['query'][_0x667b('0x3a')]){_0x28f4fb['include']=[{'all':!![]}];}return db[_0x667b('0x28')]['findAll'](_0x28f4fb);})[_0x667b('0x20')](function(_0x405a5f){_0x3d72ea[_0x667b('0x3b')]=_0x405a5f;return _0x3d72ea;})[_0x667b('0x20')](respondWithFilteredResult(_0x371708,_0x28f4fb))[_0x667b('0x3c')](handleError(_0x371708,null));};exports[_0x667b('0x3d')]=function(_0x2f70e5,_0x447a7f){var _0x43614c={'raw':!![],'where':{'id':_0x2f70e5[_0x667b('0x3e')]['id']}},_0x1edf2b={};_0x1edf2b['model']=_[_0x667b('0x3f')](db[_0x667b('0x28')][_0x667b('0x40')]);_0x1edf2b[_0x667b('0x2c')]=_['keys'](_0x2f70e5[_0x667b('0x2c')]);_0x1edf2b[_0x667b('0x35')]=_[_0x667b('0x2d')](_0x1edf2b[_0x667b('0x2e')],_0x1edf2b['query']);_0x43614c[_0x667b('0x2f')]=_[_0x667b('0x2d')](_0x1edf2b[_0x667b('0x2e')],qs[_0x667b('0x30')](_0x2f70e5[_0x667b('0x2c')][_0x667b('0x30')]));_0x43614c[_0x667b('0x2f')]=_0x43614c[_0x667b('0x2f')][_0x667b('0x31')]?_0x43614c['attributes']:_0x1edf2b[_0x667b('0x2e')];if(_0x2f70e5[_0x667b('0x2c')][_0x667b('0x3a')]){_0x43614c['include']=[{'all':!![]}];}_0x43614c=_[_0x667b('0x38')]({},_0x43614c,_0x2f70e5[_0x667b('0x39')]);return db[_0x667b('0x28')][_0x667b('0x41')](_0x43614c)['then'](handleEntityNotFound(_0x447a7f,null))[_0x667b('0x20')](respondWithResult(_0x447a7f,null))[_0x667b('0x3c')](handleError(_0x447a7f,null));};exports['create']=function(_0x24a1eb,_0x3b7733){return db[_0x667b('0x28')][_0x667b('0x42')](_0x24a1eb[_0x667b('0x43')],{})[_0x667b('0x20')](respondWithResult(_0x3b7733,0xc9))['catch'](handleError(_0x3b7733,null));};exports[_0x667b('0x44')]=function(_0x2a073a,_0x347df2){if(_0x2a073a[_0x667b('0x43')]['id']){delete _0x2a073a['body']['id'];}return db[_0x667b('0x28')][_0x667b('0x41')]({'where':{'id':_0x2a073a[_0x667b('0x3e')]['id']}})[_0x667b('0x20')](handleEntityNotFound(_0x347df2,null))[_0x667b('0x20')](saveUpdates(_0x2a073a[_0x667b('0x43')],null))[_0x667b('0x20')](respondWithResult(_0x347df2,null))[_0x667b('0x3c')](handleError(_0x347df2,null));};exports[_0x667b('0x21')]=function(_0x1a07c5,_0x66715){return db[_0x667b('0x28')]['find']({'where':{'id':_0x1a07c5[_0x667b('0x3e')]['id']}})['then'](handleEntityNotFound(_0x66715,null))[_0x667b('0x20')](removeEntity(_0x66715,null))['catch'](handleError(_0x66715,null));};
\ No newline at end of file
+var _0xf6ad=['show','rawAttributes','options','find','body','params','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','save','update','then','destroy','error','name','send','index','map','Dynamics365Field','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','rows','catch'];(function(_0x597eb5,_0x4cb6f4){var _0x1305ab=function(_0x24c0cb){while(--_0x24c0cb){_0x597eb5['push'](_0x597eb5['shift']());}};_0x1305ab(++_0x4cb6f4);}(_0xf6ad,0xde));var _0xdf6a=function(_0x3f6f75,_0x26d69e){_0x3f6f75=_0x3f6f75-0x0;var _0x49931f=_0xf6ad[_0x3f6f75];return _0x49931f;};'use strict';var emlformat=require(_0xdf6a('0x0'));var rimraf=require(_0xdf6a('0x1'));var zipdir=require(_0xdf6a('0x2'));var jsonpatch=require(_0xdf6a('0x3'));var rp=require(_0xdf6a('0x4'));var moment=require('moment');var BPromise=require(_0xdf6a('0x5'));var Mustache=require(_0xdf6a('0x6'));var util=require(_0xdf6a('0x7'));var path=require(_0xdf6a('0x8'));var sox=require(_0xdf6a('0x9'));var csv=require(_0xdf6a('0xa'));var ejs=require(_0xdf6a('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xdf6a('0xc'));var squel=require(_0xdf6a('0xd'));var crypto=require('crypto');var jsforce=require(_0xdf6a('0xe'));var deskjs=require(_0xdf6a('0xf'));var toCsv=require(_0xdf6a('0xa'));var querystring=require(_0xdf6a('0x10'));var Papa=require(_0xdf6a('0x11'));var Redis=require(_0xdf6a('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xdf6a('0x13'));var hardwareService=require(_0xdf6a('0x14'));var logger=require('../../config/logger')(_0xdf6a('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xdf6a('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x121150,_0x19d394){_0x19d394=_0x19d394||0xcc;return function(_0x5444d5){if(_0x5444d5){return _0x121150[_0xdf6a('0x17')](_0x19d394);}return _0x121150[_0xdf6a('0x18')](_0x19d394)[_0xdf6a('0x19')]();};}function respondWithResult(_0x3fce3d,_0x1345c3){_0x1345c3=_0x1345c3||0xc8;return function(_0x55a936){if(_0x55a936){return _0x3fce3d[_0xdf6a('0x18')](_0x1345c3)[_0xdf6a('0x1a')](_0x55a936);}};}function respondWithFilteredResult(_0x376da4,_0x19572a){return function(_0x36c0b7){if(_0x36c0b7){var _0x4901a1=typeof _0x19572a[_0xdf6a('0x1b')]==='undefined'&&typeof _0x19572a['limit']===_0xdf6a('0x1c');var _0x51ad34=_0x36c0b7[_0xdf6a('0x1d')];var _0x203bc8=_0x4901a1?0x0:_0x19572a['offset'];var _0x1bebcb=_0x4901a1?_0x36c0b7[_0xdf6a('0x1d')]:_0x19572a[_0xdf6a('0x1b')]+_0x19572a[_0xdf6a('0x1e')];var _0x26d6cc;if(_0x1bebcb>=_0x51ad34){_0x1bebcb=_0x51ad34;_0x26d6cc=0xc8;}else{_0x26d6cc=0xce;}_0x376da4[_0xdf6a('0x18')](_0x26d6cc);return _0x376da4[_0xdf6a('0x1f')](_0xdf6a('0x20'),_0x203bc8+'-'+_0x1bebcb+'/'+_0x51ad34)[_0xdf6a('0x1a')](_0x36c0b7);}return null;};}function patchUpdates(_0x3f0b57){return function(_0x122860){try{jsonpatch[_0xdf6a('0x21')](_0x122860,_0x3f0b57,!![]);}catch(_0xde159a){return BPromise['reject'](_0xde159a);}return _0x122860[_0xdf6a('0x22')]();};}function saveUpdates(_0xa78c13,_0x113193){return function(_0x33631e){if(_0x33631e){return _0x33631e[_0xdf6a('0x23')](_0xa78c13)[_0xdf6a('0x24')](function(_0xcf349c){return _0xcf349c;});}return null;};}function removeEntity(_0x406508,_0x35fed7){return function(_0x3951d8){if(_0x3951d8){return _0x3951d8[_0xdf6a('0x25')]()[_0xdf6a('0x24')](function(){_0x406508[_0xdf6a('0x18')](0xcc)[_0xdf6a('0x19')]();});}};}function handleEntityNotFound(_0x5bb4db,_0x2bc40d){return function(_0x489957){if(!_0x489957){_0x5bb4db['sendStatus'](0x194);}return _0x489957;};}function handleError(_0x53a3c2,_0x515a96){_0x515a96=_0x515a96||0x1f4;return function(_0x1a5021){logger[_0xdf6a('0x26')](_0x1a5021['stack']);if(_0x1a5021[_0xdf6a('0x27')]){delete _0x1a5021[_0xdf6a('0x27')];}_0x53a3c2[_0xdf6a('0x18')](_0x515a96)[_0xdf6a('0x28')](_0x1a5021);};}exports[_0xdf6a('0x29')]=function(_0x32cdcb,_0x2dc80c){var _0x317f90={},_0x458793={},_0x1aedf8={'count':0x0,'rows':[]};var _0x4bfc22=_[_0xdf6a('0x2a')](db[_0xdf6a('0x2b')]['rawAttributes'],function(_0x145f9b){return{'name':_0x145f9b[_0xdf6a('0x2c')],'type':_0x145f9b[_0xdf6a('0x2d')]['key']};});_0x458793[_0xdf6a('0x2e')]=_[_0xdf6a('0x2a')](_0x4bfc22,_0xdf6a('0x27'));_0x458793[_0xdf6a('0x2f')]=_[_0xdf6a('0x30')](_0x32cdcb[_0xdf6a('0x2f')]);_0x458793[_0xdf6a('0x31')]=_[_0xdf6a('0x32')](_0x458793[_0xdf6a('0x2e')],_0x458793[_0xdf6a('0x2f')]);_0x317f90['attributes']=_[_0xdf6a('0x32')](_0x458793['model'],qs[_0xdf6a('0x33')](_0x32cdcb[_0xdf6a('0x2f')]['fields']));_0x317f90['attributes']=_0x317f90[_0xdf6a('0x34')][_0xdf6a('0x35')]?_0x317f90[_0xdf6a('0x34')]:_0x458793['model'];if(!_0x32cdcb['query']['hasOwnProperty'](_0xdf6a('0x36'))){_0x317f90[_0xdf6a('0x1e')]=qs['limit'](_0x32cdcb[_0xdf6a('0x2f')][_0xdf6a('0x1e')]);_0x317f90['offset']=qs['offset'](_0x32cdcb[_0xdf6a('0x2f')][_0xdf6a('0x1b')]);}_0x317f90[_0xdf6a('0x37')]=qs[_0xdf6a('0x38')](_0x32cdcb['query']['sort']);_0x317f90[_0xdf6a('0x39')]=qs[_0xdf6a('0x31')](_[_0xdf6a('0x3a')](_0x32cdcb[_0xdf6a('0x2f')],_0x458793[_0xdf6a('0x31')]),_0x4bfc22);if(_0x32cdcb[_0xdf6a('0x2f')][_0xdf6a('0x3b')]){_0x317f90['where']=_[_0xdf6a('0x3c')](_0x317f90['where'],{'$or':_[_0xdf6a('0x2a')](_0x4bfc22,function(_0x791f9e){if(_0x791f9e[_0xdf6a('0x2d')]!==_0xdf6a('0x3d')){var _0x101ff0={};_0x101ff0[_0x791f9e[_0xdf6a('0x27')]]={'$like':'%'+_0x32cdcb[_0xdf6a('0x2f')]['filter']+'%'};return _0x101ff0;}})});}_0x317f90=_[_0xdf6a('0x3c')]({},_0x317f90,_0x32cdcb['options']);var _0xc050ff={'where':_0x317f90['where']};return db[_0xdf6a('0x2b')][_0xdf6a('0x1d')](_0xc050ff)['then'](function(_0x17d6ba){_0x1aedf8[_0xdf6a('0x1d')]=_0x17d6ba;if(_0x32cdcb[_0xdf6a('0x2f')][_0xdf6a('0x3e')]){_0x317f90[_0xdf6a('0x3f')]=[{'all':!![]}];}return db[_0xdf6a('0x2b')]['findAll'](_0x317f90);})[_0xdf6a('0x24')](function(_0x52a173){_0x1aedf8[_0xdf6a('0x40')]=_0x52a173;return _0x1aedf8;})[_0xdf6a('0x24')](respondWithFilteredResult(_0x2dc80c,_0x317f90))[_0xdf6a('0x41')](handleError(_0x2dc80c,null));};exports[_0xdf6a('0x42')]=function(_0x33b5bc,_0x1e802e){var _0x23d378={'raw':!![],'where':{'id':_0x33b5bc['params']['id']}},_0x48964e={};_0x48964e[_0xdf6a('0x2e')]=_[_0xdf6a('0x30')](db['Dynamics365Field'][_0xdf6a('0x43')]);_0x48964e[_0xdf6a('0x2f')]=_[_0xdf6a('0x30')](_0x33b5bc[_0xdf6a('0x2f')]);_0x48964e['filters']=_[_0xdf6a('0x32')](_0x48964e[_0xdf6a('0x2e')],_0x48964e[_0xdf6a('0x2f')]);_0x23d378[_0xdf6a('0x34')]=_[_0xdf6a('0x32')](_0x48964e[_0xdf6a('0x2e')],qs[_0xdf6a('0x33')](_0x33b5bc[_0xdf6a('0x2f')][_0xdf6a('0x33')]));_0x23d378['attributes']=_0x23d378[_0xdf6a('0x34')][_0xdf6a('0x35')]?_0x23d378[_0xdf6a('0x34')]:_0x48964e[_0xdf6a('0x2e')];if(_0x33b5bc[_0xdf6a('0x2f')][_0xdf6a('0x3e')]){_0x23d378[_0xdf6a('0x3f')]=[{'all':!![]}];}_0x23d378=_[_0xdf6a('0x3c')]({},_0x23d378,_0x33b5bc[_0xdf6a('0x44')]);return db[_0xdf6a('0x2b')][_0xdf6a('0x45')](_0x23d378)[_0xdf6a('0x24')](handleEntityNotFound(_0x1e802e,null))[_0xdf6a('0x24')](respondWithResult(_0x1e802e,null))[_0xdf6a('0x41')](handleError(_0x1e802e,null));};exports['create']=function(_0x436d67,_0x3237d4){return db[_0xdf6a('0x2b')]['create'](_0x436d67[_0xdf6a('0x46')],{})[_0xdf6a('0x24')](respondWithResult(_0x3237d4,0xc9))[_0xdf6a('0x41')](handleError(_0x3237d4,null));};exports[_0xdf6a('0x23')]=function(_0x1578db,_0x564355){if(_0x1578db['body']['id']){delete _0x1578db[_0xdf6a('0x46')]['id'];}return db[_0xdf6a('0x2b')][_0xdf6a('0x45')]({'where':{'id':_0x1578db[_0xdf6a('0x47')]['id']}})[_0xdf6a('0x24')](handleEntityNotFound(_0x564355,null))[_0xdf6a('0x24')](saveUpdates(_0x1578db['body'],null))['then'](respondWithResult(_0x564355,null))[_0xdf6a('0x41')](handleError(_0x564355,null));};exports[_0xdf6a('0x25')]=function(_0x2db759,_0x4d63d3){return db[_0xdf6a('0x2b')][_0xdf6a('0x45')]({'where':{'id':_0x2db759[_0xdf6a('0x47')]['id']}})[_0xdf6a('0x24')](handleEntityNotFound(_0x4d63d3,null))['then'](removeEntity(_0x4d63d3,null))[_0xdf6a('0x41')](handleError(_0x4d63d3,null));};
\ No newline at end of file