@resolveio/server-lib 7.0.4 → 7.1.0

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 (48) hide show
  1. package/client-server-app.d.ts +1 -0
  2. package/client-server-app.js +56 -0
  3. package/client-server-app.js.map +1 -0
  4. package/collections/monitor-cpu.collection.d.ts +7 -0
  5. package/collections/monitor-cpu.collection.js +56 -0
  6. package/collections/monitor-cpu.collection.js.map +1 -0
  7. package/collections/monitor-https-inbound.collection.d.ts +7 -0
  8. package/collections/monitor-https-inbound.collection.js +66 -0
  9. package/collections/monitor-https-inbound.collection.js.map +1 -0
  10. package/collections/monitor-https-outbound.collection.d.ts +7 -0
  11. package/collections/monitor-https-outbound.collection.js +72 -0
  12. package/collections/monitor-https-outbound.collection.js.map +1 -0
  13. package/collections/monitor-memory.collection.d.ts +7 -0
  14. package/collections/monitor-memory.collection.js +71 -0
  15. package/collections/monitor-memory.collection.js.map +1 -0
  16. package/collections/monitor-mongo.collection.d.ts +7 -0
  17. package/collections/monitor-mongo.collection.js +63 -0
  18. package/collections/monitor-mongo.collection.js.map +1 -0
  19. package/index.d.ts +2 -1
  20. package/index.js +4 -2
  21. package/index.js.map +1 -1
  22. package/managers/method.manager.js +2 -0
  23. package/managers/method.manager.js.map +1 -1
  24. package/managers/monitor.manager.d.ts +7 -0
  25. package/managers/monitor.manager.js +244 -0
  26. package/managers/monitor.manager.js.map +1 -0
  27. package/methods/monitor.d.ts +2 -0
  28. package/methods/monitor.js +39 -0
  29. package/methods/monitor.js.map +1 -0
  30. package/models/monitor-cpu.model.d.ts +7 -0
  31. package/models/monitor-cpu.model.js +4 -0
  32. package/models/monitor-cpu.model.js.map +1 -0
  33. package/models/monitor-https-inbound.model.d.ts +10 -0
  34. package/models/monitor-https-inbound.model.js +4 -0
  35. package/models/monitor-https-inbound.model.js.map +1 -0
  36. package/models/monitor-https-outbound.model.d.ts +11 -0
  37. package/models/monitor-https-outbound.model.js +4 -0
  38. package/models/monitor-https-outbound.model.js.map +1 -0
  39. package/models/monitor-memory.model.d.ts +11 -0
  40. package/models/monitor-memory.model.js +4 -0
  41. package/models/monitor-memory.model.js.map +1 -0
  42. package/models/monitor-mongo.model.d.ts +9 -0
  43. package/models/monitor-mongo.model.js +4 -0
  44. package/models/monitor-mongo.model.js.map +1 -0
  45. package/package.json +3 -1
  46. package/server-app.d.ts +4 -1
  47. package/server-app.js +11 -4
  48. package/server-app.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/managers/method.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAA+D;AAE/D,wCAAiD;AACjD,gDAAyD;AACzD,sCAAgD;AAChD,sCAAgD;AAChD,wDAAkE;AAClE,2BAA6B;AAC7B,uBAAyB;AACzB,uCAAyC;AAEzC,6BAA+B;AAC/B,gDAAyD;AACzD,yCAAkD;AAClD,mDAA2D;AAC3D,kDAA0D;AAC1D,0CAAmD;AAEnD,wFAA4E;AAC5E,qCAAiC;AACjC,yCAAyD;AACzD,gEAAqD;AAErD,8FAAkF;AAClF,+BAAiC;AACjC,4DAAqE;AACrE,8CAAwD;AAExD;IAaC,uBAAY,UAAU,EAAE,YAAY,EAAE,SAAS;QAA/C,iBAwOC;QAlPM,aAAQ,GAAgB,EAAE,CAAC;QAO1B,eAAU,GAAG,EAAE,CAAC;QAChB,kBAAa,GAAG,KAAK,CAAC;QAG7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,WAAW;QACX,qBAAc,EAAE,CAAC;QACjB,8BAAkB,EAAE,CAAC;QAErB,UAAU;QACV,6BAAkB,CAAC,IAAI,CAAC,CAAC;QACzB,oBAAc,CAAC,IAAI,CAAC,CAAC;QACrB,sCAAuB,CAAC,IAAI,CAAC,CAAC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AAC;IACJ,CAAC;IAEM,iCAAS,GAAhB,UAAiB,QAAQ;QAAzB,iBAyBC;QAxBA,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAClC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;gBACpE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,aAAa,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAC,GAAG,EAAE,GAAG;oBAChF,IAAI,GAAG,EAAE;wBACR,MAAM,CAAC,GAAG,CAAC,CAAC;qBACZ;yBACI;wBACJ,OAAO,CAAC,GAAG,CAAC,CAAC;qBACb;gBACF,CAAC,CAAC,CAAC;aACH;iBACI;gBACJ,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;oBACxE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAC,GAAG,EAAE,GAAG;wBACpF,IAAI,GAAG,EAAE;4BACR,MAAM,CAAC,GAAG,CAAC,CAAC;yBACZ;6BACI;4BACJ,OAAO,CAAC,GAAG,CAAC,CAAC;yBACb;oBACF,CAAC,CAAC,CAAC;iBACH;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IACF,oBAAC;AAAD,CAlrBA,AAkrBC,IAAA;AAlrBY,sCAAa","file":"method.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { loadCollectionMethods } from '../methods/collections';\nimport { MethodModel } from '../models/method.model';\nimport { loadLogMethods } from '../methods/logs';\nimport { loadCounterMethods } from '../methods/counters';\nimport { loadPDFMethods } from '../methods/pdf';\nimport { loadAWSMethods } from '../methods/aws';\nimport { loadCloudConvertMethods } from '../methods/cloudconvert';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as nodemailer from 'nodemailer';\nimport * as imap from 'imap';\nimport * as aws from 'aws-sdk';\nimport { loadAccountMethods } from '../methods/accounts';\nimport { loadServerInit } from '../fixtures/init';\nimport { loadServerCronJobs } from '../fixtures/cron-jobs';\nimport { loadCronJobMethods } from '../methods/cron-jobs';\nimport { loadFlagMethods } from '../methods/flags';\nimport { QueueMethodModel } from '../models/queue-method.model';\nimport { MethodResponses } from '../collections/method-response.collection';\nimport { Types } from 'mongoose';\nimport { deepCopy, getBinarySize } from '../util/common';\nimport { Logs } from '../collections/log.collection';\nimport ResolveIOMainServer from '../server-app';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport * as moment from 'moment';\nimport { loadReportBuilderMethods } from '../methods/report-builder';\nimport { loadSupportMethods } from '../methods/support';\n\nexport class MethodManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tpublic _methods: MethodModel = {};\n\tprivate _mailer: nodemailer.Transporter;\n\tprivate _imap: imap;\n\tprivate _aws: aws.S3;\n\tprivate serverConfig;\n\tprivate clientDir;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tconstructor(mainServer, serverConfig, clientDir) {\n\t\tthis._mainServer = mainServer;\n\t\tthis.serverConfig = serverConfig;\n\t\tthis.clientDir = clientDir;\n\n\t\t// Fixtures\n\t\tloadServerInit();\n\t\tloadServerCronJobs();\n\n\t\t// Methods\n\t\tloadAccountMethods(this);\n\t\tloadAWSMethods(this);\n\t\tloadCloudConvertMethods(this);\n\t\tloadCollectionMethods(this);\n\t\tloadCounterMethods(this);\n\t\tloadLogMethods(this);\n\t\tloadPDFMethods(this);\n\t\tloadCronJobMethods(this);\n\t\tloadFlagMethods(this);\n\t\tloadReportBuilderMethods(this);\n\t\tloadSupportMethods(this);\n\n\t\tif (mainServer.sesMail) {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\tSES: new aws.SES({\n\t\t\t\t\tapiVersion: '2010-12-01',\n\t\t\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\t\t\tregion: serverConfig.AWSSES_REGION\n\t\t\t\t})\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\thost: this.serverConfig['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server\n\t\t\t\tport: this.serverConfig['MAIL_PORT'], //587, // secure SMTP\n\t\t\t\tsecure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely\n\t\t\t\tauth: {\n\t\t\t\t\tuser: this.serverConfig['MAIL_USERNAME'],\n\t\t\t\t\tpass: this.serverConfig['MAIL_PASSWORD']\n\t\t\t\t},\n\t\t\t\ttls: {\n\t\t\t\t\tciphers: 'SSLv3'\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// this._imap = new imap({\n\t\t// \tuser: this.serverConfig['ORDERS_EMAIL'],\n\t\t// \tpassword: this.serverConfig['ORDERS_PASSWORD'],\n\t\t// \thost: this.serverConfig['ORDERS_HOST'],\n\t\t// \tport: this.serverConfig['ORDERS_PORT'],\n\t\t// \ttls: this.serverConfig['ORDERS_TLS']\n\t\t// });\n\n\t\t// let that = this;\n\n\t\t// let chemicalNames = await Chemicals.find({}).select('description').exec();\n\t\t// let jobNames = await Jobs.find({status: 'Active'}).select('well').exec();\n\n\t\t// console.log(jobNames.map(a => a.well));\n\n\t\t// this._imap.once('ready', () => {\n\t\t// \tthis._imap.openBox('INBOX', true, function(err, box) {\n\t\t// \t\tif (err) {\n\t\t// \t\t\tthrow err;\n\t\t// \t\t}\n\n\t\t// \t\tthat._imap.search([ 'NEW' ], function(err, results) {\n\n\t\t// \t\t\tconsole.log(err, results);\n\n\t\t// \t\t\tif (err || !results.length) {\n\t\t// \t\t\t\treturn that._imap.end();\n\t\t// \t\t\t}\n\n\t\t// \t\t\tlet f = that._imap.fetch(results[0], { bodies: ['HEADER.FIELDS (FROM)', 'TEXT'] });\n\t\t// \t\t\tf.on('message', function(msg, seqno) {\n\t\t// \t\t\t\t// console.log('Message #%d', seqno);\n\t\t// \t\t\t\tlet prefix = '(#' + seqno + ') ';\n\t\t// \t\t\t\tmsg.on('body', function(stream, info) {\n\t\t// \t\t\t\t\tlet buffer = '', count = 0;\n\t\t// \t\t\t\t\tstream.on('data', function(chunk) {\n\t\t// \t\t\t\t\t\tcount += chunk.length;\n\t\t// \t\t\t\t\t\tbuffer += chunk.toString('utf8');\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t\tstream.once('end', function() {\n\t\t// \t\t\t\t\t\tif (info.which === 'TEXT') {\n\t\t// \t\t\t\t\t\t\t// console.log(buffer);\n\t\t// \t\t\t\t\t\t\t// console.log(typeof(buffer));\n\t\t// \t\t\t\t\t\t\tlet lines = buffer.split('\\r\\n');\n\t\t// \t\t\t\t\t\t\t// console.log(lines);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\t\t\t// let i = 0;\n\t\t// \t\t\t\t\t\t\t// lines.forEach(line => {\n\n\t\t// \t\t\t\t\t\t\t// \tlet date: Date;\n\t\t// \t\t\t\t\t\t\t// \tlet dateString;\n\n\t\t// \t\t\t\t\t\t\t// \tif (line.includes('From')) {\n\t\t// \t\t\t\t\t\t\t// \t\tconsole.log(line);\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// \tif (!line.includes('class=3D') && !line.includes('style=3D')) {\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Well') || line.includes('Well Name') || line.includes('Job') || line.includes('Pad')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, jobNames.map(a => a.well)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Well', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Product') || line.includes('Chemical')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, chemicalNames.map(a => a.description)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Chemical', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Quantity') || line.includes('Qty') || line.includes('Amount')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Qty', line);\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Date')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Date', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tdate = moment(Date.parse(line)).toDate();\n\t\t// \t\t\t\t\t\t\t// \t\t\tdateString = line;\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Time')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Time', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(date.setTime(Date.parse(line))));\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// });\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\t\tmsg.once('attributes', function(attrs) {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));\n\t\t// \t\t\t\t});\n\n\t\t// \t\t\t\tmsg.once('end', function() {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Finished');\n\t\t// \t\t\t\t});\n\t\t// \t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\tf.once('error', function(error) {\n\t\t// \t\t\t\tconsole.log('Fetch error: ' + error);\n\t\t// \t\t\t});\n\n\t\t// \t\t\tf.once('end', function() {\n\t\t// \t\t\t\tconsole.log('Done fetching all messages!');\n\t\t// \t\t\t\tthat._imap.end();\n\t\t// \t\t\t});\n\t\t// \t\t});\n\t\t// \t});\n\t\t// });\n\n\t\t// this._imap.connect();\n\n\t\tthis._aws = new aws.S3({\n\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\tregion: serverConfig.AWSREGION\n\t\t});\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (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') {\n\t\t\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(sendItem.methodData)) < 200000 && getBinarySize(JSON.stringify(sendItem.data)) < 200000) {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: JSON.stringify([sendItem.methodData, sendItem.data], null, 2),\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\tMethodResponses.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\t\t\tmessage_id: sendItem.data.messageId,\n\t\t\t\t\t\t\t\t\t\t\tresponse: sendItem.data,\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tdate: sendItem.date\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic getMainServer() {\n\t\treturn this._mainServer;\n\t}\n\n\t// Add methods to private methods object\n\tpublic methods(method: MethodModel) {\n\t\tthis._methods = Object.assign(this._methods, method);\n\t}\n\n\tpublic callMethodCron(method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.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));\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData);\n\t}\n\n\tpublic callMethodQueue(update: QueueMethodModel) {\n\t\t// console.log('Call Method Queue', update);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet updateCopy = deepCopy(update);\n\t\t\n\t\t\tlet that = this;\n\n\t\t\tif (!that._methods[update.method]) {\n\t\t\t\tconsole.log('No Method: ' + update.method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + update.method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\treturn resolve('No Method: ' + update.method);\n\t\t\t}\n\n\t\t\tif ((update.method_data.length > 1 || update.method_data[0]) && !that._methods[update.method].skipValidation) {\n\t\t\t\tif (!that._methods[update.method].check) {\n\t\t\t\t\tconsole.error('No Check Function For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Function For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse if (!that._methods[update.method].check._schema) {\n\t\t\t\t\tconsole.error('No Check Schema For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Schema For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(that._methods[update.method].check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < update.method_data.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = update.method_data[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthat._methods[update.method].check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error('Error in Method Check (' + update.method + ')', errors);\n\n\t\t\t\t\t\t\tthat.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));\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\t\t\n\t\t\t\t\t\t\treturn resolve('Error in Method Check (' + update.method + ')');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet timeout = setTimeout(() => {\n\t\t\t\tconsole.error('Timeout on method', update);\n\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'Timeout on method: ', [update]);\n\t\t\t\tresolve('Timeout');\n\t\t\t}, 5000);\n\n\t\t\t// console.log('Run Method', update.method);\n\t\t\t\n\t\t\tthat._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).then(async (res) => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: res\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tlet latency = await LogMethodLatencies.findById(update.id_methodLatency);\n\n\t\t\t\tif (latency) {\n\t\t\t\t\tLogMethodLatencies.updateOne({_id: update.id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t\t}\n\n\t\t\t\tresolve(serverRes);\n\t\t\t}, err => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: err\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\tresolve(serverRes);\n\t\t\t});\n\t\t});\n\t}\n\n\n\n\t// Call/run method (Emit on Socket)\n\tpublic callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\t\t\t\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: 'Internal Error'\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.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));\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), ...methodData).then(async (res) => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tlet latency = await LogMethodLatencies.findById(id_methodLatency);\n\n\t\t\tif (latency) {\n\t\t\t\tLogMethodLatencies.updateOne({_id: id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t}\n\t\t}, err => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t});\n\t}\n\n\t// Call/run method internal (No Emit on Socket)\n\tpublic callMethodInternal(method, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tprivate sendWS(ws: WebSocket, messageDate: Date, method: string, methodData: any[], data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tmethod: method,\n\t\t\tmethodData: methodData,\n\t\t\tdata: data,\n\t\t\tdate: messageDate\n\t\t});\n\t}\n\n\tpublic sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\\:\\/\\/dev\\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\\@resolveio\\.com/))) {\n\t\t\t\tsendTo = 'dev@resolveio.com';\n\t\t\t}\n\n\t\t\tthis._mailer.sendMail({\n\t\t\t\treplyTo: undefined,\n\t\t\t\tfrom: send_from ? send_from : this.serverConfig.MAIL_FROM,\n\t\t\t\tto: sendTo,\n\t\t\t\tsubject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\\:\\/\\/dev\\./)) ? '(DEV SERVER) - ' : '') + subject,\n\t\t\t\ttext: text,\n\t\t\t\thtml: html,\n\t\t\t\tattachments: attachments\n\t\t\t}, (err, info) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tconsole.log(err);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic getAWS() {\n\t\treturn this._aws;\n\t}\n\n\tpublic readFile(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic readImage(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/managers/method.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAA+D;AAE/D,wCAAiD;AACjD,gDAAyD;AACzD,sCAAgD;AAChD,sCAAgD;AAChD,wDAAkE;AAClE,2BAA6B;AAC7B,uBAAyB;AACzB,uCAAyC;AAEzC,6BAA+B;AAC/B,gDAAyD;AACzD,yCAAkD;AAClD,mDAA2D;AAC3D,kDAA0D;AAC1D,0CAAmD;AAEnD,wFAA4E;AAC5E,qCAAiC;AACjC,yCAAyD;AACzD,gEAAqD;AAErD,8FAAkF;AAClF,+BAAiC;AACjC,4D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oBACxE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAC,GAAG,EAAE,GAAG;wBACpF,IAAI,GAAG,EAAE;4BACR,MAAM,CAAC,GAAG,CAAC,CAAC;yBACZ;6BACI;4BACJ,OAAO,CAAC,GAAG,CAAC,CAAC;yBACb;oBACF,CAAC,CAAC,CAAC;iBACH;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IACF,oBAAC;AAAD,CAnrBA,AAmrBC,IAAA;AAnrBY,sCAAa","file":"method.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { loadCollectionMethods } from '../methods/collections';\nimport { MethodModel } from '../models/method.model';\nimport { loadLogMethods } from '../methods/logs';\nimport { loadCounterMethods } from '../methods/counters';\nimport { loadPDFMethods } from '../methods/pdf';\nimport { loadAWSMethods } from '../methods/aws';\nimport { loadCloudConvertMethods } from '../methods/cloudconvert';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as nodemailer from 'nodemailer';\nimport * as imap from 'imap';\nimport * as aws from 'aws-sdk';\nimport { loadAccountMethods } from '../methods/accounts';\nimport { loadServerInit } from '../fixtures/init';\nimport { loadServerCronJobs } from '../fixtures/cron-jobs';\nimport { loadCronJobMethods } from '../methods/cron-jobs';\nimport { loadFlagMethods } from '../methods/flags';\nimport { QueueMethodModel } from '../models/queue-method.model';\nimport { MethodResponses } from '../collections/method-response.collection';\nimport { Types } from 'mongoose';\nimport { deepCopy, getBinarySize } from '../util/common';\nimport { Logs } from '../collections/log.collection';\nimport ResolveIOMainServer from '../server-app';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport * as moment from 'moment';\nimport { loadReportBuilderMethods } from '../methods/report-builder';\nimport { loadSupportMethods } from '../methods/support';\nimport { loadMonitorMethods } from '../methods/monitor';\n\nexport class MethodManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tpublic _methods: MethodModel = {};\n\tprivate _mailer: nodemailer.Transporter;\n\tprivate _imap: imap;\n\tprivate _aws: aws.S3;\n\tprivate serverConfig;\n\tprivate clientDir;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tconstructor(mainServer, serverConfig, clientDir) {\n\t\tthis._mainServer = mainServer;\n\t\tthis.serverConfig = serverConfig;\n\t\tthis.clientDir = clientDir;\n\n\t\t// Fixtures\n\t\tloadServerInit();\n\t\tloadServerCronJobs();\n\n\t\t// Methods\n\t\tloadAccountMethods(this);\n\t\tloadAWSMethods(this);\n\t\tloadCloudConvertMethods(this);\n\t\tloadCollectionMethods(this);\n\t\tloadCounterMethods(this);\n\t\tloadLogMethods(this);\n\t\tloadPDFMethods(this);\n\t\tloadCronJobMethods(this);\n\t\tloadFlagMethods(this);\n\t\tloadReportBuilderMethods(this);\n\t\tloadSupportMethods(this);\n\t\tloadMonitorMethods(this);\n\n\t\tif (mainServer.sesMail) {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\tSES: new aws.SES({\n\t\t\t\t\tapiVersion: '2010-12-01',\n\t\t\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\t\t\tregion: serverConfig.AWSSES_REGION\n\t\t\t\t})\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\thost: this.serverConfig['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server\n\t\t\t\tport: this.serverConfig['MAIL_PORT'], //587, // secure SMTP\n\t\t\t\tsecure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely\n\t\t\t\tauth: {\n\t\t\t\t\tuser: this.serverConfig['MAIL_USERNAME'],\n\t\t\t\t\tpass: this.serverConfig['MAIL_PASSWORD']\n\t\t\t\t},\n\t\t\t\ttls: {\n\t\t\t\t\tciphers: 'SSLv3'\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// this._imap = new imap({\n\t\t// \tuser: this.serverConfig['ORDERS_EMAIL'],\n\t\t// \tpassword: this.serverConfig['ORDERS_PASSWORD'],\n\t\t// \thost: this.serverConfig['ORDERS_HOST'],\n\t\t// \tport: this.serverConfig['ORDERS_PORT'],\n\t\t// \ttls: this.serverConfig['ORDERS_TLS']\n\t\t// });\n\n\t\t// let that = this;\n\n\t\t// let chemicalNames = await Chemicals.find({}).select('description').exec();\n\t\t// let jobNames = await Jobs.find({status: 'Active'}).select('well').exec();\n\n\t\t// console.log(jobNames.map(a => a.well));\n\n\t\t// this._imap.once('ready', () => {\n\t\t// \tthis._imap.openBox('INBOX', true, function(err, box) {\n\t\t// \t\tif (err) {\n\t\t// \t\t\tthrow err;\n\t\t// \t\t}\n\n\t\t// \t\tthat._imap.search([ 'NEW' ], function(err, results) {\n\n\t\t// \t\t\tconsole.log(err, results);\n\n\t\t// \t\t\tif (err || !results.length) {\n\t\t// \t\t\t\treturn that._imap.end();\n\t\t// \t\t\t}\n\n\t\t// \t\t\tlet f = that._imap.fetch(results[0], { bodies: ['HEADER.FIELDS (FROM)', 'TEXT'] });\n\t\t// \t\t\tf.on('message', function(msg, seqno) {\n\t\t// \t\t\t\t// console.log('Message #%d', seqno);\n\t\t// \t\t\t\tlet prefix = '(#' + seqno + ') ';\n\t\t// \t\t\t\tmsg.on('body', function(stream, info) {\n\t\t// \t\t\t\t\tlet buffer = '', count = 0;\n\t\t// \t\t\t\t\tstream.on('data', function(chunk) {\n\t\t// \t\t\t\t\t\tcount += chunk.length;\n\t\t// \t\t\t\t\t\tbuffer += chunk.toString('utf8');\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t\tstream.once('end', function() {\n\t\t// \t\t\t\t\t\tif (info.which === 'TEXT') {\n\t\t// \t\t\t\t\t\t\t// console.log(buffer);\n\t\t// \t\t\t\t\t\t\t// console.log(typeof(buffer));\n\t\t// \t\t\t\t\t\t\tlet lines = buffer.split('\\r\\n');\n\t\t// \t\t\t\t\t\t\t// console.log(lines);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\t\t\t// let i = 0;\n\t\t// \t\t\t\t\t\t\t// lines.forEach(line => {\n\n\t\t// \t\t\t\t\t\t\t// \tlet date: Date;\n\t\t// \t\t\t\t\t\t\t// \tlet dateString;\n\n\t\t// \t\t\t\t\t\t\t// \tif (line.includes('From')) {\n\t\t// \t\t\t\t\t\t\t// \t\tconsole.log(line);\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// \tif (!line.includes('class=3D') && !line.includes('style=3D')) {\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Well') || line.includes('Well Name') || line.includes('Job') || line.includes('Pad')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, jobNames.map(a => a.well)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Well', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Product') || line.includes('Chemical')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, chemicalNames.map(a => a.description)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Chemical', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Quantity') || line.includes('Qty') || line.includes('Amount')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Qty', line);\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Date')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Date', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tdate = moment(Date.parse(line)).toDate();\n\t\t// \t\t\t\t\t\t\t// \t\t\tdateString = line;\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Time')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Time', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(date.setTime(Date.parse(line))));\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// });\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\t\tmsg.once('attributes', function(attrs) {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));\n\t\t// \t\t\t\t});\n\n\t\t// \t\t\t\tmsg.once('end', function() {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Finished');\n\t\t// \t\t\t\t});\n\t\t// \t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\tf.once('error', function(error) {\n\t\t// \t\t\t\tconsole.log('Fetch error: ' + error);\n\t\t// \t\t\t});\n\n\t\t// \t\t\tf.once('end', function() {\n\t\t// \t\t\t\tconsole.log('Done fetching all messages!');\n\t\t// \t\t\t\tthat._imap.end();\n\t\t// \t\t\t});\n\t\t// \t\t});\n\t\t// \t});\n\t\t// });\n\n\t\t// this._imap.connect();\n\n\t\tthis._aws = new aws.S3({\n\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\tregion: serverConfig.AWSREGION\n\t\t});\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (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') {\n\t\t\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(sendItem.methodData)) < 200000 && getBinarySize(JSON.stringify(sendItem.data)) < 200000) {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: JSON.stringify([sendItem.methodData, sendItem.data], null, 2),\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\tMethodResponses.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\t\t\tmessage_id: sendItem.data.messageId,\n\t\t\t\t\t\t\t\t\t\t\tresponse: sendItem.data,\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tdate: sendItem.date\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic getMainServer() {\n\t\treturn this._mainServer;\n\t}\n\n\t// Add methods to private methods object\n\tpublic methods(method: MethodModel) {\n\t\tthis._methods = Object.assign(this._methods, method);\n\t}\n\n\tpublic callMethodCron(method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.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));\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData);\n\t}\n\n\tpublic callMethodQueue(update: QueueMethodModel) {\n\t\t// console.log('Call Method Queue', update);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet updateCopy = deepCopy(update);\n\t\t\n\t\t\tlet that = this;\n\n\t\t\tif (!that._methods[update.method]) {\n\t\t\t\tconsole.log('No Method: ' + update.method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + update.method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\treturn resolve('No Method: ' + update.method);\n\t\t\t}\n\n\t\t\tif ((update.method_data.length > 1 || update.method_data[0]) && !that._methods[update.method].skipValidation) {\n\t\t\t\tif (!that._methods[update.method].check) {\n\t\t\t\t\tconsole.error('No Check Function For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Function For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse if (!that._methods[update.method].check._schema) {\n\t\t\t\t\tconsole.error('No Check Schema For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Schema For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(that._methods[update.method].check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < update.method_data.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = update.method_data[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthat._methods[update.method].check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error('Error in Method Check (' + update.method + ')', errors);\n\n\t\t\t\t\t\t\tthat.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));\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\t\t\n\t\t\t\t\t\t\treturn resolve('Error in Method Check (' + update.method + ')');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet timeout = setTimeout(() => {\n\t\t\t\tconsole.error('Timeout on method', update);\n\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'Timeout on method: ', [update]);\n\t\t\t\tresolve('Timeout');\n\t\t\t}, 5000);\n\n\t\t\t// console.log('Run Method', update.method);\n\t\t\t\n\t\t\tthat._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).then(async (res) => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: res\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tlet latency = await LogMethodLatencies.findById(update.id_methodLatency);\n\n\t\t\t\tif (latency) {\n\t\t\t\t\tLogMethodLatencies.updateOne({_id: update.id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t\t}\n\n\t\t\t\tresolve(serverRes);\n\t\t\t}, err => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: err\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\tresolve(serverRes);\n\t\t\t});\n\t\t});\n\t}\n\n\n\n\t// Call/run method (Emit on Socket)\n\tpublic callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\t\t\t\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: 'Internal Error'\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.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));\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), ...methodData).then(async (res) => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tlet latency = await LogMethodLatencies.findById(id_methodLatency);\n\n\t\t\tif (latency) {\n\t\t\t\tLogMethodLatencies.updateOne({_id: id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t}\n\t\t}, err => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t});\n\t}\n\n\t// Call/run method internal (No Emit on Socket)\n\tpublic callMethodInternal(method, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tprivate sendWS(ws: WebSocket, messageDate: Date, method: string, methodData: any[], data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tmethod: method,\n\t\t\tmethodData: methodData,\n\t\t\tdata: data,\n\t\t\tdate: messageDate\n\t\t});\n\t}\n\n\tpublic sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\\:\\/\\/dev\\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\\@resolveio\\.com/))) {\n\t\t\t\tsendTo = 'dev@resolveio.com';\n\t\t\t}\n\n\t\t\tthis._mailer.sendMail({\n\t\t\t\treplyTo: undefined,\n\t\t\t\tfrom: send_from ? send_from : this.serverConfig.MAIL_FROM,\n\t\t\t\tto: sendTo,\n\t\t\t\tsubject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\\:\\/\\/dev\\./)) ? '(DEV SERVER) - ' : '') + subject,\n\t\t\t\ttext: text,\n\t\t\t\thtml: html,\n\t\t\t\tattachments: attachments\n\t\t\t}, (err, info) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tconsole.log(err);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic getAWS() {\n\t\treturn this._aws;\n\t}\n\n\tpublic readFile(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic readImage(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,7 @@
1
+ export declare class MonitorManager {
2
+ private _mainServer;
3
+ private _monitorAgent;
4
+ private _serverConfig;
5
+ constructor(mainServer: any, monitorAgent: any, serverConfig: any);
6
+ setupEvents(): void;
7
+ }
@@ -0,0 +1,244 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var bent = require("bent");
40
+ var mongoose_1 = require("mongoose");
41
+ var monitor_cpu_collection_1 = require("../collections/monitor-cpu.collection");
42
+ var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
43
+ var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
44
+ var monitor_https_outbound_collection_1 = require("../collections/monitor-https-outbound.collection");
45
+ var monitor_mongo_collection_1 = require("../collections/monitor-mongo.collection");
46
+ var MonitorManager = /** @class */ (function () {
47
+ function MonitorManager(mainServer, monitorAgent, serverConfig) {
48
+ this._mainServer = mainServer;
49
+ this._monitorAgent = monitorAgent;
50
+ this._serverConfig = serverConfig;
51
+ this.setupEvents();
52
+ }
53
+ MonitorManager.prototype.setupEvents = function () {
54
+ var _this = this;
55
+ var post = bent('https://backend.resolveio.com', 'POST', 'json', 200);
56
+ this._monitorAgent.on('initialized', function (env) {
57
+ env = _this._monitorAgent.getEnvironment();
58
+ for (var entry in env) {
59
+ console.log(entry + ':' + env[entry]);
60
+ }
61
+ ;
62
+ });
63
+ this._monitorAgent.on('cpu', function (data) { return __awaiter(_this, void 0, void 0, function () {
64
+ var response;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ if (!(this._serverConfig['ROOT_URL'] === 'https://resolveio.com')) return [3 /*break*/, 1];
69
+ monitor_cpu_collection_1.MonitorCPUs.create({
70
+ _id: mongoose_1.Types.ObjectId().toHexString(),
71
+ __v: 0,
72
+ client: this._serverConfig['CLIENT_NAME'],
73
+ date: new Date(data.time),
74
+ app: data.process,
75
+ system: data.system
76
+ });
77
+ return [3 /*break*/, 3];
78
+ case 1: return [4 /*yield*/, post('/api/monitor/cpu', {
79
+ client: this._serverConfig['CLIENT_NAME'],
80
+ date: new Date(data.time),
81
+ app: data.process,
82
+ system: data.system
83
+ })];
84
+ case 2:
85
+ response = _a.sent();
86
+ _a.label = 3;
87
+ case 3: return [2 /*return*/];
88
+ }
89
+ });
90
+ }); });
91
+ this._monitorAgent.on('memory', function (data) { return __awaiter(_this, void 0, void 0, function () {
92
+ var response;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0:
96
+ if (!(this._serverConfig['ROOT_URL'] === 'https://resolveio.com')) return [3 /*break*/, 1];
97
+ monitor_memory_collection_1.MonitorMemorys.create({
98
+ _id: mongoose_1.Types.ObjectId().toHexString(),
99
+ __v: 0,
100
+ client: this._serverConfig['CLIENT_NAME'],
101
+ date: new Date(data.time),
102
+ physical_total: data.physical_total,
103
+ physical_used: data.physical_used,
104
+ physical_free: data.physical_free,
105
+ virtual: data.virtual,
106
+ private: data.private,
107
+ physical: data.physical
108
+ });
109
+ return [3 /*break*/, 3];
110
+ case 1: return [4 /*yield*/, post('/api/monitor/memory', {
111
+ client: this._serverConfig['CLIENT_NAME'],
112
+ date: new Date(data.time),
113
+ physical_total: data.physical_total,
114
+ physical_used: data.physical_used,
115
+ physical_free: data.physical_free,
116
+ virtual: data.virtual,
117
+ private: data.private,
118
+ physical: data.physical
119
+ })];
120
+ case 2:
121
+ response = _a.sent();
122
+ _a.label = 3;
123
+ case 3: return [2 /*return*/];
124
+ }
125
+ });
126
+ }); });
127
+ this._monitorAgent.on('https', function (data) { return __awaiter(_this, void 0, void 0, function () {
128
+ var response;
129
+ return __generator(this, function (_a) {
130
+ switch (_a.label) {
131
+ case 0:
132
+ if (!(this._serverConfig['ROOT_URL'] === 'https://resolveio.com')) return [3 /*break*/, 1];
133
+ monitor_https_inbound_collection_1.MonitorHTTPSInbounds.create({
134
+ _id: mongoose_1.Types.ObjectId().toHexString(),
135
+ __v: 0,
136
+ client: this._serverConfig['CLIENT_NAME'],
137
+ date: new Date(data.time),
138
+ method: data.method,
139
+ url: data.url,
140
+ duration: data.duration,
141
+ contentType: data.contentType,
142
+ requestHeader: data.requestHeader
143
+ });
144
+ return [3 /*break*/, 3];
145
+ case 1: return [4 /*yield*/, post('/api/monitor/https-inbound', {
146
+ client: this._serverConfig['CLIENT_NAME'],
147
+ date: new Date(data.time),
148
+ method: data.method,
149
+ url: data.url,
150
+ duration: data.duration,
151
+ contentType: data.contentType,
152
+ requestHeader: data.requestHeader
153
+ })];
154
+ case 2:
155
+ response = _a.sent();
156
+ _a.label = 3;
157
+ case 3: return [2 /*return*/];
158
+ }
159
+ });
160
+ }); });
161
+ this._monitorAgent.on('https-outbound', function (data) { return __awaiter(_this, void 0, void 0, function () {
162
+ var response;
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0:
166
+ if (!(this._serverConfig['ROOT_URL'] === 'https://resolveio.com')) return [3 /*break*/, 1];
167
+ monitor_https_outbound_collection_1.MonitorHTTPSOutbounds.create({
168
+ _id: mongoose_1.Types.ObjectId().toHexString(),
169
+ __v: 0,
170
+ client: this._serverConfig['CLIENT_NAME'],
171
+ date: new Date(data.time),
172
+ method: data.method,
173
+ url: data.url,
174
+ duration: data.duration,
175
+ status: data.status,
176
+ contentType: data.contentType,
177
+ requestHeaders: data.requestHeaders
178
+ });
179
+ return [3 /*break*/, 3];
180
+ case 1: return [4 /*yield*/, post('/api/monitor/https-outbound', {
181
+ client: this._serverConfig['CLIENT_NAME'],
182
+ date: new Date(data.time),
183
+ method: data.method,
184
+ url: data.url,
185
+ duration: data.duration,
186
+ status: data.status,
187
+ contentType: data.contentType,
188
+ requestHeaders: data.requestHeaders
189
+ })];
190
+ case 2:
191
+ response = _a.sent();
192
+ _a.label = 3;
193
+ case 3: return [2 /*return*/];
194
+ }
195
+ });
196
+ }); });
197
+ this._monitorAgent.on('mongo', function (data) { return __awaiter(_this, void 0, void 0, function () {
198
+ var response;
199
+ return __generator(this, function (_a) {
200
+ switch (_a.label) {
201
+ case 0:
202
+ if (!(this._serverConfig['ROOT_URL'] === 'https://resolveio.com')) return [3 /*break*/, 1];
203
+ monitor_mongo_collection_1.MonitorMongos.create({
204
+ _id: mongoose_1.Types.ObjectId().toHexString(),
205
+ __v: 0,
206
+ client: this._serverConfig['CLIENT_NAME'],
207
+ date: new Date(data.time),
208
+ method: data.method,
209
+ doc_collection: data.collection,
210
+ duration: data.duration,
211
+ query: data.query
212
+ });
213
+ return [3 /*break*/, 3];
214
+ case 1: return [4 /*yield*/, post('/api/monitor/mongo', {
215
+ client: this._serverConfig['CLIENT_NAME'],
216
+ date: new Date(data.time),
217
+ method: data.method,
218
+ doc_collection: data.collection,
219
+ duration: data.duration,
220
+ query: data.query
221
+ })];
222
+ case 2:
223
+ response = _a.sent();
224
+ _a.label = 3;
225
+ case 3: return [2 /*return*/];
226
+ }
227
+ });
228
+ }); });
229
+ // this._monitorAgent.on('socket', async (data) => {
230
+ // if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
231
+ // }
232
+ // else {
233
+ // const response = await post('/api/monitor/socket', {
234
+ // client: this._serverConfig['CLIENT_NAME'],
235
+ // date: new Date(data.time),
236
+ // });
237
+ // }
238
+ // });
239
+ };
240
+ return MonitorManager;
241
+ }());
242
+ exports.MonitorManager = MonitorManager;
243
+
244
+ //# sourceMappingURL=monitor.manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/managers/monitor.manager.ts"],"names":[],"mappings":";;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AK,uBAAuB,CAAA,EAA1D,wBAA0D;wBAC7D,wCAAa,CAAC,MAAM,CAAC;4BACpB,GAAG,EAAE,gBAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE;4BACnC,GAAG,EAAE,CAAC;4BACN,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;4BACzC,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;4BACzB,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,cAAc,EAAE,IAAI,CAAC,UAAU;4BAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;4BACvB,KAAK,EAAE,IAAI,CAAC,KAAK;yBACjB,CAAC,CAAC;;4BAGc,qBAAM,IAAI,CAAC,oBAAoB,EAAE;4BACjD,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;4BACzC,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;4BACzB,MAAM,EAAE,IAAI,CAAC,MAAM;4BACnB,cAAc,EAAE,IAAI,CAAC,UAAU;4BAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;4BACvB,KAAK,EAAE,IAAI,CAAC,KAAK;yBACjB,CAAC,EAAA;;wBAPI,QAAQ,GAAG,SAOf;;;;;aAEH,CAAC,CAAC;QAEH,oDAAoD;QACpD,qEAAqE;QAErE,KAAK;QACL,UAAU;QACV,yDAAyD;QACzD,gDAAgD;QAChD,gCAAgC;QAEhC,QAAQ;QACR,KAAK;QACL,MAAM;IACP,CAAC;IACF,qBAAC;AAAD,CAvKA,AAuKC,IAAA;AAvKY,wCAAc","file":"monitor.manager.js","sourcesContent":["import ResolveIOMainServer from '../server-app';\nimport * as bent from 'bent';\nimport { Types } from 'mongoose';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\n\nexport class MonitorManager {\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _monitorAgent;\n\tprivate _serverConfig;\n\n\tconstructor(mainServer, monitorAgent, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorAgent = monitorAgent;\n\t\tthis._serverConfig = serverConfig;\n\n\t\tthis.setupEvents();\n\t}\n\n\tsetupEvents() {\n\t\tconst post = bent('https://backend.resolveio.com', 'POST', 'json', 200);\n\t\t\n\t\tthis._monitorAgent.on('initialized', (env) => {\n\t\t\tenv = this._monitorAgent.getEnvironment();\n\t\t\tfor (let entry in env) {\n\t\t\t\tconsole.log(entry + ':' + env[entry]);\n\t\t\t};\n\t\t});\n\t\t\n\t\tthis._monitorAgent.on('cpu', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorCPUs.create({\n\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tapp: data.process,\n\t\t\t\t\tsystem: data.system\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst response = await post('/api/monitor/cpu', {\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tapp: data.process,\n\t\t\t\t\tsystem: data.system\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('memory', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorMemorys.create({\n\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\tprivate: data.private,\n\t\t\t\t\tphysical: data.physical\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst response = await post('/api/monitor/memory', {\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\tprivate: data.private,\n\t\t\t\t\tphysical: data.physical\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorHTTPSInbounds.create({\n\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst response = await post('/api/monitor/https-inbound', {\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https-outbound', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorHTTPSOutbounds.create({\n\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tstatus: data.status,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst response = await post('/api/monitor/https-outbound', {\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tstatus: data.status,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('mongo', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorMongos.create({\n\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tquery: data.query\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst response = await post('/api/monitor/mongo', {\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tquery: data.query\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// this._monitorAgent.on('socket', async (data) => {\n\t\t// \tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\n\t\t// \t}\n\t\t// \telse {\n\t\t// \t\tconst response = await post('/api/monitor/socket', {\n\t\t// \t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t// \t\t\tdate: new Date(data.time),\n\t\t\t\t\t\n\t\t// \t\t});\n\t\t// \t}\n\t\t// });\n\t}\n}"]}
@@ -0,0 +1,2 @@
1
+ import { MethodManager } from '../managers/method.manager';
2
+ export declare function loadMonitorMethods(methodManager: MethodManager): void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var monitor_mongo_collection_1 = require("../collections/monitor-mongo.collection");
4
+ var monitor_cpu_collection_1 = require("../collections/monitor-cpu.collection");
5
+ var monitor_https_outbound_collection_1 = require("../collections/monitor-https-outbound.collection");
6
+ var monitor_https_inbound_collection_1 = require("../collections/monitor-https-inbound.collection");
7
+ var monitor_memory_collection_1 = require("../collections/monitor-memory.collection");
8
+ function loadMonitorMethods(methodManager) {
9
+ methodManager.methods({
10
+ monitorMongos: {
11
+ function: function () {
12
+ return monitor_mongo_collection_1.MonitorMongos.find().exec();
13
+ }
14
+ },
15
+ monitorCPUs: {
16
+ function: function () {
17
+ return monitor_cpu_collection_1.MonitorCPUs.find().exec();
18
+ }
19
+ },
20
+ monitorMemorys: {
21
+ function: function () {
22
+ return monitor_memory_collection_1.MonitorMemorys.find().exec();
23
+ }
24
+ },
25
+ monitorHTTPSOutbounds: {
26
+ function: function () {
27
+ return monitor_https_outbound_collection_1.MonitorHTTPSOutbounds.find().exec();
28
+ }
29
+ },
30
+ monitorHTTPSInbounds: {
31
+ function: function () {
32
+ return monitor_https_inbound_collection_1.MonitorHTTPSInbounds.find().exec();
33
+ }
34
+ },
35
+ });
36
+ }
37
+ exports.loadMonitorMethods = loadMonitorMethods;
38
+
39
+ //# sourceMappingURL=monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/methods/monitor.ts"],"names":[],"mappings":";;AACA,oFAAwE;AACxE,gFAAoE;AACpE,sGAAyF;AACzF,oGAAuF;AACvF,sFAA0E;AAE1E,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACf,aAAa,EAAE;YACX,QAAQ,EAAE;gBACN,OAAO,wCAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACvC,CAAC;SACJ;QACD,WAAW,EAAE;YACT,QAAQ,EAAE;gBACN,OAAO,oCAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACrC,CAAC;SACJ;QACD,cAAc,EAAE;YACZ,QAAQ,EAAE;gBACN,OAAO,0CAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,CAAC;SACJ;QACD,qBAAqB,EAAE;YACnB,QAAQ,EAAE;gBACN,OAAO,yDAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/C,CAAC;SACJ;QACD,oBAAoB,EAAE;YAClB,QAAQ,EAAE;gBACN,OAAO,uDAAoB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC9C,CAAC;SACJ;KACP,CAAC,CAAC;AACJ,CAAC;AA5BD,gDA4BC","file":"monitor.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\n\nexport function loadMonitorMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n monitorMongos: {\n function: function() {\n return MonitorMongos.find().exec();\n }\n },\n monitorCPUs: {\n function: function() {\n return MonitorCPUs.find().exec();\n }\n },\n monitorMemorys: {\n function: function() {\n return MonitorMemorys.find().exec();\n }\n },\n monitorHTTPSOutbounds: {\n function: function() {\n return MonitorHTTPSOutbounds.find().exec();\n }\n },\n monitorHTTPSInbounds: {\n function: function() {\n return MonitorHTTPSInbounds.find().exec();\n }\n },\n\t});\n}"]}
@@ -0,0 +1,7 @@
1
+ import { CollectionDocument } from './collection-document.model';
2
+ export interface MonitorCPUModel extends CollectionDocument {
3
+ client: string;
4
+ date: Date;
5
+ app: number;
6
+ system: number;
7
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+
4
+ //# sourceMappingURL=monitor-cpu.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/models/monitor-cpu.model.ts"],"names":[],"mappings":"","file":"monitor-cpu.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorCPUModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tapp: number;\n\tsystem: number;\n}"]}
@@ -0,0 +1,10 @@
1
+ import { CollectionDocument } from './collection-document.model';
2
+ export interface MonitorHTTPSInboundModel extends CollectionDocument {
3
+ client: string;
4
+ date: Date;
5
+ method: string;
6
+ url: string;
7
+ duration: number;
8
+ contentType: string;
9
+ requestHeader: string;
10
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+
4
+ //# sourceMappingURL=monitor-https-inbound.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/models/monitor-https-inbound.model.ts"],"names":[],"mappings":"","file":"monitor-https-inbound.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorHTTPSInboundModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\turl: string;\n\tduration: number;\n\tcontentType: string;\n\trequestHeader: string;\n}"]}