@resolveio/server-lib 11.0.4 → 11.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,43 @@
1
1
  import { MethodModel } from '../models/method.model';
2
- import * as aws from 'aws-sdk';
3
2
  import ResolveIOMainServer from '../server-app';
3
+ import { CloudFormation } from '@aws-sdk/client-cloudformation';
4
+ import { CloudFront } from '@aws-sdk/client-cloudfront';
5
+ import { CodeBuild } from '@aws-sdk/client-codebuild';
6
+ import { EBS } from '@aws-sdk/client-ebs';
7
+ import { EC2 } from '@aws-sdk/client-ec2';
8
+ import { EC2InstanceConnect } from '@aws-sdk/client-ec2-instance-connect';
9
+ import { ElasticBeanstalk } from '@aws-sdk/client-elastic-beanstalk';
10
+ import { Route53 } from '@aws-sdk/client-route-53';
11
+ import { S3 } from '@aws-sdk/client-s3';
12
+ import { SES } from '@aws-sdk/client-ses';
13
+ export declare class AWS {
14
+ private _serverConfig;
15
+ private _cloudfront;
16
+ private _cloudformation;
17
+ private _codebuild;
18
+ private _ebs;
19
+ private _ec2;
20
+ private _ec2connect;
21
+ private _elasticbeanstalk;
22
+ private _route53;
23
+ private _s3;
24
+ private _ses;
25
+ constructor(serverConfig: any);
26
+ cloudfront(): CloudFront;
27
+ cloudformation(): CloudFormation;
28
+ codebuild(): CodeBuild;
29
+ ebs(): EBS;
30
+ ec2(): EC2;
31
+ ec2connect(): EC2InstanceConnect;
32
+ elasticbeanstalk(): ElasticBeanstalk;
33
+ route53(): Route53;
34
+ s3(): S3;
35
+ ses(): SES;
36
+ }
4
37
  export declare class MethodManager {
5
38
  private _mainServer;
6
39
  _methods: MethodModel;
7
40
  private _mailer;
8
- private _imap;
9
41
  private _aws;
10
42
  private serverConfig;
11
43
  private clientDir;
@@ -19,7 +51,7 @@ export declare class MethodManager {
19
51
  callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
20
52
  private sendWS;
21
53
  sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string): Promise<unknown>;
22
- getAWS(): aws.S3;
54
+ getAWS(): AWS;
23
55
  readFile(fileName: any): Promise<unknown>;
24
56
  readImage(fileName: any): Promise<unknown>;
25
57
  }
@@ -43,7 +43,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
43
43
  return r;
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.MethodManager = void 0;
46
+ exports.MethodManager = exports.AWS = void 0;
47
47
  var collections_1 = require("../methods/collections");
48
48
  var logs_1 = require("../methods/logs");
49
49
  var counters_1 = require("../methods/counters");
@@ -53,7 +53,6 @@ var cloudconvert_1 = require("../methods/cloudconvert");
53
53
  var path = require("path");
54
54
  var fs = require("fs");
55
55
  var nodemailer = require("nodemailer");
56
- var aws = require("aws-sdk");
57
56
  var accounts_1 = require("../methods/accounts");
58
57
  var init_1 = require("../fixtures/init");
59
58
  var cron_jobs_1 = require("../fixtures/cron-jobs");
@@ -70,6 +69,165 @@ var monitor_1 = require("../methods/monitor");
70
69
  var email_history_collection_1 = require("../collections/email-history.collection");
71
70
  var mongo_manager_1 = require("./mongo.manager");
72
71
  var monitor_manager_1 = require("./monitor.manager");
72
+ var client_cloudformation_1 = require("@aws-sdk/client-cloudformation");
73
+ var client_cloudfront_1 = require("@aws-sdk/client-cloudfront");
74
+ var client_codebuild_1 = require("@aws-sdk/client-codebuild");
75
+ var client_ebs_1 = require("@aws-sdk/client-ebs");
76
+ var client_ec2_1 = require("@aws-sdk/client-ec2");
77
+ var client_ec2_instance_connect_1 = require("@aws-sdk/client-ec2-instance-connect");
78
+ var client_elastic_beanstalk_1 = require("@aws-sdk/client-elastic-beanstalk");
79
+ var client_route_53_1 = require("@aws-sdk/client-route-53");
80
+ var client_s3_1 = require("@aws-sdk/client-s3");
81
+ var client_ses_1 = require("@aws-sdk/client-ses");
82
+ var AWS = /** @class */ (function () {
83
+ function AWS(serverConfig) {
84
+ this._serverConfig = null;
85
+ this._cloudfront = null;
86
+ this._cloudformation = null;
87
+ this._codebuild = null;
88
+ this._ebs = null;
89
+ this._ec2 = null;
90
+ this._ec2connect = null;
91
+ this._elasticbeanstalk = null;
92
+ this._route53 = null;
93
+ this._s3 = null;
94
+ this._ses = null;
95
+ this._serverConfig = serverConfig;
96
+ }
97
+ AWS.prototype.cloudfront = function () {
98
+ if (this._cloudfront) {
99
+ return this._cloudfront;
100
+ }
101
+ this._cloudfront = new client_cloudfront_1.CloudFront({
102
+ credentials: {
103
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
104
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
105
+ },
106
+ region: 'us-east-1'
107
+ });
108
+ return this._cloudfront;
109
+ };
110
+ AWS.prototype.cloudformation = function () {
111
+ if (this._cloudformation) {
112
+ return this._cloudformation;
113
+ }
114
+ this._cloudformation = new client_cloudformation_1.CloudFormation({
115
+ credentials: {
116
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
117
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
118
+ },
119
+ region: 'us-east-1'
120
+ });
121
+ return this._cloudformation;
122
+ };
123
+ AWS.prototype.codebuild = function () {
124
+ if (this._codebuild) {
125
+ return this._codebuild;
126
+ }
127
+ this._codebuild = new client_codebuild_1.CodeBuild({
128
+ credentials: {
129
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
130
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
131
+ },
132
+ region: 'us-east-1'
133
+ });
134
+ return this._codebuild;
135
+ };
136
+ AWS.prototype.ebs = function () {
137
+ if (this._ebs) {
138
+ return this._ebs;
139
+ }
140
+ this._ebs = new client_ebs_1.EBS({
141
+ credentials: {
142
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
143
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
144
+ },
145
+ region: 'us-east-1'
146
+ });
147
+ return this._ebs;
148
+ };
149
+ AWS.prototype.ec2 = function () {
150
+ if (this._ec2) {
151
+ return this._ec2;
152
+ }
153
+ this._ec2 = new client_ec2_1.EC2({
154
+ // apiVersion: '2016-11-15',
155
+ region: 'us-east-1',
156
+ credentials: {
157
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
158
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
159
+ },
160
+ });
161
+ return this._ec2;
162
+ };
163
+ AWS.prototype.ec2connect = function () {
164
+ if (this._ec2connect) {
165
+ return this._ec2connect;
166
+ }
167
+ this._ec2connect = new client_ec2_instance_connect_1.EC2InstanceConnect({
168
+ region: 'us-east-1',
169
+ credentials: {
170
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
171
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
172
+ }
173
+ });
174
+ return this._ec2connect;
175
+ };
176
+ AWS.prototype.elasticbeanstalk = function () {
177
+ if (this._elasticbeanstalk) {
178
+ return this._elasticbeanstalk;
179
+ }
180
+ this._elasticbeanstalk = new client_elastic_beanstalk_1.ElasticBeanstalk({
181
+ region: 'us-east-1',
182
+ credentials: {
183
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
184
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
185
+ },
186
+ });
187
+ return this._elasticbeanstalk;
188
+ };
189
+ AWS.prototype.route53 = function () {
190
+ if (this._route53) {
191
+ return this._route53;
192
+ }
193
+ this._route53 = new client_route_53_1.Route53({
194
+ credentials: {
195
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
196
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
197
+ },
198
+ region: this._serverConfig.AWSSES_REGION
199
+ });
200
+ return this._route53;
201
+ };
202
+ AWS.prototype.s3 = function () {
203
+ if (this._s3) {
204
+ return this._s3;
205
+ }
206
+ this._s3 = new client_s3_1.S3({
207
+ credentials: {
208
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
209
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
210
+ },
211
+ region: this._serverConfig.AWSREGION
212
+ });
213
+ return this._s3;
214
+ };
215
+ AWS.prototype.ses = function () {
216
+ if (this._ses) {
217
+ return this._ses;
218
+ }
219
+ this._ses = new client_ses_1.SES({
220
+ credentials: {
221
+ accessKeyId: this._serverConfig.AWSACCESSKEYID,
222
+ secretAccessKey: this._serverConfig.AWSSECRETACCESSKEY
223
+ },
224
+ region: this._serverConfig.AWSSES_REGION
225
+ });
226
+ return this._ses;
227
+ };
228
+ return AWS;
229
+ }());
230
+ exports.AWS = AWS;
73
231
  var MethodManager = /** @class */ (function () {
74
232
  function MethodManager(mainServer, serverConfig, clientDir) {
75
233
  var _this = this;
@@ -95,14 +253,10 @@ var MethodManager = /** @class */ (function () {
95
253
  report_builder_1.loadReportBuilderMethods(this);
96
254
  support_1.loadSupportMethods(this);
97
255
  monitor_1.loadMonitorMethods(this);
256
+ this._aws = new AWS(serverConfig);
98
257
  if (mainServer.sesMail) {
99
258
  this._mailer = nodemailer.createTransport({
100
- SES: new aws.SES({
101
- apiVersion: '2010-12-01',
102
- accessKeyId: serverConfig.AWSACCESSKEYID,
103
- secretAccessKey: serverConfig.AWSSECRETACCESSKEY,
104
- region: serverConfig.AWSSES_REGION
105
- })
259
+ SES: this._aws.ses()
106
260
  });
107
261
  }
108
262
  else {
@@ -119,105 +273,6 @@ var MethodManager = /** @class */ (function () {
119
273
  }
120
274
  });
121
275
  }
122
- // this._imap = new imap({
123
- // user: this.serverConfig['ORDERS_EMAIL'],
124
- // password: this.serverConfig['ORDERS_PASSWORD'],
125
- // host: this.serverConfig['ORDERS_HOST'],
126
- // port: this.serverConfig['ORDERS_PORT'],
127
- // tls: this.serverConfig['ORDERS_TLS']
128
- // });
129
- // let that = this;
130
- // let chemicalNames = await Chemicals.find({}).select('description');
131
- // let jobNames = await Jobs.find({status: 'Active'}).select('well');
132
- // console.log(jobNames.map(a => a.well));
133
- // this._imap.once('ready', () => {
134
- // this._imap.openBox('INBOX', true, function(err, box) {
135
- // if (err) {
136
- // throw err;
137
- // }
138
- // that._imap.search([ 'NEW' ], function(err, results) {
139
- // console.log(err, results);
140
- // if (err || !results.length) {
141
- // return that._imap.end();
142
- // }
143
- // let f = that._imap.fetch(results[0], { bodies: ['HEADER.FIELDS (FROM)', 'TEXT'] });
144
- // f.on('message', function(msg, seqno) {
145
- // // console.log('Message #%d', seqno);
146
- // let prefix = '(#' + seqno + ') ';
147
- // msg.on('body', function(stream, info) {
148
- // let buffer = '', count = 0;
149
- // stream.on('data', function(chunk) {
150
- // count += chunk.length;
151
- // buffer += chunk.toString('utf8');
152
- // });
153
- // stream.once('end', function() {
154
- // if (info.which === 'TEXT') {
155
- // // console.log(buffer);
156
- // // console.log(typeof(buffer));
157
- // let lines = buffer.split('\r\n');
158
- // // console.log(lines);
159
- // // let i = 0;
160
- // // lines.forEach(line => {
161
- // // let date: Date;
162
- // // let dateString;
163
- // // if (line.includes('From')) {
164
- // // console.log(line);
165
- // // }
166
- // // if (!line.includes('class=3D') && !line.includes('style=3D')) {
167
- // // if (line.includes('Well') || line.includes('Well Name') || line.includes('Job') || line.includes('Pad')) {
168
- // // let best = stringSimilarity.findBestMatch(line, jobNames.map(a => a.well)).bestMatch;
169
- // // if (best && best.rating > 0.5) {
170
- // // console.log('Well', line);
171
- // // }
172
- // // }
173
- // // if (line.includes('Product') || line.includes('Chemical')) {
174
- // // let best = stringSimilarity.findBestMatch(line, chemicalNames.map(a => a.description)).bestMatch;
175
- // // if (best && best.rating > 0.5) {
176
- // // console.log('Chemical', line);
177
- // // }
178
- // // }
179
- // // if (line.includes('Quantity') || line.includes('Qty') || line.includes('Amount')) {
180
- // // console.log('Qty', line);
181
- // // }
182
- // // if (line.includes('Date')) {
183
- // // console.log('Date', line);
184
- // // console.log(moment(Date.parse(line)));
185
- // // date = moment(Date.parse(line)).toDate();
186
- // // dateString = line;
187
- // // }
188
- // // if (line.includes('Time')) {
189
- // // console.log('Time', line);
190
- // // console.log(moment(Date.parse(line)));
191
- // // console.log(moment(date.setTime(Date.parse(line))));
192
- // // }
193
- // // }
194
- // // });
195
- // }
196
- // });
197
- // });
198
- // msg.once('attributes', function(attrs) {
199
- // console.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));
200
- // });
201
- // msg.once('end', function() {
202
- // console.log(prefix + 'Finished');
203
- // });
204
- // });
205
- // f.once('error', function(error) {
206
- // console.log('Fetch error: ' + error);
207
- // });
208
- // f.once('end', function() {
209
- // console.log('Done fetching all messages!');
210
- // that._imap.end();
211
- // });
212
- // });
213
- // });
214
- // });
215
- // this._imap.connect();
216
- this._aws = new aws.S3({
217
- accessKeyId: serverConfig.AWSACCESSKEYID,
218
- secretAccessKey: serverConfig.AWSSECRETACCESSKEY,
219
- region: serverConfig.AWSREGION
220
- });
221
276
  setInterval(function () {
222
277
  if (!_this._runningQueue) {
223
278
  if (_this._sendQueue.length) {
@@ -279,53 +334,53 @@ var MethodManager = /** @class */ (function () {
279
334
  };
280
335
  MethodManager.prototype.callMethodCron = function (method) {
281
336
  var _a;
337
+ var _this = this;
282
338
  var methodData = [];
283
339
  for (var _i = 1; _i < arguments.length; _i++) {
284
340
  methodData[_i - 1] = arguments[_i];
285
341
  }
286
- var that = this;
287
- if (!that._methods[method]) {
342
+ if (!this._methods[method]) {
288
343
  console.log('No Method: ' + method);
289
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
344
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
290
345
  return;
291
346
  }
292
- if ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {
293
- if (!that._methods[method].check) {
347
+ if ((methodData.length > 1 || methodData[0]) && !this._methods[method].skipValidation) {
348
+ if (!this._methods[method].check) {
294
349
  console.error(new Date(), 'No Check Function For Method ' + method);
295
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
350
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
296
351
  return;
297
352
  }
298
- else if (!that._methods[method].check._schema) {
353
+ else if (!this._methods[method].check._schema) {
299
354
  console.error(new Date(), 'No Check Schema For Method ' + method);
300
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
355
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
301
356
  return;
302
357
  }
303
358
  else {
304
359
  var valObj = {};
305
- var valKeys = Object.keys(that._methods[method].check._schema);
360
+ var valKeys = Object.keys(this._methods[method].check._schema);
306
361
  var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
307
362
  for (var i = 0; i < methodData.length; i++) {
308
363
  valObj[rootKeys[i]] = methodData[i];
309
364
  }
310
365
  try {
311
- that._methods[method].check.validate(valObj);
366
+ this._methods[method].check.validate(valObj);
312
367
  }
313
368
  catch (errors) {
314
369
  if (errors) {
315
370
  console.error(new Date(), 'Error in Method Check (' + method + ')', errors);
316
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
371
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
317
372
  return;
318
373
  }
319
374
  }
320
375
  }
321
376
  }
322
377
  var monitor = new monitor_manager_1.MonitorFunction('Cron Method', method, '', methodData);
323
- var promise = (_a = that._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, MethodManager.prototype, { id_user: '', user: '', id_ws: '' })], methodData)).then(function (res) {
378
+ var promise = (_a = this._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, this, MethodManager.prototype, { id_user: '', user: '', id_ws: '' })], methodData)).then(function (res) {
324
379
  monitor.finish();
325
380
  return res;
326
381
  }, function (methodErrs) {
327
382
  monitor.finish();
328
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodCron)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
383
+ _this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodCron)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
329
384
  return methodErrs;
330
385
  });
331
386
  return promise;
@@ -338,10 +393,9 @@ var MethodManager = /** @class */ (function () {
338
393
  for (var _i = 5; _i < arguments.length; _i++) {
339
394
  methodData[_i - 5] = arguments[_i];
340
395
  }
341
- var that = this;
342
- if (!that._methods[method]) {
396
+ if (!this._methods[method]) {
343
397
  console.log('No Method: ' + method);
344
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
398
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
345
399
  var serverRes = {
346
400
  messageId: messageId,
347
401
  hasError: true,
@@ -353,10 +407,10 @@ var MethodManager = /** @class */ (function () {
353
407
  }
354
408
  return;
355
409
  }
356
- if ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {
357
- if (!that._methods[method].check) {
410
+ if ((methodData.length > 1 || methodData[0]) && !this._methods[method].skipValidation) {
411
+ if (!this._methods[method].check) {
358
412
  console.error(new Date(), 'No Check Function For Method ' + method);
359
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
413
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
360
414
  var serverRes = {
361
415
  messageId: messageId,
362
416
  hasError: true,
@@ -368,9 +422,9 @@ var MethodManager = /** @class */ (function () {
368
422
  }
369
423
  return;
370
424
  }
371
- else if (!that._methods[method].check._schema) {
425
+ else if (!this._methods[method].check._schema) {
372
426
  console.error(new Date(), 'No Check Schema For Method ' + method);
373
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
427
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
374
428
  var serverRes = {
375
429
  messageId: messageId,
376
430
  hasError: true,
@@ -384,18 +438,18 @@ var MethodManager = /** @class */ (function () {
384
438
  }
385
439
  else {
386
440
  var valObj = {};
387
- var valKeys = Object.keys(that._methods[method].check._schema);
441
+ var valKeys = Object.keys(this._methods[method].check._schema);
388
442
  var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
389
443
  for (var i = 0; i < methodData.length; i++) {
390
444
  valObj[rootKeys[i]] = methodData[i];
391
445
  }
392
446
  try {
393
- that._methods[method].check.validate(valObj);
447
+ this._methods[method].check.validate(valObj);
394
448
  }
395
449
  catch (errors) {
396
450
  if (errors) {
397
451
  console.error(new Date(), 'Error in Method Check (' + method + ')', errors);
398
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
452
+ this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
399
453
  var serverRes = {
400
454
  messageId: messageId,
401
455
  hasError: true,
@@ -411,7 +465,7 @@ var MethodManager = /** @class */ (function () {
411
465
  }
412
466
  }
413
467
  var monitor = new monitor_manager_1.MonitorFunction('Method', method, ws['user'], methodData);
414
- (_a = that._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, MethodManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })], methodData)).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
468
+ (_a = this._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, this, MethodManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })], methodData)).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
415
469
  var serverRes, latency;
416
470
  return __generator(this, function (_a) {
417
471
  switch (_a.label) {
@@ -445,27 +499,27 @@ var MethodManager = /** @class */ (function () {
445
499
  if (id_methodLatency) {
446
500
  log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
447
501
  }
448
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethod)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(err, null, 2));
502
+ _this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethod)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(err, null, 2));
449
503
  });
450
504
  };
451
505
  // Call/run method internal (No Emit on Socket)
452
506
  MethodManager.prototype.callMethodInternal = function (method) {
453
507
  var _a;
508
+ var _this = this;
454
509
  var methodData = [];
455
510
  for (var _i = 1; _i < arguments.length; _i++) {
456
511
  methodData[_i - 1] = arguments[_i];
457
512
  }
458
- var that = this;
459
- if (!that._methods[method]) {
513
+ if (!this._methods[method]) {
460
514
  console.log('No Method: ' + method);
461
515
  return null;
462
516
  }
463
- if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._methods[method].skipValidation) {
464
- if (!that._methods[method].check) {
517
+ if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !this._methods[method].skipValidation) {
518
+ if (!this._methods[method].check) {
465
519
  console.error(new Date(), 'No Check Function For Method ' + method);
466
520
  return null;
467
521
  }
468
- else if (!that._methods[method].check._schema) {
522
+ else if (!this._methods[method].check._schema) {
469
523
  console.error(new Date(), 'No Check Schema For Method ' + method);
470
524
  return null;
471
525
  }
@@ -485,12 +539,12 @@ var MethodManager = /** @class */ (function () {
485
539
  });
486
540
  }
487
541
  var monitor = new monitor_manager_1.MonitorFunction('Internal Method', method, this['id_user'] || '', methodData);
488
- var promise = (_a = that._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, MethodManager.prototype)], methodData)).then(function (res) {
542
+ var promise = (_a = this._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, this, MethodManager.prototype)], methodData)).then(function (res) {
489
543
  monitor.finish();
490
544
  return res;
491
545
  }, function (methodErrs) {
492
546
  monitor.finish();
493
- that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodInternal)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
547
+ _this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodInternal)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
494
548
  return methodErrs;
495
549
  });
496
550
  if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {