@resolveio/server-lib 9.0.32 → 9.0.34

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