@resolveio/server-lib 9.0.34 → 9.0.35

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.
Files changed (192) hide show
  1. package/client-server-app.js +48 -7
  2. package/client-server-app.js.map +1 -1
  3. package/collections/app-status.collection.js +11 -8
  4. package/collections/app-status.collection.js.map +1 -1
  5. package/collections/app-version.collection.js +11 -8
  6. package/collections/app-version.collection.js.map +1 -1
  7. package/collections/counter.collection.js +11 -8
  8. package/collections/counter.collection.js.map +1 -1
  9. package/collections/cron-job-history.collection.js +12 -9
  10. package/collections/cron-job-history.collection.js.map +1 -1
  11. package/collections/cron-job.collection.js +11 -8
  12. package/collections/cron-job.collection.js.map +1 -1
  13. package/collections/email-history.collection.js +11 -8
  14. package/collections/email-history.collection.js.map +1 -1
  15. package/collections/email-verified.collection.js +12 -9
  16. package/collections/email-verified.collection.js.map +1 -1
  17. package/collections/file.collection.js +11 -8
  18. package/collections/file.collection.js.map +1 -1
  19. package/collections/flag.collection.js +11 -8
  20. package/collections/flag.collection.js.map +1 -1
  21. package/collections/log-method-latency.collection.js +14 -11
  22. package/collections/log-method-latency.collection.js.map +1 -1
  23. package/collections/log-subscription.collection.js +16 -13
  24. package/collections/log-subscription.collection.js.map +1 -1
  25. package/collections/log.collection.js +19 -16
  26. package/collections/log.collection.js.map +1 -1
  27. package/collections/logged-in-users.collection.js +12 -9
  28. package/collections/logged-in-users.collection.js.map +1 -1
  29. package/collections/method-call.collection.js +13 -10
  30. package/collections/method-call.collection.js.map +1 -1
  31. package/collections/method-response.collection.js +13 -10
  32. package/collections/method-response.collection.js.map +1 -1
  33. package/collections/monitor-cpu.collection.js +16 -13
  34. package/collections/monitor-cpu.collection.js.map +1 -1
  35. package/collections/monitor-https-inbound.collection.js +16 -13
  36. package/collections/monitor-https-inbound.collection.js.map +1 -1
  37. package/collections/monitor-https-outbound.collection.js +18 -15
  38. package/collections/monitor-https-outbound.collection.js.map +1 -1
  39. package/collections/monitor-memory.collection.js +15 -12
  40. package/collections/monitor-memory.collection.js.map +1 -1
  41. package/collections/monitor-mongo.collection.js +15 -12
  42. package/collections/monitor-mongo.collection.js.map +1 -1
  43. package/collections/notification.collection.js +11 -8
  44. package/collections/notification.collection.js.map +1 -1
  45. package/collections/queue-flag.collection.js +12 -9
  46. package/collections/queue-flag.collection.js.map +1 -1
  47. package/collections/queue-method.collection.js +12 -9
  48. package/collections/queue-method.collection.js.map +1 -1
  49. package/collections/queue-response.collection.js +12 -9
  50. package/collections/queue-response.collection.js.map +1 -1
  51. package/collections/report-builder-dashboard-builder.collection.js +13 -10
  52. package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
  53. package/collections/report-builder-library.collection.js +14 -11
  54. package/collections/report-builder-library.collection.js.map +1 -1
  55. package/collections/report-builder-report.collection.js +14 -11
  56. package/collections/report-builder-report.collection.js.map +1 -1
  57. package/collections/user-group.collection.js +14 -11
  58. package/collections/user-group.collection.js.map +1 -1
  59. package/collections/user-guide.collection.js +11 -8
  60. package/collections/user-guide.collection.js.map +1 -1
  61. package/collections/user.collection.js +15 -12
  62. package/collections/user.collection.js.map +1 -1
  63. package/cron/cron.js +25 -25
  64. package/cron/cron.js.map +1 -1
  65. package/fixtures/cron-jobs.js +80 -30
  66. package/fixtures/cron-jobs.js.map +1 -1
  67. package/fixtures/init.js +59 -9
  68. package/fixtures/init.js.map +1 -1
  69. package/http/auth.js +460 -344
  70. package/http/auth.js.map +1 -1
  71. package/http/health.js +5 -1
  72. package/http/health.js.map +1 -1
  73. package/http/home.js +11 -7
  74. package/http/home.js.map +1 -1
  75. package/index.js +98 -36
  76. package/index.js.map +1 -1
  77. package/managers/cron.manager.js +157 -78
  78. package/managers/cron.manager.js.map +1 -1
  79. package/managers/method.manager.js +302 -314
  80. package/managers/method.manager.js.map +1 -1
  81. package/managers/mongo.manager.js +1001 -739
  82. package/managers/mongo.manager.js.map +1 -1
  83. package/managers/monitor.manager.js +254 -171
  84. package/managers/monitor.manager.js.map +1 -1
  85. package/managers/queue-method.manager.js +166 -69
  86. package/managers/queue-method.manager.js.map +1 -1
  87. package/managers/subscription.manager.js +714 -515
  88. package/managers/subscription.manager.js.map +1 -1
  89. package/methods/accounts.js +183 -111
  90. package/methods/accounts.js.map +1 -1
  91. package/methods/aws.js +262 -156
  92. package/methods/aws.js.map +1 -1
  93. package/methods/cloudconvert.js +180 -100
  94. package/methods/cloudconvert.js.map +1 -1
  95. package/methods/collections.js +110 -103
  96. package/methods/collections.js.map +1 -1
  97. package/methods/counters.js +79 -29
  98. package/methods/counters.js.map +1 -1
  99. package/methods/cron-jobs.js +884 -819
  100. package/methods/cron-jobs.js.map +1 -1
  101. package/methods/flags.js +5 -1
  102. package/methods/flags.js.map +1 -1
  103. package/methods/logs.js +313 -258
  104. package/methods/logs.js.map +1 -1
  105. package/methods/monitor.js +348 -289
  106. package/methods/monitor.js.map +1 -1
  107. package/methods/pdf.js +340 -341
  108. package/methods/pdf.js.map +1 -1
  109. package/methods/report-builder.js +657 -565
  110. package/methods/report-builder.js.map +1 -1
  111. package/methods/support.js +185 -67
  112. package/methods/support.js.map +1 -1
  113. package/models/app-status.model.js +2 -1
  114. package/models/app-version.model.js +2 -1
  115. package/models/billing-logged-in-users.model.js +2 -1
  116. package/models/collection-document.model.js +2 -1
  117. package/models/counter.model.js +2 -1
  118. package/models/cron-job-history.model.js +2 -1
  119. package/models/cron-job.model.js +2 -1
  120. package/models/dialog.model.js +2 -1
  121. package/models/email-history.model.js +2 -1
  122. package/models/email-verified.model.js +2 -1
  123. package/models/file.model.js +2 -1
  124. package/models/flag.model.js +2 -1
  125. package/models/log-method-latency.model.js +2 -1
  126. package/models/log-subscription.model.js +2 -1
  127. package/models/log.model.js +2 -1
  128. package/models/logged-in-users.model.js +2 -1
  129. package/models/method-call.model.js +2 -1
  130. package/models/method-response.model.js +2 -1
  131. package/models/method.model.js +2 -1
  132. package/models/monitor-cpu.model.js +2 -1
  133. package/models/monitor-https-inbound.model.js +2 -1
  134. package/models/monitor-https-outbound.model.js +2 -1
  135. package/models/monitor-memory.model.js +2 -1
  136. package/models/monitor-mongo.model.js +2 -1
  137. package/models/notification.model.js +2 -1
  138. package/models/pagination.model.js +5 -2
  139. package/models/pagination.model.js.map +1 -1
  140. package/models/permission.model.js +2 -1
  141. package/models/queue-method.model.js +2 -1
  142. package/models/queue-response.model.js +2 -1
  143. package/models/report-builder-dashboard-builder.model.js +2 -1
  144. package/models/report-builder-library.model.js +2 -1
  145. package/models/report-builder-report.model.js +2 -1
  146. package/models/report-builder.model.js +2 -1
  147. package/models/select-data-label.model.js +2 -1
  148. package/models/server-response.model.js +2 -1
  149. package/models/subscription.model.js +2 -1
  150. package/models/support-ticket.model.js +2 -1
  151. package/models/user-group.model.js +2 -1
  152. package/models/user-guide.model.js +2 -1
  153. package/models/user.model.js +2 -1
  154. package/package.json +1 -1
  155. package/public_api.js +82 -70
  156. package/public_api.js.map +1 -1
  157. package/publications/app-status.js +8 -4
  158. package/publications/app-status.js.map +1 -1
  159. package/publications/app-version.js +8 -4
  160. package/publications/app-version.js.map +1 -1
  161. package/publications/cron-jobs.js +13 -9
  162. package/publications/cron-jobs.js.map +1 -1
  163. package/publications/files.js +15 -11
  164. package/publications/files.js.map +1 -1
  165. package/publications/flags.js +11 -7
  166. package/publications/flags.js.map +1 -1
  167. package/publications/logs.js +35 -31
  168. package/publications/logs.js.map +1 -1
  169. package/publications/method-calls.js +8 -4
  170. package/publications/method-calls.js.map +1 -1
  171. package/publications/method-responses.js +8 -4
  172. package/publications/method-responses.js.map +1 -1
  173. package/publications/notifications.js +8 -4
  174. package/publications/notifications.js.map +1 -1
  175. package/publications/report-builder-dashboard-builders.js +12 -8
  176. package/publications/report-builder-dashboard-builders.js.map +1 -1
  177. package/publications/report-builder-libraries.js +66 -16
  178. package/publications/report-builder-libraries.js.map +1 -1
  179. package/publications/report-builder-reports.js +21 -17
  180. package/publications/report-builder-reports.js.map +1 -1
  181. package/publications/super-admin.js +7 -3
  182. package/publications/super-admin.js.map +1 -1
  183. package/publications/user-groups.js +8 -4
  184. package/publications/user-groups.js.map +1 -1
  185. package/publications/user-guides.js +8 -4
  186. package/publications/user-guides.js.map +1 -1
  187. package/server-app.js +534 -393
  188. package/server-app.js.map +1 -1
  189. package/util/common.js +92 -55
  190. package/util/common.js.map +1 -1
  191. package/util/schema-report-builder.js +134 -76
  192. package/util/schema-report-builder.js.map +1 -1
@@ -1,31 +1,78 @@
1
- import { loadCollectionMethods } from '../methods/collections';
2
- import { loadLogMethods } from '../methods/logs';
3
- import { loadCounterMethods } from '../methods/counters';
4
- import { loadPDFMethods } from '../methods/pdf';
5
- import { loadAWSMethods } from '../methods/aws';
6
- import { loadCloudConvertMethods } from '../methods/cloudconvert';
7
- import * as path from 'path';
8
- import * as fs from 'fs';
9
- import * as nodemailer from 'nodemailer';
10
- import * as aws from 'aws-sdk';
11
- import { loadAccountMethods } from '../methods/accounts';
12
- import { loadServerInit } from '../fixtures/init';
13
- import { loadServerCronJobs } from '../fixtures/cron-jobs';
14
- import { loadCronJobMethods } from '../methods/cron-jobs';
15
- import { loadFlagMethods } from '../methods/flags';
16
- import { MethodResponses } from '../collections/method-response.collection';
17
- import { deepCopy, getBinarySize } from '../util/common';
18
- import { Logs } from '../collections/log.collection';
19
- import { LogMethodLatencies } from '../collections/log-method-latency.collection';
20
- import * as moment from 'moment';
21
- import { loadReportBuilderMethods } from '../methods/report-builder';
22
- import { loadSupportMethods } from '../methods/support';
23
- import { loadMonitorMethods } from '../methods/monitor';
24
- import { EmailHistories } from '../collections/email-history.collection';
25
- import { objectIdHexString } from './mongo.manager';
26
- const Verifier = require('email-verifier');
27
- export class MethodManager {
28
- constructor(mainServer, serverConfig, clientDir) {
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
39
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
40
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
41
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
42
+ r[k] = a[j];
43
+ return r;
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.MethodManager = void 0;
47
+ var collections_1 = require("../methods/collections");
48
+ var logs_1 = require("../methods/logs");
49
+ var counters_1 = require("../methods/counters");
50
+ var pdf_1 = require("../methods/pdf");
51
+ var aws_1 = require("../methods/aws");
52
+ var cloudconvert_1 = require("../methods/cloudconvert");
53
+ var path = require("path");
54
+ var fs = require("fs");
55
+ var nodemailer = require("nodemailer");
56
+ var aws = require("aws-sdk");
57
+ var accounts_1 = require("../methods/accounts");
58
+ var init_1 = require("../fixtures/init");
59
+ var cron_jobs_1 = require("../fixtures/cron-jobs");
60
+ var cron_jobs_2 = require("../methods/cron-jobs");
61
+ var flags_1 = require("../methods/flags");
62
+ var method_response_collection_1 = require("../collections/method-response.collection");
63
+ var common_1 = require("../util/common");
64
+ var log_collection_1 = require("../collections/log.collection");
65
+ var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
66
+ var moment = require("moment");
67
+ var report_builder_1 = require("../methods/report-builder");
68
+ var support_1 = require("../methods/support");
69
+ var monitor_1 = require("../methods/monitor");
70
+ var email_history_collection_1 = require("../collections/email-history.collection");
71
+ var mongo_manager_1 = require("./mongo.manager");
72
+ var Verifier = require('email-verifier');
73
+ var MethodManager = /** @class */ (function () {
74
+ function MethodManager(mainServer, serverConfig, clientDir) {
75
+ var _this = this;
29
76
  this._methods = {};
30
77
  this._sendQueue = [];
31
78
  this._runningQueue = false;
@@ -33,21 +80,21 @@ export class MethodManager {
33
80
  this.serverConfig = serverConfig;
34
81
  this.clientDir = clientDir;
35
82
  // Fixtures
36
- loadServerInit();
37
- loadServerCronJobs();
83
+ init_1.loadServerInit();
84
+ cron_jobs_1.loadServerCronJobs();
38
85
  // Methods
39
- loadAccountMethods(this);
40
- loadAWSMethods(this);
41
- loadCloudConvertMethods(this);
42
- loadCollectionMethods(this);
43
- loadCounterMethods(this);
44
- loadLogMethods(this);
45
- loadPDFMethods(this);
46
- loadCronJobMethods(this);
47
- loadFlagMethods(this);
48
- loadReportBuilderMethods(this);
49
- loadSupportMethods(this);
50
- loadMonitorMethods(this);
86
+ accounts_1.loadAccountMethods(this);
87
+ aws_1.loadAWSMethods(this);
88
+ cloudconvert_1.loadCloudConvertMethods(this);
89
+ collections_1.loadCollectionMethods(this);
90
+ counters_1.loadCounterMethods(this);
91
+ logs_1.loadLogMethods(this);
92
+ pdf_1.loadPDFMethods(this);
93
+ cron_jobs_2.loadCronJobMethods(this);
94
+ flags_1.loadFlagMethods(this);
95
+ report_builder_1.loadReportBuilderMethods(this);
96
+ support_1.loadSupportMethods(this);
97
+ monitor_1.loadMonitorMethods(this);
51
98
  if (mainServer.sesMail) {
52
99
  this._mailer = nodemailer.createTransport({
53
100
  SES: new aws.SES({
@@ -171,28 +218,28 @@ export class MethodManager {
171
218
  secretAccessKey: serverConfig.AWSSECRETACCESSKEY,
172
219
  region: serverConfig.AWSREGION
173
220
  });
174
- setInterval(() => {
175
- if (!this._runningQueue) {
176
- if (this._sendQueue.length) {
177
- this._runningQueue = true;
178
- for (let i = this._sendQueue.length - 1; i >= 0; i--) {
179
- let ws = this._mainServer.getWS(this._sendQueue[i].id_ws);
221
+ setInterval(function () {
222
+ if (!_this._runningQueue) {
223
+ if (_this._sendQueue.length) {
224
+ _this._runningQueue = true;
225
+ var _loop_1 = function (i) {
226
+ var ws = _this._mainServer.getWS(_this._sendQueue[i].id_ws);
180
227
  if (ws && ws.readyState === ws.OPEN) {
181
228
  if (ws.bufferedAmount < 20480) {
182
- let sendItem = this._sendQueue.pop();
183
- ws.send(JSON.stringify(sendItem.data), (error) => {
229
+ var sendItem = _this._sendQueue.pop();
230
+ ws.send(JSON.stringify(sendItem.data), function (error) {
184
231
  if (error) {
185
232
  console.log('Error on WS: ', error);
186
- this._mainServer.unsubscribeWS(ws);
233
+ _this._mainServer.unsubscribeWS(ws);
187
234
  }
188
235
  });
189
236
  if (sendItem.method !== 'reportBuilderGetResults' && sendItem.method !== 'reportBuilderGetDistinctValue' && sendItem.method !== 'reportBuilderBuildTree' && sendItem.method !== 'generatePDF' && sendItem.method !== 'getWOOfflineData' && sendItem.method !== 'countQuery' && sendItem.method !== 'countWithQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'setWSAppVersion' && sendItem.method !== 'uploadFileAndSave' && sendItem.method !== 'getDrivers') {
190
- Logs.create({
191
- _id: objectIdHexString(),
237
+ log_collection_1.Logs.create({
238
+ _id: mongo_manager_1.objectIdHexString(),
192
239
  type: 'client-response',
193
240
  collection: '',
194
241
  id_document: '',
195
- payload: getBinarySize(JSON.stringify([sendItem.methodData, sendItem.data])) < 200000 ? JSON.stringify([sendItem.methodData, sendItem.data], null, 2) : 'Too Big',
242
+ payload: common_1.getBinarySize(JSON.stringify([sendItem.methodData, sendItem.data])) < 200000 ? JSON.stringify([sendItem.methodData, sendItem.data], null, 2) : 'Too Big',
196
243
  method: sendItem.method,
197
244
  id_user: ws['id_user'],
198
245
  user: ws['user'],
@@ -200,35 +247,43 @@ export class MethodManager {
200
247
  route: ''
201
248
  });
202
249
  }
203
- MethodResponses.create({
204
- _id: objectIdHexString(),
250
+ method_response_collection_1.MethodResponses.create({
251
+ _id: mongo_manager_1.objectIdHexString(),
205
252
  __v: 0,
206
253
  id_user: ws['id_user'],
207
254
  message_id: sendItem.data.messageId,
208
- response: getBinarySize(JSON.stringify(sendItem.data)) < 200000 ? sendItem.data : 'Too Big',
255
+ response: common_1.getBinarySize(JSON.stringify(sendItem.data)) < 200000 ? sendItem.data : 'Too Big',
209
256
  method: sendItem.method,
210
257
  date: sendItem.date
211
258
  });
212
259
  }
213
260
  }
214
261
  else {
215
- this._sendQueue.splice(i, 1);
262
+ _this._sendQueue.splice(i, 1);
216
263
  }
264
+ };
265
+ for (var i = _this._sendQueue.length - 1; i >= 0; i--) {
266
+ _loop_1(i);
217
267
  }
218
- this._runningQueue = false;
268
+ _this._runningQueue = false;
219
269
  }
220
270
  }
221
271
  }, 10);
222
272
  }
223
- getMainServer() {
273
+ MethodManager.prototype.getMainServer = function () {
224
274
  return this._mainServer;
225
- }
275
+ };
226
276
  // Add methods to private methods object
227
- methods(method) {
277
+ MethodManager.prototype.methods = function (method) {
228
278
  this._methods = Object.assign(this._methods, method);
229
- }
230
- callMethodCron(method, ...methodData) {
231
- let that = this;
279
+ };
280
+ MethodManager.prototype.callMethodCron = function (method) {
281
+ var _a;
282
+ var methodData = [];
283
+ for (var _i = 1; _i < arguments.length; _i++) {
284
+ methodData[_i - 1] = arguments[_i];
285
+ }
286
+ var that = this;
232
287
  if (!that._methods[method]) {
233
288
  console.log('No Method: ' + method);
234
289
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
@@ -246,10 +301,10 @@ export class MethodManager {
246
301
  return;
247
302
  }
248
303
  else {
249
- let valObj = {};
250
- let valKeys = Object.keys(that._methods[method].check._schema);
251
- let rootKeys = valKeys.filter(a => !a.includes('.'));
252
- for (let i = 0; i < methodData.length; i++) {
304
+ var valObj = {};
305
+ var valKeys = Object.keys(that._methods[method].check._schema);
306
+ var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
307
+ for (var i = 0; i < methodData.length; i++) {
253
308
  valObj[rootKeys[i]] = methodData[i];
254
309
  }
255
310
  try {
@@ -264,57 +319,59 @@ export class MethodManager {
264
319
  }
265
320
  }
266
321
  }
267
- that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, { id_user: '', user: '', id_ws: '' }), ...methodData).catch(methodErrs => {
322
+ (_a = that._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, MethodManager.prototype, { id_user: '', user: '', id_ws: '' })], methodData)).catch(function (methodErrs) {
268
323
  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));
269
324
  });
270
- }
271
- callMethodQueue(update) {
325
+ };
326
+ MethodManager.prototype.callMethodQueue = function (update) {
327
+ var _this = this;
272
328
  // console.log('Call Method Queue', update);
273
- return new Promise((resolve, reject) => {
274
- let updateCopy = deepCopy(update);
275
- let that = this;
329
+ return new Promise(function (resolve, reject) {
330
+ var _a;
331
+ var updateCopy = common_1.deepCopy(update);
332
+ var that = _this;
276
333
  if (!that._methods[update.method]) {
277
334
  console.log('No Method: ' + update.method);
278
335
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + update.method);
279
- let serverRes = {
336
+ var serverRes = {
280
337
  messageId: update.messageId,
281
338
  hasError: true,
282
339
  data: 'Internal Error'
283
340
  };
284
- this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
285
- LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
341
+ _this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
342
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
286
343
  return resolve('No Method: ' + update.method);
287
344
  }
288
345
  if ((update.method_data.length > 1 || update.method_data[0]) && !that._methods[update.method].skipValidation) {
289
346
  if (!that._methods[update.method].check) {
290
347
  console.error('No Check Function For Method ' + update.method);
291
348
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);
292
- let serverRes = {
349
+ var serverRes = {
293
350
  messageId: update.messageId,
294
351
  hasError: true,
295
352
  data: 'Internal Error'
296
353
  };
297
- this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
298
- LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
354
+ _this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
355
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
299
356
  return resolve('No Check Function For Method ' + update.method);
300
357
  }
301
358
  else if (!that._methods[update.method].check._schema) {
302
359
  console.error('No Check Schema For Method ' + update.method);
303
360
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);
304
- let serverRes = {
361
+ var serverRes = {
305
362
  messageId: update.messageId,
306
363
  hasError: true,
307
364
  data: 'Internal Error'
308
365
  };
309
- this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
310
- LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
366
+ _this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
367
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
311
368
  return resolve('No Check Schema For Method ' + update.method);
312
369
  }
313
370
  else {
314
- let valObj = {};
315
- let valKeys = Object.keys(that._methods[update.method].check._schema);
316
- let rootKeys = valKeys.filter(a => !a.includes('.'));
317
- for (let i = 0; i < update.method_data.length; i++) {
371
+ var valObj = {};
372
+ var valKeys = Object.keys(that._methods[update.method].check._schema);
373
+ var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
374
+ for (var i = 0; i < update.method_data.length; i++) {
318
375
  valObj[rootKeys[i]] = update.method_data[i];
319
376
  }
320
377
  try {
@@ -324,97 +381,112 @@ export class MethodManager {
324
381
  if (errors) {
325
382
  console.error('Error in Method Check (' + update.method + ')', errors);
326
383
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + update.method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
327
- let serverRes = {
384
+ var serverRes = {
328
385
  messageId: update.messageId,
329
386
  hasError: true,
330
387
  data: 'Internal Error'
331
388
  };
332
- this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
333
- LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
389
+ _this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
390
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
334
391
  return resolve('Error in Method Check (' + update.method + ')');
335
392
  }
336
393
  }
337
394
  }
338
395
  }
339
- let timeout = setTimeout(() => {
396
+ var timeout = setTimeout(function () {
340
397
  console.error('Timeout on method', update);
341
- this.callMethodInternal('insertErrorLog', 'Timeout on method: ', [update]);
398
+ _this.callMethodInternal('insertErrorLog', 'Timeout on method: ', [update]);
342
399
  resolve('Timeout');
343
400
  }, 5000);
344
401
  // console.log('Run Method', update.method);
345
- that._methods[update.method].function.call(Object.assign({}, that, MethodManager.prototype, { id_user: update.id_user, user: update.user, id_ws: update.id_ws }), ...update.method_data).catch(methodErrs => {
402
+ (_a = that._methods[update.method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, MethodManager.prototype, { id_user: update.id_user, user: update.user, id_ws: update.id_ws })], update.method_data)).catch(function (methodErrs) {
346
403
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + update.method + ' - (callMethodQueue)\n\nData \n' + JSON.stringify(update.method_data, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
347
- }).then(async (res) => {
348
- let serverRes = {
349
- messageId: update.messageId,
350
- hasError: false,
351
- data: res
352
- };
353
- this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
354
- clearTimeout(timeout);
355
- let latency = await LogMethodLatencies.findById(update.id_methodLatency);
356
- if (latency) {
357
- LogMethodLatencies.updateOne({ _id: update.id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
358
- }
359
- resolve(serverRes);
360
- }, err => {
361
- let serverRes = {
404
+ }).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
405
+ var serverRes, latency;
406
+ return __generator(this, function (_a) {
407
+ switch (_a.label) {
408
+ case 0:
409
+ serverRes = {
410
+ messageId: update.messageId,
411
+ hasError: false,
412
+ data: res
413
+ };
414
+ this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
415
+ clearTimeout(timeout);
416
+ return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.findById(update.id_methodLatency)];
417
+ case 1:
418
+ latency = _a.sent();
419
+ if (latency) {
420
+ log_method_latency_collection_1.LogMethodLatencies.updateOne({ _id: update.id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
421
+ }
422
+ resolve(serverRes);
423
+ return [2 /*return*/];
424
+ }
425
+ });
426
+ }); }, function (err) {
427
+ var serverRes = {
362
428
  messageId: update.messageId,
363
429
  hasError: true,
364
430
  data: err
365
431
  };
366
- this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
432
+ _this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
367
433
  clearTimeout(timeout);
368
- LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
434
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
369
435
  resolve(serverRes);
370
436
  });
371
437
  });
372
- }
438
+ };
373
439
  // Call/run method (Emit on Socket)
374
- callMethod(id_methodLatency, ws, messageDate, messageId, method, ...methodData) {
375
- let that = this;
440
+ MethodManager.prototype.callMethod = function (id_methodLatency, ws, messageDate, messageId, method) {
441
+ var _a;
442
+ var _this = this;
443
+ var methodData = [];
444
+ for (var _i = 5; _i < arguments.length; _i++) {
445
+ methodData[_i - 5] = arguments[_i];
446
+ }
447
+ var that = this;
376
448
  if (!that._methods[method]) {
377
449
  console.log('No Method: ' + method);
378
450
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
379
- let serverRes = {
451
+ var serverRes = {
380
452
  messageId: messageId,
381
453
  hasError: true,
382
454
  data: 'Internal Error'
383
455
  };
384
456
  this.sendWS(ws, messageDate, method, methodData, serverRes);
385
- LogMethodLatencies.deleteOne({ _id: id_methodLatency });
457
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
386
458
  return;
387
459
  }
388
460
  if ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {
389
461
  if (!that._methods[method].check) {
390
462
  console.error('No Check Function For Method ' + method);
391
463
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
392
- let serverRes = {
464
+ var serverRes = {
393
465
  messageId: messageId,
394
466
  hasError: true,
395
467
  data: 'Internal Error'
396
468
  };
397
469
  this.sendWS(ws, messageDate, method, methodData, serverRes);
398
- LogMethodLatencies.deleteOne({ _id: id_methodLatency });
470
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
399
471
  return;
400
472
  }
401
473
  else if (!that._methods[method].check._schema) {
402
474
  console.error('No Check Schema For Method ' + method);
403
475
  that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
404
- let serverRes = {
476
+ var serverRes = {
405
477
  messageId: messageId,
406
478
  hasError: true,
407
479
  data: 'Internal Error'
408
480
  };
409
- LogMethodLatencies.deleteOne({ _id: id_methodLatency });
481
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
410
482
  this.sendWS(ws, messageDate, method, methodData, serverRes);
411
483
  return;
412
484
  }
413
485
  else {
414
- let valObj = {};
415
- let valKeys = Object.keys(that._methods[method].check._schema);
416
- let rootKeys = valKeys.filter(a => !a.includes('.'));
417
- for (let i = 0; i < methodData.length; i++) {
486
+ var valObj = {};
487
+ var valKeys = Object.keys(that._methods[method].check._schema);
488
+ var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
489
+ for (var i = 0; i < methodData.length; i++) {
418
490
  valObj[rootKeys[i]] = methodData[i];
419
491
  }
420
492
  try {
@@ -424,44 +496,58 @@ export class MethodManager {
424
496
  if (errors) {
425
497
  console.error('Error in Method Check (' + method + ')', errors);
426
498
  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));
427
- let serverRes = {
499
+ var serverRes = {
428
500
  messageId: messageId,
429
501
  hasError: true,
430
502
  data: 'Internal Error'
431
503
  };
432
504
  this.sendWS(ws, messageDate, method, methodData, serverRes);
433
- LogMethodLatencies.deleteOne({ _id: id_methodLatency });
505
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
434
506
  return;
435
507
  }
436
508
  }
437
509
  }
438
510
  }
439
- that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] }), ...methodData).catch(methodErrs => {
511
+ (_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)).catch(function (methodErrs) {
440
512
  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(methodErrs, null, 2));
441
- }).then(async (res) => {
442
- let serverRes = {
443
- messageId: messageId,
444
- hasError: false,
445
- data: res
446
- };
447
- this.sendWS(ws, messageDate, method, methodData, serverRes);
448
- let latency = await LogMethodLatencies.findById(id_methodLatency);
449
- if (latency) {
450
- LogMethodLatencies.updateOne({ _id: id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
451
- }
452
- }, err => {
453
- let serverRes = {
513
+ }).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
514
+ var serverRes, latency;
515
+ return __generator(this, function (_a) {
516
+ switch (_a.label) {
517
+ case 0:
518
+ serverRes = {
519
+ messageId: messageId,
520
+ hasError: false,
521
+ data: res
522
+ };
523
+ this.sendWS(ws, messageDate, method, methodData, serverRes);
524
+ return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.findById(id_methodLatency)];
525
+ case 1:
526
+ latency = _a.sent();
527
+ if (latency) {
528
+ log_method_latency_collection_1.LogMethodLatencies.updateOne({ _id: id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
529
+ }
530
+ return [2 /*return*/];
531
+ }
532
+ });
533
+ }); }, function (err) {
534
+ var serverRes = {
454
535
  messageId: messageId,
455
536
  hasError: true,
456
537
  data: err
457
538
  };
458
- this.sendWS(ws, messageDate, method, methodData, serverRes);
459
- LogMethodLatencies.deleteOne({ _id: id_methodLatency });
539
+ _this.sendWS(ws, messageDate, method, methodData, serverRes);
540
+ log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
460
541
  });
461
- }
542
+ };
462
543
  // Call/run method internal (No Emit on Socket)
463
- callMethodInternal(method, ...methodData) {
464
- let that = this;
544
+ MethodManager.prototype.callMethodInternal = function (method) {
545
+ var _a;
546
+ var methodData = [];
547
+ for (var _i = 1; _i < arguments.length; _i++) {
548
+ methodData[_i - 1] = arguments[_i];
549
+ }
550
+ var that = this;
465
551
  if (!that._methods[method]) {
466
552
  console.log('No Method: ' + method);
467
553
  return null;
@@ -476,15 +562,15 @@ export class MethodManager {
476
562
  return null;
477
563
  }
478
564
  }
479
- let promise = that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData).catch(methodErrs => {
565
+ var promise = (_a = that._methods[method].function).call.apply(_a, __spreadArrays([Object.assign({}, that, MethodManager.prototype)], methodData)).catch(function (methodErrs) {
480
566
  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));
481
567
  });
482
568
  if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
483
- promise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));
569
+ promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
484
570
  }
485
571
  return promise;
486
- }
487
- sendWS(ws, messageDate, method, methodData, data) {
572
+ };
573
+ MethodManager.prototype.sendWS = function (ws, messageDate, method, methodData, data) {
488
574
  this._sendQueue.splice(0, 0, {
489
575
  id_ws: ws['id_socket'],
490
576
  method: method,
@@ -492,165 +578,64 @@ export class MethodManager {
492
578
  data: data,
493
579
  date: messageDate
494
580
  });
495
- }
496
- sendEmail(sendTo, subject, text, html, attachments, send_from) {
497
- return new Promise(async (resolve, reject) => {
498
- if ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\@resolveio\.com/))) {
499
- sendTo = 'dev@resolveio.com';
500
- }
501
- // if (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200' || sendTo.endsWith('@resolveio.com')) {
502
- this._mailer.sendMail({
503
- replyTo: undefined,
504
- from: send_from ? send_from : this.serverConfig.MAIL_FROM,
505
- to: sendTo,
506
- subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) ? '(DEV SERVER) - ' : '') + subject,
507
- text: text,
508
- html: html,
509
- attachments: attachments
510
- }, (err, info) => {
511
- if (err) {
512
- console.log(err);
513
- EmailHistories.create({
514
- _id: objectIdHexString(),
515
- __v: 0,
516
- date: new Date(),
517
- id_user: this['id_user'],
518
- user: this['user'],
519
- email: sendTo,
520
- success: false,
521
- verified: false
522
- });
581
+ };
582
+ MethodManager.prototype.sendEmail = function (sendTo, subject, text, html, attachments, send_from) {
583
+ var _this = this;
584
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
585
+ var _this = this;
586
+ return __generator(this, function (_a) {
587
+ if ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\@resolveio\.com/))) {
588
+ sendTo = 'dev@resolveio.com';
523
589
  }
524
- else {
525
- EmailHistories.create({
526
- _id: objectIdHexString(),
527
- __v: 0,
528
- date: new Date(),
529
- id_user: this['id_user'],
530
- user: this['user'],
531
- email: sendTo,
532
- success: true,
533
- verified: false
534
- });
535
- }
536
- resolve();
590
+ // if (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200' || sendTo.endsWith('@resolveio.com')) {
591
+ this._mailer.sendMail({
592
+ replyTo: undefined,
593
+ from: send_from ? send_from : this.serverConfig.MAIL_FROM,
594
+ to: sendTo,
595
+ subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) ? '(DEV SERVER) - ' : '') + subject,
596
+ text: text,
597
+ html: html,
598
+ attachments: attachments
599
+ }, function (err, info) {
600
+ if (err) {
601
+ console.log(err);
602
+ email_history_collection_1.EmailHistories.create({
603
+ _id: mongo_manager_1.objectIdHexString(),
604
+ __v: 0,
605
+ date: new Date(),
606
+ id_user: _this['id_user'],
607
+ user: _this['user'],
608
+ email: sendTo,
609
+ success: false,
610
+ verified: false
611
+ });
612
+ }
613
+ else {
614
+ email_history_collection_1.EmailHistories.create({
615
+ _id: mongo_manager_1.objectIdHexString(),
616
+ __v: 0,
617
+ date: new Date(),
618
+ id_user: _this['id_user'],
619
+ user: _this['user'],
620
+ email: sendTo,
621
+ success: true,
622
+ verified: false
623
+ });
624
+ }
625
+ resolve();
626
+ });
627
+ return [2 /*return*/];
537
628
  });
538
- // }
539
- // else {
540
- // let oldVerfication = await EmailVerifies.findOne({email: sendTo});
541
- // if (oldVerfication) {
542
- // this._mailer.sendMail({
543
- // replyTo: undefined,
544
- // from: send_from ? send_from : this.serverConfig.MAIL_FROM,
545
- // to: sendTo,
546
- // subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) ? '(DEV SERVER) - ' : '') + subject,
547
- // text: text,
548
- // html: html,
549
- // attachments: attachments
550
- // }, (err, info) => {
551
- // if (err) {
552
- // console.log(err);
553
- // EmailHistories.create({
554
- // _id: objectIdHexString(),
555
- // __v: 0,
556
- // date: new Date(),
557
- // id_user: this['id_user'],
558
- // user: this['user'],
559
- // email: sendTo,
560
- // success: false,
561
- // verified: true
562
- // });
563
- // }
564
- // else {
565
- // EmailHistories.create({
566
- // _id: objectIdHexString(),
567
- // __v: 0,
568
- // date: new Date(),
569
- // id_user: this['id_user'],
570
- // user: this['user'],
571
- // email: sendTo,
572
- // success: true,
573
- // verified: true
574
- // });
575
- // }
576
- // resolve();
577
- // });
578
- // }
579
- // else {
580
- // let verifier = new Verifier(this.serverConfig['WHOISXMLAPI']);
581
- // verifier.verify(sendTo, {hardRefresh: true}, (errVerify, resVerify) => {
582
- // if (errVerify) {
583
- // console.log(errVerify);
584
- // EmailHistories.create({
585
- // _id: objectIdHexString(),
586
- // __v: 0,
587
- // date: new Date(),
588
- // id_user: this['id_user'],
589
- // user: this['user'],
590
- // email: sendTo,
591
- // success: false,
592
- // verified: false
593
- // });
594
- // resolve();
595
- // }
596
- // else {
597
- // EmailVerifies.create({
598
- // _id: objectIdHexString(),
599
- // __v: 0,
600
- // date: new Date(),
601
- // id_user: this['id_user'],
602
- // user: this['user'],
603
- // email: sendTo
604
- // });
605
- // this._mailer.sendMail({
606
- // replyTo: undefined,
607
- // from: send_from ? send_from : this.serverConfig.MAIL_FROM,
608
- // to: sendTo,
609
- // subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) ? '(DEV SERVER) - ' : '') + subject,
610
- // text: text,
611
- // html: html,
612
- // attachments: attachments
613
- // }, (err, info) => {
614
- // if (err) {
615
- // console.log(err);
616
- // EmailHistories.create({
617
- // _id: objectIdHexString(),
618
- // __v: 0,
619
- // date: new Date(),
620
- // id_user: this['id_user'],
621
- // user: this['user'],
622
- // email: sendTo,
623
- // success: false,
624
- // verified: true
625
- // });
626
- // }
627
- // else {
628
- // EmailHistories.create({
629
- // _id: objectIdHexString(),
630
- // __v: 0,
631
- // date: new Date(),
632
- // id_user: this['id_user'],
633
- // user: this['user'],
634
- // email: sendTo,
635
- // success: true,
636
- // verified: true
637
- // });
638
- // }
639
- // resolve();
640
- // });
641
- // }
642
- // });
643
- // }
644
- // }
645
- });
646
- }
647
- getAWS() {
629
+ }); });
630
+ };
631
+ MethodManager.prototype.getAWS = function () {
648
632
  return this._aws;
649
- }
650
- readFile(fileName) {
651
- return new Promise((resolve, reject) => {
633
+ };
634
+ MethodManager.prototype.readFile = function (fileName) {
635
+ var _this = this;
636
+ return new Promise(function (resolve, reject) {
652
637
  if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
653
- fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => {
638
+ fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', function (err, res) {
654
639
  if (err) {
655
640
  reject(err);
656
641
  }
@@ -660,8 +645,8 @@ export class MethodManager {
660
645
  });
661
646
  }
662
647
  else {
663
- if (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {
664
- fs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => {
648
+ if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
649
+ fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'utf-8', function (err, res) {
665
650
  if (err) {
666
651
  reject(err);
667
652
  }
@@ -672,11 +657,12 @@ export class MethodManager {
672
657
  }
673
658
  }
674
659
  });
675
- }
676
- readImage(fileName) {
677
- return new Promise((resolve, reject) => {
660
+ };
661
+ MethodManager.prototype.readImage = function (fileName) {
662
+ var _this = this;
663
+ return new Promise(function (resolve, reject) {
678
664
  if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
679
- fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => {
665
+ fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', function (err, res) {
680
666
  if (err) {
681
667
  reject(err);
682
668
  }
@@ -686,8 +672,8 @@ export class MethodManager {
686
672
  });
687
673
  }
688
674
  else {
689
- if (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {
690
- fs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => {
675
+ if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
676
+ fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'base64', function (err, res) {
691
677
  if (err) {
692
678
  reject(err);
693
679
  }
@@ -698,7 +684,9 @@ export class MethodManager {
698
684
  }
699
685
  }
700
686
  });
701
- }
702
- }
687
+ };
688
+ return MethodManager;
689
+ }());
690
+ exports.MethodManager = MethodManager;
703
691
 
704
692
  //# sourceMappingURL=method.manager.js.map