@resolveio/server-lib 20.11.12 → 20.11.14
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.
- package/managers/cron.manager.d.ts +2 -0
- package/managers/cron.manager.js +23 -3
- package/managers/cron.manager.js.map +1 -1
- package/methods/collections.js +3 -0
- package/methods/collections.js.map +1 -1
- package/package.json +1 -1
- package/resolveio-server-app.d.ts +3 -0
- package/resolveio-server-app.js +109 -2
- package/resolveio-server-app.js.map +1 -1
- package/server-app.d.ts +5 -0
- package/server-app.js +142 -12
- package/server-app.js.map +1 -1
package/managers/cron.manager.js
CHANGED
|
@@ -403,7 +403,7 @@ var CronManager = /** @class */ (function () {
|
|
|
403
403
|
return __generator(this, function (_a) {
|
|
404
404
|
switch (_a.label) {
|
|
405
405
|
case 0:
|
|
406
|
-
console.log(new Date(), 'Cron Timeout',
|
|
406
|
+
console.log(new Date(), 'Cron Timeout', this.safeStringify(cron));
|
|
407
407
|
if (!res.repeat) return [3 /*break*/, 2];
|
|
408
408
|
nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);
|
|
409
409
|
cronHistory_1.date_next = nextDate;
|
|
@@ -445,8 +445,8 @@ var CronManager = /** @class */ (function () {
|
|
|
445
445
|
case 11: return [3 /*break*/, 18];
|
|
446
446
|
case 12:
|
|
447
447
|
err_1 = _a.sent();
|
|
448
|
-
console.log(new Date(), 'Cron Error',
|
|
449
|
-
cronHistory_1.error =
|
|
448
|
+
console.log(new Date(), 'Cron Error', this.safeStringify(err_1));
|
|
449
|
+
cronHistory_1.error = this.safeStringify(err_1);
|
|
450
450
|
cronHistory_1.passed = false;
|
|
451
451
|
if (!res.repeat) return [3 /*break*/, 14];
|
|
452
452
|
nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);
|
|
@@ -491,6 +491,26 @@ var CronManager = /** @class */ (function () {
|
|
|
491
491
|
});
|
|
492
492
|
});
|
|
493
493
|
};
|
|
494
|
+
CronManager.prototype.safeStringify = function (obj) {
|
|
495
|
+
try {
|
|
496
|
+
return JSON.stringify(obj, this.getCircularReplacer(), 2);
|
|
497
|
+
}
|
|
498
|
+
catch (e) {
|
|
499
|
+
return "Error stringifying object: ".concat(e.message);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
CronManager.prototype.getCircularReplacer = function () {
|
|
503
|
+
var seen = new WeakSet();
|
|
504
|
+
return function (key, value) {
|
|
505
|
+
if (typeof value === 'object' && value !== null) {
|
|
506
|
+
if (seen.has(value)) {
|
|
507
|
+
return '[Circular]';
|
|
508
|
+
}
|
|
509
|
+
seen.add(value);
|
|
510
|
+
}
|
|
511
|
+
return value;
|
|
512
|
+
};
|
|
513
|
+
};
|
|
494
514
|
return CronManager;
|
|
495
515
|
}());
|
|
496
516
|
exports.CronManager = CronManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/cron.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0FAA8E;AAC9E,0EAA8D;AAC9D,qCAA8C;AAG9C,gEAA0D;AAC1D,yCAAmD;AAEnD;IAKC;QAFQ,UAAK,GAAmB,EAAE,CAAC;IAEpB,CAAC;IAET,kBAAM,GAAb;QAAA,iBAIC;QAHA,IAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QACtC,YAAY,CAAC;;wBAAY,qBAAM,WAAW,CAAC,UAAU,EAAE,EAAA;wBAA9B,sBAAA,SAA8B,EAAA;;iBAAA,CAAC,CAAC;QACzD,OAAO,WAAW,CAAC;IACpB,CAAC;IAEa,gCAAU,GAAxB;;;;;wBACC,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAc,EAAE,CAAC;wBACzC,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;wBAAvB,SAAuB,CAAC;;;;;KACxB;IAEa,gCAAU,GAAxB;;;;;;;;6BACK,CAAA,IAAI,CAAC,YAAY,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AAK,EAAE,aAAW,CAAC,KAAK;gCACxB,QAAQ,EAAE,IAAI,IAAI,EAAE;gCACpB,SAAS,EAAE,aAAW,CAAC,SAAS;6BAChC,EAAC,CAAC,EAAA;;wBANH,SAMG,CAAC;;;;;;KAEL;IACF,kBAAC;AAAD,CAvRA,AAuRC,IAAA;AAvRY,kCAAW","file":"cron.manager.js","sourcesContent":["import { ChangeStream, ChangeStreamDocument } from 'mongodb';\nimport { CronJobHistories } from '../collections/cron-job-history.collection';\nimport { CronJobs } from '../collections/cron-job.collection';\nimport { CronJobManager } from '../cron/cron';\nimport { CronJobHistoryModel } from '../models/cron-job-history.model';\nimport { CronJobModel } from '../models/cron-job.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport class CronManager {\n\tprivate _cronManager: CronJobManager;\n\tprivate _watchCrons$: ChangeStream;\n\tprivate _jobs: CronJobModel[] = [];\n\n\tconstructor() {}\n\n\tstatic create() {\n\t\tconst cronManager = new CronManager();\n\t\tsetImmediate(async () => await cronManager.initialize());\n\t\treturn cronManager;\n\t}\n\n\tprivate async initialize() {\n\t\tthis._cronManager = new CronJobManager();\n\t\tawait this.watchCrons();\n\t}\n\n\tprivate async watchCrons() {\n\t\tif (this._watchCrons$ && !this._watchCrons$.closed) {\n\t\t\tthis._watchCrons$.removeAllListeners();\n\t\t\tawait this._watchCrons$.close();\n\t\t\tthis._watchCrons$ = null;\n\t\t}\n\t\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\t\n\t\tif (!this._watchCrons$ || this._watchCrons$.closed) {\t\t\t\n\t\t\tlet res = await CronJobs.find();\n\t\t\tthis._jobs = res;\n\n\t\t\tfor (let job of this._jobs) {\n\t\t\t\tawait this.addCronJob(job);\n\t\t\t\tif (job.running) {\n\t\t\t\t\tawait CronJobs.updateOne({_id: job._id}, {$set: {running: false}});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._watchCrons$ = CronJobs.watchCollection([], {fullDocument: 'updateLookup'});\n\n\t\t\tthis._watchCrons$.on('change', async (doc: ChangeStreamDocument<CronJobModel>) => {\n\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\tif (doc.fullDocument) {\n\t\t\t\t\t\tif (!this._jobs.some(a => a._id === <any>doc.documentKey['_id'])) {\n\t\t\t\t\t\t\tthis._jobs.push(doc.fullDocument);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait this.addCronJob(doc.fullDocument);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'replace' || doc.operationType === 'update') {\n\t\t\t\t\tif (doc.fullDocument) {\n\t\t\t\t\t\tlet oldDoc = this._jobs.find(a => a._id === <any>doc.documentKey['_id']);\n\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\tthis._jobs.splice(this._jobs.map(a => a._id).indexOf(<any>doc.documentKey['_id']), 1, doc.fullDocument);\n\n\t\t\t\t\t\t\tif (oldDoc.name !== doc.fullDocument.name) {\n\t\t\t\t\t\t\t\tawait this.removeCronJob(oldDoc.name);\n\t\t\t\t\t\t\t\tawait this.addCronJob(doc.fullDocument);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (typeof oldDoc.time_to_run !== typeof doc.fullDocument.time_to_run || (typeof oldDoc.time_to_run === 'string' && oldDoc.time_to_run !== doc.fullDocument.time_to_run) ||\n\t\t\t\t\t\t\t\t(oldDoc.time_to_run instanceof Date && oldDoc.time_to_run.getTime() !== (<Date>doc.fullDocument.time_to_run).getTime()) || \n\t\t\t\t\t\t\t\toldDoc.timezone !== doc.fullDocument.timezone\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tawait this.updateCronJob(doc.fullDocument);\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._jobs.push(doc.fullDocument);\n\t\t\t\t\t\t\tawait this.addCronJob(doc.fullDocument);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (this._jobs.some(a => a._id === <any>doc.documentKey['_id'])) {\n\t\t\t\t\t\t\tlet job = this._jobs.find(a => a._id === <any>doc.documentKey['_id']);\n\t\t\t\t\t\t\tawait this.removeCronJob(job.name);\n\t\t\t\t\t\t\tthis._jobs.splice(this._jobs.map(a => a._id).indexOf(<any>doc.documentKey['_id']), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\tif (this._jobs.some(a => a._id === (<any>doc).documentKey['_id'])) {\n\t\t\t\t\t\tlet job = this._jobs.find(a => a._id === <any>doc.documentKey['_id']);\n\t\t\t\t\t\tawait this.removeCronJob(job.name);\n\t\t\t\t\t\tthis._jobs.splice(this._jobs.map(a => a._id).indexOf(<any>doc.documentKey['_id']), 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.on('error', async () => {\n\t\t\t\tawait this._watchCrons$.close();\n\t\t\t})\n\t\t\t.on('end', async () => {\n\t\t\t\tawait this._watchCrons$.close();\n\t\t\t})\n\t\t\t.on('close', async () => {\n\t\t\t\tthis._watchCrons$.removeAllListeners();\n\t\t\t\tthis._watchCrons$ = null;\n\t\t\t\tawait this.watchCrons();\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate doesCronJobExist(cron: CronJobModel) {\n\t\treturn this._cronManager.exists(cron.name);\n\t}\n\n\tprivate doesCronJobNameExist(cron_name: string) {\n\t\treturn this._cronManager.exists(cron_name);\n\t}\n\n\tprivate async addCronJob(cron: CronJobModel) {\n\t\tif (!this.doesCronJobExist(cron)) {\n\t\t\ttry {\n\t\t\t\tawait this._cronManager.add(\n\t\t\t\t\tcron.name,\n\t\t\t\t\tcron.time_to_run,\n\t\t\t\t\t() => this.runCronJob(cron),\n\t\t\t\t\tnull,\n\t\t\t\t\ttrue,\n\t\t\t\t\tcron.timezone,\n\t\t\t\t\tnull, \n\t\t\t\t\tfalse\n\t\t\t\t);\n\n\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(cron.name).nextDate()['ts']);\n\n\t\t\t\tif (cron.running || (nextDate && !cron.next_run || nextDate.getTime() !== cron.next_run.getTime())) {\n\t\t\t\t\tawait CronJobs.updateOne({_id: cron._id}, {$set: {running: false, next_run: nextDate || null}});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(e) {\n\t\t\t\tconsole.log('Cron error', e);\n\n\t\t\t\tif (cron.time_to_run instanceof Date) {\n\t\t\t\t\tawait this.runCronJob(cron);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async updateCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tawait this._cronManager.update(cron.name, cron.time_to_run, () => this.runCronJob(cron), null, true, cron.timezone);\n\n\t\t\tlet nextDate = new Date(this._cronManager.getJob(cron.name).nextDate()['ts']);\n\n\t\t\tif (nextDate && (!cron.next_run || nextDate.getTime() !== cron.next_run.getTime())) {\n\t\t\t\tawait CronJobs.updateOne({_id: cron._id}, {$set: {next_run: nextDate}});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async removeCronJob(cron_name: string) {\n\t\tif (this.doesCronJobNameExist(cron_name)) {\n\t\t\tawait this._cronManager.delete(cron_name);\n\t\t}\n\t}\n\n\tprivate startCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tthis._cronManager.start(cron.name);\n\t\t}\n\t}\n\n\tprivate async stopCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tawait this._cronManager.stop(cron.name);\n\t\t}\n\t}\n\n\tprivate async stopAllCronJobs() {\n\t\tawait this._cronManager.stopAll();\n\t}\n\n\tprivate async runCronJob(cron: CronJobModel) {\n\t\tlet now = new Date();\n\n\t\tlet res = await CronJobs.findOneAndUpdate({\n\t\t\t$and: [\n\t\t\t\t{_id: cron._id},\n\t\t\t\t{running: false},\n\t\t\t\t{\n\t\t\t\t\t$or: [\n\t\t\t\t\t\t{next_run: {$exists: false}},\n\t\t\t\t\t\t{next_run: null},\n\t\t\t\t\t\t{next_run: {$lte: now}}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t}, {$set: {running: true}});\n\t\t\t\n\t\tif (res) {\n\t\t\tlet cronHistory: CronJobHistoryModel = {\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\tname: res.name,\n\t\t\t\treoccuring: res.repeat,\n\t\t\t\ttime_to_run: res.time_to_run,\n\t\t\t\tmethod_name: res.method_run,\n\t\t\t\tid_cronjob: res._id,\n\t\t\t\tserver_restart: true,\n\t\t\t\tpassed: true,\n\t\t\t\terror: '',\n\t\t\t\tdate_scheduled: res.next_run,\n\t\t\t\tdate_start: new Date(),\n\t\t\t\tdate_end: null,\n\t\t\t\tdate_next: null\n\t\t\t};\n\t\t\t\n\t\t\tawait CronJobHistories.create(cronHistory);\n\n\t\t\tlet timeoutHandle = setTimeout(async () => {\n\t\t\t\tconsole.log(new Date(), 'Cron Timeout', JSON.stringify(cron, null, 2));\n\n\t\t\t\tif (res.repeat) {\n\t\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);\n\t\t\t\t\tcronHistory.date_next = nextDate;\n\t\t\t\t\tawait CronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tawait CronJobs.deleteOne({_id: res._id});\n\t\t\t\t}\n\t\t\t}, 5 * 60 * 1000); // 5 minutes in milliseconds\n\n\t\t\ttry {\n\t\t\t\tif (res.method_run_data) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_run, res.method_run_data);\t\n\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_run);\n\t\t\t\t}\n\n\t\t\t\tif (res.method_complete) {\n\t\t\t\t\tif (res.method_complete_data) {\n\t\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_complete, res.method_complete_data);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_complete);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tconsole.log(new Date(), 'Cron Error', JSON.stringify(err, null, 2));\n\t\t\t\tcronHistory.error = JSON.stringify(err, null, 2);\n\t\t\t\tcronHistory.passed = false;\n\n\t\t\t\tif (res.repeat) {\n\t\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);\n\t\t\t\t\tcronHistory.date_next = nextDate;\n\t\t\t\t\tawait CronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tawait CronJobs.deleteOne({_id: res._id});\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\t// Clear the timeout if the job completes or fails before the timeout\n\t\t\t\tclearTimeout(timeoutHandle);\n\t\t\t}\n\n\t\t\tif (res.repeat) {\n\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);\n\t\t\t\tcronHistory.date_next = nextDate;\n\t\t\t\tawait CronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t} \n\t\t\telse {\n\t\t\t\tawait CronJobs.deleteOne({_id: res._id});\n\t\t\t}\n\n\t\t\tawait CronJobHistories.updateOne({_id: cronHistory._id}, {$set: {\n\t\t\t\tserver_restart: false,\n\t\t\t\tpassed: cronHistory.passed,\n\t\t\t\terror: cronHistory.error,\n\t\t\t\tdate_end: new Date(),\n\t\t\t\tdate_next: cronHistory.date_next\n\t\t\t}});\n\t\t}\n\t}\n}"]}
|
|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BACA,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EACnB,CAAC;oBACA,OAAO,YAAY,CAAC;gBACrB,CAAC;gBACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC,CAAC;IACH,CAAC;IACF,kBAAC;AAAD,CApTA,AAoTC,IAAA;AApTY,kCAAW","file":"cron.manager.js","sourcesContent":["import { ChangeStream, ChangeStreamDocument } from 'mongodb';\nimport { CronJobHistories } from '../collections/cron-job-history.collection';\nimport { CronJobs } from '../collections/cron-job.collection';\nimport { CronJobManager } from '../cron/cron';\nimport { CronJobHistoryModel } from '../models/cron-job-history.model';\nimport { CronJobModel } from '../models/cron-job.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport class CronManager {\n\tprivate _cronManager: CronJobManager;\n\tprivate _watchCrons$: ChangeStream;\n\tprivate _jobs: CronJobModel[] = [];\n\n\tconstructor() {}\n\n\tstatic create() {\n\t\tconst cronManager = new CronManager();\n\t\tsetImmediate(async () => await cronManager.initialize());\n\t\treturn cronManager;\n\t}\n\n\tprivate async initialize() {\n\t\tthis._cronManager = new CronJobManager();\n\t\tawait this.watchCrons();\n\t}\n\n\tprivate async watchCrons() {\n\t\tif (this._watchCrons$ && !this._watchCrons$.closed) {\n\t\t\tthis._watchCrons$.removeAllListeners();\n\t\t\tawait this._watchCrons$.close();\n\t\t\tthis._watchCrons$ = null;\n\t\t}\n\t\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\t\n\t\tif (!this._watchCrons$ || this._watchCrons$.closed) {\t\t\t\n\t\t\tlet res = await CronJobs.find();\n\t\t\tthis._jobs = res;\n\n\t\t\tfor (let job of this._jobs) {\n\t\t\t\tawait this.addCronJob(job);\n\t\t\t\tif (job.running) {\n\t\t\t\t\tawait CronJobs.updateOne({_id: job._id}, {$set: {running: false}});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._watchCrons$ = CronJobs.watchCollection([], {fullDocument: 'updateLookup'});\n\n\t\t\tthis._watchCrons$.on('change', async (doc: ChangeStreamDocument<CronJobModel>) => {\n\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\tif (doc.fullDocument) {\n\t\t\t\t\t\tif (!this._jobs.some(a => a._id === <any>doc.documentKey['_id'])) {\n\t\t\t\t\t\t\tthis._jobs.push(doc.fullDocument);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait this.addCronJob(doc.fullDocument);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'replace' || doc.operationType === 'update') {\n\t\t\t\t\tif (doc.fullDocument) {\n\t\t\t\t\t\tlet oldDoc = this._jobs.find(a => a._id === <any>doc.documentKey['_id']);\n\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\tthis._jobs.splice(this._jobs.map(a => a._id).indexOf(<any>doc.documentKey['_id']), 1, doc.fullDocument);\n\n\t\t\t\t\t\t\tif (oldDoc.name !== doc.fullDocument.name) {\n\t\t\t\t\t\t\t\tawait this.removeCronJob(oldDoc.name);\n\t\t\t\t\t\t\t\tawait this.addCronJob(doc.fullDocument);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (typeof oldDoc.time_to_run !== typeof doc.fullDocument.time_to_run || (typeof oldDoc.time_to_run === 'string' && oldDoc.time_to_run !== doc.fullDocument.time_to_run) ||\n\t\t\t\t\t\t\t\t(oldDoc.time_to_run instanceof Date && oldDoc.time_to_run.getTime() !== (<Date>doc.fullDocument.time_to_run).getTime()) || \n\t\t\t\t\t\t\t\toldDoc.timezone !== doc.fullDocument.timezone\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tawait this.updateCronJob(doc.fullDocument);\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._jobs.push(doc.fullDocument);\n\t\t\t\t\t\t\tawait this.addCronJob(doc.fullDocument);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (this._jobs.some(a => a._id === <any>doc.documentKey['_id'])) {\n\t\t\t\t\t\t\tlet job = this._jobs.find(a => a._id === <any>doc.documentKey['_id']);\n\t\t\t\t\t\t\tawait this.removeCronJob(job.name);\n\t\t\t\t\t\t\tthis._jobs.splice(this._jobs.map(a => a._id).indexOf(<any>doc.documentKey['_id']), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\tif (this._jobs.some(a => a._id === (<any>doc).documentKey['_id'])) {\n\t\t\t\t\t\tlet job = this._jobs.find(a => a._id === <any>doc.documentKey['_id']);\n\t\t\t\t\t\tawait this.removeCronJob(job.name);\n\t\t\t\t\t\tthis._jobs.splice(this._jobs.map(a => a._id).indexOf(<any>doc.documentKey['_id']), 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.on('error', async () => {\n\t\t\t\tawait this._watchCrons$.close();\n\t\t\t})\n\t\t\t.on('end', async () => {\n\t\t\t\tawait this._watchCrons$.close();\n\t\t\t})\n\t\t\t.on('close', async () => {\n\t\t\t\tthis._watchCrons$.removeAllListeners();\n\t\t\t\tthis._watchCrons$ = null;\n\t\t\t\tawait this.watchCrons();\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate doesCronJobExist(cron: CronJobModel) {\n\t\treturn this._cronManager.exists(cron.name);\n\t}\n\n\tprivate doesCronJobNameExist(cron_name: string) {\n\t\treturn this._cronManager.exists(cron_name);\n\t}\n\n\tprivate async addCronJob(cron: CronJobModel) {\n\t\tif (!this.doesCronJobExist(cron)) {\n\t\t\ttry {\n\t\t\t\tawait this._cronManager.add(\n\t\t\t\t\tcron.name,\n\t\t\t\t\tcron.time_to_run,\n\t\t\t\t\t() => this.runCronJob(cron),\n\t\t\t\t\tnull,\n\t\t\t\t\ttrue,\n\t\t\t\t\tcron.timezone,\n\t\t\t\t\tnull, \n\t\t\t\t\tfalse\n\t\t\t\t);\n\n\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(cron.name).nextDate()['ts']);\n\n\t\t\t\tif (cron.running || (nextDate && !cron.next_run || nextDate.getTime() !== cron.next_run.getTime())) {\n\t\t\t\t\tawait CronJobs.updateOne({_id: cron._id}, {$set: {running: false, next_run: nextDate || null}});\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(e) {\n\t\t\t\tconsole.log('Cron error', e);\n\n\t\t\t\tif (cron.time_to_run instanceof Date) {\n\t\t\t\t\tawait this.runCronJob(cron);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async updateCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tawait this._cronManager.update(cron.name, cron.time_to_run, () => this.runCronJob(cron), null, true, cron.timezone);\n\n\t\t\tlet nextDate = new Date(this._cronManager.getJob(cron.name).nextDate()['ts']);\n\n\t\t\tif (nextDate && (!cron.next_run || nextDate.getTime() !== cron.next_run.getTime())) {\n\t\t\t\tawait CronJobs.updateOne({_id: cron._id}, {$set: {next_run: nextDate}});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async removeCronJob(cron_name: string) {\n\t\tif (this.doesCronJobNameExist(cron_name)) {\n\t\t\tawait this._cronManager.delete(cron_name);\n\t\t}\n\t}\n\n\tprivate startCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tthis._cronManager.start(cron.name);\n\t\t}\n\t}\n\n\tprivate async stopCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tawait this._cronManager.stop(cron.name);\n\t\t}\n\t}\n\n\tprivate async stopAllCronJobs() {\n\t\tawait this._cronManager.stopAll();\n\t}\n\n\tprivate async runCronJob(cron: CronJobModel) {\n\t\tlet now = new Date();\n\n\t\tlet res = await CronJobs.findOneAndUpdate({\n\t\t\t$and: [\n\t\t\t\t{_id: cron._id},\n\t\t\t\t{running: false},\n\t\t\t\t{\n\t\t\t\t\t$or: [\n\t\t\t\t\t\t{next_run: {$exists: false}},\n\t\t\t\t\t\t{next_run: null},\n\t\t\t\t\t\t{next_run: {$lte: now}}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t}, {$set: {running: true}});\n\t\t\t\n\t\tif (res) {\n\t\t\tlet cronHistory: CronJobHistoryModel = {\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\tname: res.name,\n\t\t\t\treoccuring: res.repeat,\n\t\t\t\ttime_to_run: res.time_to_run,\n\t\t\t\tmethod_name: res.method_run,\n\t\t\t\tid_cronjob: res._id,\n\t\t\t\tserver_restart: true,\n\t\t\t\tpassed: true,\n\t\t\t\terror: '',\n\t\t\t\tdate_scheduled: res.next_run,\n\t\t\t\tdate_start: new Date(),\n\t\t\t\tdate_end: null,\n\t\t\t\tdate_next: null\n\t\t\t};\n\t\t\t\n\t\t\tawait CronJobHistories.create(cronHistory);\n\n\t\t\tlet timeoutHandle = setTimeout(async () => {\n\t\t\t\tconsole.log(new Date(), 'Cron Timeout', this.safeStringify(cron));\n\n\t\t\t\tif (res.repeat) {\n\t\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);\n\t\t\t\t\tcronHistory.date_next = nextDate;\n\t\t\t\t\tawait CronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tawait CronJobs.deleteOne({_id: res._id});\n\t\t\t\t}\n\t\t\t}, 5 * 60 * 1000); // 5 minutes in milliseconds\n\n\t\t\ttry {\n\t\t\t\tif (res.method_run_data) {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_run, res.method_run_data);\t\n\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_run);\n\t\t\t\t}\n\n\t\t\t\tif (res.method_complete) {\n\t\t\t\t\tif (res.method_complete_data) {\n\t\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_complete, res.method_complete_data);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().callMethodCron(res.method_complete);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tconsole.log(new Date(), 'Cron Error', this.safeStringify(err));\n\t\t\t\tcronHistory.error = this.safeStringify(err);\n\t\t\t\tcronHistory.passed = false;\n\n\t\t\t\tif (res.repeat) {\n\t\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);\n\t\t\t\t\tcronHistory.date_next = nextDate;\n\t\t\t\t\tawait CronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tawait CronJobs.deleteOne({_id: res._id});\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\t// Clear the timeout if the job completes or fails before the timeout\n\t\t\t\tclearTimeout(timeoutHandle);\n\t\t\t}\n\n\t\t\tif (res.repeat) {\n\t\t\t\tlet nextDate = new Date(this._cronManager.getJob(res.name).nextDate()['ts']);\n\t\t\t\tcronHistory.date_next = nextDate;\n\t\t\t\tawait CronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t} \n\t\t\telse {\n\t\t\t\tawait CronJobs.deleteOne({_id: res._id});\n\t\t\t}\n\n\t\t\tawait CronJobHistories.updateOne({_id: cronHistory._id}, {$set: {\n\t\t\t\tserver_restart: false,\n\t\t\t\tpassed: cronHistory.passed,\n\t\t\t\terror: cronHistory.error,\n\t\t\t\tdate_end: new Date(),\n\t\t\t\tdate_next: cronHistory.date_next\n\t\t\t}});\n\t\t}\n\t}\n\n\tprivate safeStringify(obj: unknown)\n\t{\n\t\ttry\n\t\t{\n\t\t\treturn JSON.stringify(obj, this.getCircularReplacer(), 2);\n\t\t}\n\t\tcatch (e)\n\t\t{\n\t\t\treturn `Error stringifying object: ${e.message}`;\n\t\t}\n\t}\n\n\tprivate getCircularReplacer()\n\t{\n\t\tconst seen = new WeakSet();\n\t\treturn (key, value) =>\n\t\t{\n\t\t\tif (typeof value === 'object' && value !== null)\n\t\t\t{\n\t\t\t\tif (seen.has(value))\n\t\t\t\t{\n\t\t\t\t\treturn '[Circular]';\n\t\t\t\t}\n\t\t\t\tseen.add(value);\n\t\t\t}\n\t\t\treturn value;\n\t\t};\n\t}\n}\n"]}
|
package/methods/collections.js
CHANGED
|
@@ -55,6 +55,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
55
55
|
},
|
|
56
56
|
// Query database for any collection and query
|
|
57
57
|
findOne: {
|
|
58
|
+
bypassSession: true,
|
|
58
59
|
check: new simpl_schema_1.default({
|
|
59
60
|
collection: {
|
|
60
61
|
type: String
|
|
@@ -73,6 +74,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
73
74
|
}
|
|
74
75
|
},
|
|
75
76
|
find: {
|
|
77
|
+
bypassSession: true,
|
|
76
78
|
check: new simpl_schema_1.default({
|
|
77
79
|
collection: {
|
|
78
80
|
type: String
|
|
@@ -97,6 +99,7 @@ function loadCollectionMethods(methodManager) {
|
|
|
97
99
|
}
|
|
98
100
|
},
|
|
99
101
|
findWithOptions: {
|
|
102
|
+
bypassSession: true,
|
|
100
103
|
check: new simpl_schema_1.default({
|
|
101
104
|
collection: {
|
|
102
105
|
type: String
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,sDA2cC;AAjdD,6CAAwC;AAExC,+DAAwF;AACxF,gEAA0D;AAC1D,yCAAsF;AAEt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ACZ;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"collections.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { MethodManager } from '../managers/method.manager';\nimport { PaginationOptions, PaginationOptionsSchema } from '../models/pagination.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { deepCopy, getMongoMergeUpdatedDoc, objectIdHexString } from '../util/common';\n\nexport function loadCollectionMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tcollectionListAll: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\tcollectionListRB: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().filter(a => a.useRB).map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\t// Query database for any collection and query\n\t\tfindOne: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find One Collection: Invalid collection');\n\t\t\t\t}\n\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).findOne(query);\n\t\t\t}\n\t\t},\n\t\tfind: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tsort: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}, sortQuery = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, {sort: sortQuery});\n\t\t\t}\n\t\t},\n\t\tfindWithOptions: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\toptions: {\n\t\t\t\t\ttype: PaginationOptionsSchema\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object, options: PaginationOptions) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find With Options Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet optionsQuery = {};\n\n\t\t\t\t\tif (options.fields && Object.keys(options.fields).length) {\n\t\t\t\t\t\toptionsQuery['projection'] = options.fields;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.sort && Object.keys(options.sort).length) {\n\t\t\t\t\t\toptionsQuery['sort'] = options.sort;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.limit) {\n\t\t\t\t\t\toptionsQuery['limit'] = options.limit;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.skip) {\n\t\t\t\t\t\toptionsQuery['skip'] = options.skip;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocument: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet id = objectIdHexString();\n\t\t\t\t\tdocument['_id'] = id;\n\t\t\t\t\tdocument['__v'] = 0;\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertOne(document);\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertManyDocuments: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocuments: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'documents.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, documents: Object[]) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Many Documents Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdocuments.forEach(document => {\n\t\t\t\t\t\tdocument['_id'] = objectIdHexString();\n\t\t\t\t\t\tdocument['__v'] = 0;\n\t\t\t\t\t});\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertMany(documents);\n\t\t\t\t\treturn documents.map(a => a['_id']);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Replaces 1 document with new document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (updated 1), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update\n\t\tupdateDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentProps: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v?: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!doc__v || modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: currDoc._id,\n\t\t\t\t\t\t\t\t\t\t__v: doc__v\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\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tupdateDocumentOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: f_document['_id']});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tif (currDoc.__v === f_document['__v']) {\n\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\tlet oldDocV = f_document['__v'];\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: newCurrDocId,\n\t\t\t\t\t\t\t\t\t\t__v: oldDocV\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 (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(f_document, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + oldDocV);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentPropsOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id}, null, true);\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: currDoc._id,\n\t\t\t\t\t\t\t\t\t\t__v: doc__v\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\t\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t// Removes 1 document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted\n\t\t// Search for doc, if found then try and remove\n\t\tremoveDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tremoveDocumentWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document With Query Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne(query);\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tremoveDocumentsWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Documents With Query Collections: Invalid Collection');\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).de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CACzD,IAAI,CAAC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;oCAC/D,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;gCACzF,CAAC;gCAED,qBAAM,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAA;;gCAAhF,SAAgF,CAAC;gCAEjF,sBAAO,IAAI,EAAC;;;;aACZ;SACD;KACD,CAAC,CAAC;AACJ,CAAC","file":"collections.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { MethodManager } from '../managers/method.manager';\nimport { PaginationOptions, PaginationOptionsSchema } from '../models/pagination.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { deepCopy, getMongoMergeUpdatedDoc, objectIdHexString } from '../util/common';\n\nexport function loadCollectionMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tcollectionListAll: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\tcollectionListRB: {\n\t\t\tfunction: function() {\n\t\t\t\treturn Promise.resolve(ResolveIOServer.getMongoManager().collections().filter(a => a.useRB).map(a => a.collectionName).sort((a, b) => a.localeCompare(b)));\n\t\t\t}\n\t\t},\n\t\t// Query database for any collection and query\n\t\tfindOne: {\n\t\t\tbypassSession: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find One Collection: Invalid collection');\n\t\t\t\t}\n\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).findOne(query);\n\t\t\t}\n\t\t},\n\t\tfind: {\n\t\t\tbypassSession: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tsort: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query = {}, sortQuery = {}) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, {sort: sortQuery});\n\t\t\t}\n\t\t},\n\t\tfindWithOptions: {\n\t\t\tbypassSession: true,\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\toptions: {\n\t\t\t\t\ttype: PaginationOptionsSchema\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collection: string, query: Object, options: PaginationOptions) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Find With Options Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet optionsQuery = {};\n\n\t\t\t\t\tif (options.fields && Object.keys(options.fields).length) {\n\t\t\t\t\t\toptionsQuery['projection'] = options.fields;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.sort && Object.keys(options.sort).length) {\n\t\t\t\t\t\toptionsQuery['sort'] = options.sort;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.limit) {\n\t\t\t\t\t\toptionsQuery['limit'] = options.limit;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.skip) {\n\t\t\t\t\t\toptionsQuery['skip'] = options.skip;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ResolveIOServer.getMongoManager().collection(collection).find(query, optionsQuery);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocument: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet id = objectIdHexString();\n\t\t\t\t\tdocument['_id'] = id;\n\t\t\t\t\tdocument['__v'] = 0;\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertOne(document);\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Insert 1 document\n\t\t// @Inputs: collection, document\n\t\t// @Outputs: res = _id of new document, err = not inserted\n\t\tinsertManyDocuments: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdocuments: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'documents.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, documents: Object[]) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Insert Many Documents Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdocuments.forEach(document => {\n\t\t\t\t\t\tdocument['_id'] = objectIdHexString();\n\t\t\t\t\t\tdocument['__v'] = 0;\n\t\t\t\t\t});\n\n\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).insertMany(documents);\n\t\t\t\t\treturn documents.map(a => a['_id']);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// Replaces 1 document with new document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (updated 1), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update\n\t\tupdateDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentProps: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v?: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!doc__v || modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: currDoc._id,\n\t\t\t\t\t\t\t\t\t\t__v: doc__v\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\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error In Update Document Props Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tupdateDocumentOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tf_document: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, f_document: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: f_document['_id']});\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tif (currDoc.__v === f_document['__v']) {\n\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: f_document['_id']}, f_document, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, f_document['__v']);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\tlet oldDocV = f_document['__v'];\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: newCurrDocId,\n\t\t\t\t\t\t\t\t\t\t__v: oldDocV\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 (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(f_document, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + oldDocV);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t// Updates 1 document's props (from _id)\n\t\t// @Inputs: collection, document id, document version, update paramters ({prop: 'xxx', data: 'yyy})\n\t\t// @Outputs: res = 1 (updated 1), res = 0 (not updated), err = not updated/wrong version\n\t\t// Search for doc, check version, if found then try and update props\n\t\tupdateDocumentPropsOffline: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tupdateParams: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'updateParams.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tdoc__v: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string, updateParams: any[], doc__v: number) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet currDoc = await ResolveIOServer.getMongoManager().collection(collection).findOne({_id: doc_id}, null, true);\n\t\t\t\t\tif (currDoc) {\n\t\t\t\t\t\tlet modifiedDoc = deepCopy(currDoc);\n\n\t\t\t\t\t\tupdateParams.forEach(data => {\n\t\t\t\t\t\t\tmodifiedDoc[data.prop] = data.data;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (modifiedDoc.__v === doc__v) {\n\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: modifiedDoc._id}, modifiedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('OFFLINE - invalid version - ' + collection, currDoc.__v, doc__v);\n\n\t\t\t\t\t\t\tlet newCurrDocId = currDoc._id;\n\t\t\t\t\t\t\tlet newCurrDocV = currDoc.__v;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (ResolveIOServer.getMongoManager().collection(collection + '.versions')) {\n\t\t\t\t\t\t\t\tlet oldDoc = await ResolveIOServer.getMongoManager().collection(collection + '.versions').findOne({\n\t\t\t\t\t\t\t\t\t_id: {\n\t\t\t\t\t\t\t\t\t\t_id: currDoc._id,\n\t\t\t\t\t\t\t\t\t\t__v: doc__v\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\t\n\t\t\t\t\t\t\t\tif (oldDoc) {\n\t\t\t\t\t\t\t\t\tlet updatedDoc = getMongoMergeUpdatedDoc(modifiedDoc, currDoc, oldDoc);\n\t\t\t\t\t\t\t\t\tupdatedDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tupdatedDoc.__v = newCurrDocV;\n\t\t\t\t\t\t\t\t\tcurrDoc._id = newCurrDocId;\n\t\t\t\t\t\t\t\t\tcurrDoc.__v = newCurrDocV;\n\n\t\t\t\t\t\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).replaceOne({_id: newCurrDocId}, updatedDoc, {}, false, false, currDoc);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: OFFLINE - Invalid Version And Could Not Find History Props - DB: ' + newCurrDocV + ', Trying to update with :' + doc__v);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: Invalid Version And We Are NOT Using Versions On This Collection!');\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\telse {\n\t\t\t\t\t\tthrow new Error('Error in Update Document Props Offline Collections: No Document');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t// Removes 1 document (from _id)\n\t\t// @Inputs: collection, document id\n\t\t// @Outputs: res = 1 (deleted), res = 0 (not deleted), err = not deleted\n\t\t// Search for doc, if found then try and remove\n\t\tremoveDocument: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tdoc_id: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, doc_id: string) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne({_id: doc_id});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tremoveDocumentWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Document With Query Collection: Invalid collection');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).deleteOne(query);\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\tremoveDocumentsWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollection: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: async function(collection: string, query: Object) {\n\t\t\t\tif (!ResolveIOServer.getMongoManager().collection(collection)) {\n\t\t\t\t\tthrow new Error('Error in Remove Documents With Query Collections: Invalid Collection');\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\tawait ResolveIOServer.getMongoManager().collection(collection).deleteMany(query);\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t});\n}\n"]}
|
package/package.json
CHANGED
|
@@ -19,6 +19,9 @@ export declare class ResolveIOServer {
|
|
|
19
19
|
private static handleMongoDisconnect;
|
|
20
20
|
private static reconnectMongo;
|
|
21
21
|
private static delay;
|
|
22
|
+
private static resolveMongoClientOptions;
|
|
23
|
+
private static pickMongoOptionValue;
|
|
24
|
+
private static pickMongoBooleanOptionValue;
|
|
22
25
|
constructor();
|
|
23
26
|
static create(serverConfig: any, clientRoutes: string[], client: string, clientDir: any, sesMail?: boolean, standardProgram?: boolean): Promise<ResolveIOServer>;
|
|
24
27
|
private initialize;
|
package/resolveio-server-app.js
CHANGED
|
@@ -35,6 +35,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
38
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
50
|
exports.ResolveIOServer = void 0;
|
|
40
51
|
var mongodb_1 = require("mongodb");
|
|
@@ -43,10 +54,13 @@ var ResolveIOServer = /** @class */ (function () {
|
|
|
43
54
|
}
|
|
44
55
|
ResolveIOServer.connectMongo = function () {
|
|
45
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var client;
|
|
57
|
+
var mongoUrl, clientOptions, client;
|
|
47
58
|
return __generator(this, function (_a) {
|
|
48
59
|
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
60
|
+
case 0:
|
|
61
|
+
mongoUrl = ResolveIOServer.getServerConfig()['MONGO_URL'];
|
|
62
|
+
clientOptions = ResolveIOServer.resolveMongoClientOptions();
|
|
63
|
+
return [4 /*yield*/, mongodb_1.MongoClient.connect(mongoUrl, clientOptions)];
|
|
50
64
|
case 1:
|
|
51
65
|
client = _a.sent();
|
|
52
66
|
client.on('close', ResolveIOServer.handleMongoDisconnect);
|
|
@@ -124,6 +138,99 @@ var ResolveIOServer = /** @class */ (function () {
|
|
|
124
138
|
});
|
|
125
139
|
});
|
|
126
140
|
};
|
|
141
|
+
ResolveIOServer.resolveMongoClientOptions = function () {
|
|
142
|
+
var e_1, _a, _b, e_2, _c, _d;
|
|
143
|
+
var config = ResolveIOServer.getServerConfig();
|
|
144
|
+
var options = {};
|
|
145
|
+
var numericOptionKeys = [
|
|
146
|
+
{ key: 'maxPoolSize', env: 'MONGO_MAX_POOL_SIZE', configKey: 'MONGO_MAX_POOL_SIZE' },
|
|
147
|
+
{ key: 'minPoolSize', env: 'MONGO_MIN_POOL_SIZE', configKey: 'MONGO_MIN_POOL_SIZE' },
|
|
148
|
+
{ key: 'waitQueueTimeoutMS', env: 'MONGO_WAIT_QUEUE_TIMEOUT_MS', configKey: 'MONGO_WAIT_QUEUE_TIMEOUT_MS' },
|
|
149
|
+
{ key: 'maxIdleTimeMS', env: 'MONGO_MAX_IDLE_TIME_MS', configKey: 'MONGO_MAX_IDLE_TIME_MS' }
|
|
150
|
+
];
|
|
151
|
+
try {
|
|
152
|
+
for (var numericOptionKeys_1 = __values(numericOptionKeys), numericOptionKeys_1_1 = numericOptionKeys_1.next(); !numericOptionKeys_1_1.done; numericOptionKeys_1_1 = numericOptionKeys_1.next()) {
|
|
153
|
+
var option = numericOptionKeys_1_1.value;
|
|
154
|
+
var value = ResolveIOServer.pickMongoOptionValue(option.env, option.configKey);
|
|
155
|
+
if (typeof value === 'number') {
|
|
156
|
+
Object.assign(options, (_b = {}, _b[option.key] = value, _b));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
161
|
+
finally {
|
|
162
|
+
try {
|
|
163
|
+
if (numericOptionKeys_1_1 && !numericOptionKeys_1_1.done && (_a = numericOptionKeys_1.return)) _a.call(numericOptionKeys_1);
|
|
164
|
+
}
|
|
165
|
+
finally { if (e_1) throw e_1.error; }
|
|
166
|
+
}
|
|
167
|
+
var booleanOptionKeys = [
|
|
168
|
+
{ key: 'retryWrites', env: 'MONGO_RETRY_WRITES', configKey: 'MONGO_RETRY_WRITES' }
|
|
169
|
+
];
|
|
170
|
+
try {
|
|
171
|
+
for (var booleanOptionKeys_1 = __values(booleanOptionKeys), booleanOptionKeys_1_1 = booleanOptionKeys_1.next(); !booleanOptionKeys_1_1.done; booleanOptionKeys_1_1 = booleanOptionKeys_1.next()) {
|
|
172
|
+
var option = booleanOptionKeys_1_1.value;
|
|
173
|
+
var value = ResolveIOServer.pickMongoBooleanOptionValue(option.env, option.configKey);
|
|
174
|
+
if (typeof value === 'boolean') {
|
|
175
|
+
Object.assign(options, (_d = {}, _d[option.key] = value, _d));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
180
|
+
finally {
|
|
181
|
+
try {
|
|
182
|
+
if (booleanOptionKeys_1_1 && !booleanOptionKeys_1_1.done && (_c = booleanOptionKeys_1.return)) _c.call(booleanOptionKeys_1);
|
|
183
|
+
}
|
|
184
|
+
finally { if (e_2) throw e_2.error; }
|
|
185
|
+
}
|
|
186
|
+
var structuredOptions = config === null || config === void 0 ? void 0 : config['MONGO_CLIENT_OPTIONS'];
|
|
187
|
+
if (structuredOptions && typeof structuredOptions === 'object' && !Array.isArray(structuredOptions)) {
|
|
188
|
+
Object.assign(options, structuredOptions);
|
|
189
|
+
}
|
|
190
|
+
return Object.keys(options).length ? options : undefined;
|
|
191
|
+
};
|
|
192
|
+
ResolveIOServer.pickMongoOptionValue = function (envKey, configKey) {
|
|
193
|
+
var rawEnv = process.env[envKey];
|
|
194
|
+
if (rawEnv && !Number.isNaN(Number(rawEnv))) {
|
|
195
|
+
var parsed = parseInt(rawEnv, 10);
|
|
196
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
197
|
+
}
|
|
198
|
+
var config = ResolveIOServer.getServerConfig();
|
|
199
|
+
var configValue = config === null || config === void 0 ? void 0 : config[configKey];
|
|
200
|
+
if (typeof configValue === 'number' && Number.isFinite(configValue) && configValue > 0) {
|
|
201
|
+
return configValue;
|
|
202
|
+
}
|
|
203
|
+
if (typeof configValue === 'string' && configValue.trim().length && !Number.isNaN(Number(configValue))) {
|
|
204
|
+
var parsed = parseInt(configValue, 10);
|
|
205
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
206
|
+
}
|
|
207
|
+
return undefined;
|
|
208
|
+
};
|
|
209
|
+
ResolveIOServer.pickMongoBooleanOptionValue = function (envKey, configKey) {
|
|
210
|
+
var rawEnv = process.env[envKey];
|
|
211
|
+
if (typeof rawEnv === 'string' && rawEnv.length) {
|
|
212
|
+
if (['true', '1', 'yes'].includes(rawEnv.toLowerCase())) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
else if (['false', '0', 'no'].includes(rawEnv.toLowerCase())) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
var config = ResolveIOServer.getServerConfig();
|
|
220
|
+
var configValue = config === null || config === void 0 ? void 0 : config[configKey];
|
|
221
|
+
if (typeof configValue === 'boolean') {
|
|
222
|
+
return configValue;
|
|
223
|
+
}
|
|
224
|
+
if (typeof configValue === 'string' && configValue.length) {
|
|
225
|
+
if (['true', '1', 'yes'].includes(configValue.toLowerCase())) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
else if (['false', '0', 'no'].includes(configValue.toLowerCase())) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return undefined;
|
|
233
|
+
};
|
|
127
234
|
ResolveIOServer.create = function (serverConfig_1, clientRoutes_1, client_1, clientDir_1) {
|
|
128
235
|
return __awaiter(this, arguments, void 0, function (serverConfig, clientRoutes, client, clientDir, sesMail, standardProgram) {
|
|
129
236
|
var resolveioServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resolveio-server-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA0C;AAK1C;IA+DC;IAAe,CAAC;IAhDK,4BAAY,GAAjC;;;;;4BACgB,qBAAM,qBAAW,CAAC,OAAO,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,CAAC,EAAA;;wBAAlF,MAAM,GAAG,SAAyE;wBACxF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;wBAC1D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;wBAC1D,MAAM,CAAC,EAAE,CAAC,uBAAuB,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;wBAC1E,sBAAO,MAA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ACjC,CAAC;IAEa,+BAAe,GAA7B;QACC,OAAO,eAAe,CAAC,aAAa,CAAC;IACtC,CAAC;IAEa,+BAAe,GAA7B,UAA8B,YAA0B;QACvD,eAAe,CAAC,aAAa,GAAG,YAAY,CAAC;IAC9C,CAAC;IAEa,kCAAkB,GAAhC;QACC,OAAO,eAAe,CAAC,gBAAgB,CAAC;IACzC,CAAC;IAEa,kCAAkB,GAAhC,UAAiC,eAAgC;QAChE,eAAe,CAAC,gBAAgB,GAAG,eAAe,CAAC;IACpD,CAAC;IAEa,+BAAe,GAA7B;QACC,OAAO,eAAe,CAAC,aAAa,CAAC;IACtC,CAAC;IAEa,+BAAe,GAA7B;QACC,OAAO,eAAe,CAAC,aAAa,CAAC;IACtC,CAAC;IAEa,4BAAY,GAA1B;QACC,OAAO,eAAe,CAAC,UAAU,CAAC;IACnC,CAAC;IAEa,0BAAU,GAAxB;QACC,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEa,kCAAkB,GAAhC;QACC,OAAO,eAAe,CAAC,gBAAgB,CAAC;IACzC,CAAC;IAnLc,6BAAa,GAAG,IAAI,CAAC;IACrB,6BAAa,GAAG,EAAE,CAAC;IACnB,gCAAgB,GAAgB,IAAI,CAAC;IACrC,uBAAO,GAAO,IAAI,CAAC;IACnB,2BAAW,GAAG,IAAI,CAAC;IACnB,gCAAgB,GAAG,IAAI,CAAC;IACxB,6BAAa,GAAG,IAAI,CAAC;IACrB,uBAAO,GAAG,EAAE,CAAC;IACb,0BAAU,GAAG,EAAE,CAAC;IAChB,wBAAQ,GAAG,IAAI,CAAC;IAChB,gCAAgB,GAAG,KAAK,CAAC;IAEzB,6BAAa,GAAG,KAAK,CAAC;IAwKtC,sBAAC;CArLD,AAqLC,IAAA;AArLY,0CAAe","file":"resolveio-server-app.js","sourcesContent":["import { Db, MongoClient } from 'mongodb';\nimport { LocalLogManager } from './managers/local-log.manager';\nimport { MongoManager } from './managers/mongo.manager';\nimport { ResolveIOMainServer } from './server-app';\n\nexport class ResolveIOServer {\n\tprivate static _serverConfig = null;\n\tprivate static _clientRoutes = [];\n\tprivate static _mongoConnection: MongoClient = null;\n\tprivate static _mainDB: Db = null;\n\tprivate static _mainServer = null;\n\tprivate static _localLogManager = null;\n\tprivate static _mongoManager = null;\n\tprivate static _client = '';\n\tprivate static _clientDir = '';\n\tprivate static _sesMail = true;\n\tprivate static _standardProgram = false;\n\n\tprivate static _reconnecting = false;\n\n\tprivate static async connectMongo(): Promise<MongoClient> {\n\t\tconst client = await MongoClient.connect(ResolveIOServer.getServerConfig()['MONGO_URL']);\n\t\tclient.on('close', ResolveIOServer.handleMongoDisconnect);\n\t\tclient.on('error', ResolveIOServer.handleMongoDisconnect);\n\t\tclient.on('connectionPoolCleared', ResolveIOServer.handleMongoDisconnect);\n\t\treturn client;\n\t}\n\n\tprivate static async handleMongoDisconnect(err): Promise<void> {\n\t\tconsole.error(new Date(), 'Mongo connection lost', err);\n\t\tif (ResolveIOServer._reconnecting) {\n\t\t\treturn;\n\t\t}\n\n\t\tResolveIOServer._reconnecting = true;\n\n\t\ttry {\n\t\t\tawait ResolveIOServer.reconnectMongo();\n\t\t}\n\t\tfinally {\n\t\t\tResolveIOServer._reconnecting = false;\n\t\t}\n\t}\n\n\tprivate static async reconnectMongo(): Promise<void> {\n\t\tlet attempt = 0;\n\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst client = await ResolveIOServer.connectMongo();\n\t\t\t\tResolveIOServer.setMongoConnection(client);\n\t\t\t\tResolveIOServer.setMainDB(client.db(ResolveIOServer.getServerConfig()['DATABASE']));\n\t\t\t\tconsole.log(new Date(), 'Mongo reconnected');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tattempt++;\n\t\t\t\tconsole.error(new Date(), 'Mongo reconnect failed', err);\n\t\t\t\tawait ResolveIOServer.delay(Math.min(attempt * 1000, 10000));\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static async delay(ms: number) {\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\tconstructor() {}\n\t\n\tpublic static async create(serverConfig, clientRoutes: string[], client: string, clientDir, sesMail = true, standardProgram = false) {\n\t\tconst resolveioServer = new ResolveIOServer();\n\t\tawait resolveioServer.initialize(serverConfig, clientRoutes, client, clientDir, sesMail, standardProgram);\n\t\treturn resolveioServer;\n\t}\n\n\tprivate async initialize(serverConfig, clientRoutes: string[], client: string, clientDir, sesMail = true, standardProgram = false) {\n\t\tResolveIOServer._serverConfig = serverConfig;\n\t\tResolveIOServer._clientRoutes = clientRoutes;\n\t\tResolveIOServer._client = client;\n\t\tResolveIOServer._clientDir = clientDir;\n\t\tResolveIOServer._sesMail = sesMail;\n\t\tResolveIOServer._standardProgram = standardProgram;\n\t\t\n\t\ttry {\n\t\t\tlet dbConnection = await ResolveIOServer.connectMongo();\n\t\t\tprocess.removeAllListeners('unhandledRejection');\n\n\t\t\tResolveIOServer.setMongoConnection(dbConnection);\n\t\t\tResolveIOServer.setMainDB(dbConnection.db(ResolveIOServer.getServerConfig()['DATABASE']));\n\n\t\t\t// dbConnection\n\t\t\t// .on('error', error => {\n\t\t\t// \tif (typeof error.message === 'string' && error.message.includes('ns does not exist')) {\n\t\t\t// \t\treturn;\n\t\t\t// \t}\n\t\t\t\t\t\n\t\t\t// \t// Otherwise log normally\n\t\t\t// \tthrow error;\n\t\t\t// })\n\t\t\t// .on('close', () => process.exit(1));\n\t\n\t\t\tlet LocalLogManager = (await import('./managers/local-log.manager')).LocalLogManager;\n\t\t\tlet localLogManager = LocalLogManager.create();\n\t\t\tResolveIOServer.setLocalLogManager(localLogManager);\n\n\t\t\tlet MongoManager = (await import('./managers/mongo.manager')).MongoManager;\n\t\t\tlet mongoManager = await MongoManager.create();\n\t\t\tResolveIOServer.setMongoManager(mongoManager);\n\t\t\t\n\t\t\tlet serverApp = (await import('./server-app')).ResolveIOMainServer;\n\t\t\tlet app = await serverApp.create();\n\t\t\tResolveIOServer.setMainServer(app);\n\t\t\t\n\t\t\treturn true;\n\t\t}\n\t\tcatch (err) {\n\t\t\terr.message = 'Error in ResolveIOServer (initialize): Mongo Client Connect And Run ResolveIO Server App Library - ' + err.message;\n\t\t\tconsole.error(err.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tpublic static getClientName() {\n\t\treturn this._client;\n\t}\n\n\tpublic static getMainServer(): ResolveIOMainServer {\n\t\treturn ResolveIOServer._mainServer;\n\t}\n\n\tpublic static setMainServer(mainServer: ResolveIOMainServer) {\n\t\tResolveIOServer._mainServer = mainServer;\n\t}\n\n\tpublic static setMongoConnection(mongoConnection: MongoClient) {\n\t\tResolveIOServer._mongoConnection = mongoConnection;\n\t}\n\n\tpublic static getMongoConnection(): MongoClient {\n\t\treturn ResolveIOServer._mongoConnection;\n\t}\n\n\tpublic static getMainDB(): Db {\n\t\treturn ResolveIOServer._mainDB;\n\t}\n\n\tpublic static setMainDB(mainDB: Db) {\n\t\tResolveIOServer._mainDB = mainDB\n\t}\n\n\tpublic static getMongoManager(): MongoManager {\n\t\treturn ResolveIOServer._mongoManager;\n\t}\n\n\tpublic static setMongoManager(mongoManager: MongoManager) {\n\t\tResolveIOServer._mongoManager = mongoManager;\n\t}\n\n\tpublic static getLocalLogManager(): LocalLogManager {\n\t\treturn ResolveIOServer._localLogManager;\n\t}\n\n\tpublic static setLocalLogManager(localLogManager: LocalLogManager) {\n\t\tResolveIOServer._localLogManager = localLogManager;\n\t}\n\n\tpublic static getServerConfig() {\n\t\treturn ResolveIOServer._serverConfig;\n\t}\n\n\tpublic static getClientRoutes() {\n\t\treturn ResolveIOServer._clientRoutes;\n\t}\n\n\tpublic static getClientDir(): string {\n\t\treturn ResolveIOServer._clientDir;\n\t}\n\n\tpublic static getSESMail(): boolean {\n\t\treturn ResolveIOServer._sesMail;\n\t}\n\n\tpublic static getStandardProgram(): boolean {\n\t\treturn ResolveIOServer._standardProgram;\n\t}\n}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,CAAC;IACzC,CAAC;IAEa,kCAAkB,GAAhC,UAAiC,eAAgC;QAChE,eAAe,CAAC,gBAAgB,GAAG,eAAe,CAAC;IACpD,CAAC;IAEa,+BAAe,GAA7B;QACC,OAAO,eAAe,CAAC,aAAa,CAAC;IACtC,CAAC;IAEa,+BAAe,GAA7B;QACC,OAAO,eAAe,CAAC,aAAa,CAAC;IACtC,CAAC;IAEa,4BAAY,GAA1B;QACC,OAAO,eAAe,CAAC,UAAU,CAAC;IACnC,CAAC;IAEa,0BAAU,GAAxB;QACC,OAAO,eAAe,CAAC,QAAQ,CAAC;IACjC,CAAC;IAEa,kCAAkB,GAAhC;QACC,OAAO,eAAe,CAAC,gBAAgB,CAAC;IACzC,CAAC;IA5Qc,6BAAa,GAAG,IAAI,CAAC;IACrB,6BAAa,GAAG,EAAE,CAAC;IACnB,gCAAgB,GAAgB,IAAI,CAAC;IACrC,uBAAO,GAAO,IAAI,CAAC;IACnB,2BAAW,GAAG,IAAI,CAAC;IACnB,gCAAgB,GAAG,IAAI,CAAC;IACxB,6BAAa,GAAG,IAAI,CAAC;IACrB,uBAAO,GAAG,EAAE,CAAC;IACb,0BAAU,GAAG,EAAE,CAAC;IAChB,wBAAQ,GAAG,IAAI,CAAC;IAChB,gCAAgB,GAAG,KAAK,CAAC;IAEzB,6BAAa,GAAG,KAAK,CAAC;IAiQtC,sBAAC;CA9QD,AA8QC,IAAA;AA9QY,0CAAe","file":"resolveio-server-app.js","sourcesContent":["import { Db, MongoClient, MongoClientOptions } from 'mongodb';\nimport { LocalLogManager } from './managers/local-log.manager';\nimport { MongoManager } from './managers/mongo.manager';\nimport { ResolveIOMainServer } from './server-app';\n\nexport class ResolveIOServer {\n\tprivate static _serverConfig = null;\n\tprivate static _clientRoutes = [];\n\tprivate static _mongoConnection: MongoClient = null;\n\tprivate static _mainDB: Db = null;\n\tprivate static _mainServer = null;\n\tprivate static _localLogManager = null;\n\tprivate static _mongoManager = null;\n\tprivate static _client = '';\n\tprivate static _clientDir = '';\n\tprivate static _sesMail = true;\n\tprivate static _standardProgram = false;\n\n\tprivate static _reconnecting = false;\n\n\tprivate static async connectMongo(): Promise<MongoClient> {\n\t\tconst mongoUrl = ResolveIOServer.getServerConfig()['MONGO_URL'];\n\t\tconst clientOptions = ResolveIOServer.resolveMongoClientOptions();\n\t\tconst client = await MongoClient.connect(mongoUrl, clientOptions);\n\t\tclient.on('close', ResolveIOServer.handleMongoDisconnect);\n\t\tclient.on('error', ResolveIOServer.handleMongoDisconnect);\n\t\tclient.on('connectionPoolCleared', ResolveIOServer.handleMongoDisconnect);\n\t\treturn client;\n\t}\n\n\tprivate static async handleMongoDisconnect(err): Promise<void> {\n\t\tconsole.error(new Date(), 'Mongo connection lost', err);\n\t\tif (ResolveIOServer._reconnecting) {\n\t\t\treturn;\n\t\t}\n\n\t\tResolveIOServer._reconnecting = true;\n\n\t\ttry {\n\t\t\tawait ResolveIOServer.reconnectMongo();\n\t\t}\n\t\tfinally {\n\t\t\tResolveIOServer._reconnecting = false;\n\t\t}\n\t}\n\n\tprivate static async reconnectMongo(): Promise<void> {\n\t\tlet attempt = 0;\n\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst client = await ResolveIOServer.connectMongo();\n\t\t\t\tResolveIOServer.setMongoConnection(client);\n\t\t\t\tResolveIOServer.setMainDB(client.db(ResolveIOServer.getServerConfig()['DATABASE']));\n\t\t\t\tconsole.log(new Date(), 'Mongo reconnected');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tattempt++;\n\t\t\t\tconsole.error(new Date(), 'Mongo reconnect failed', err);\n\t\t\t\tawait ResolveIOServer.delay(Math.min(attempt * 1000, 10000));\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static async delay(ms: number) {\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\treturn new Promise(resolve => setTimeout(resolve, ms));\n\t}\n\n\tprivate static resolveMongoClientOptions(): MongoClientOptions | undefined {\n\t\tconst config = ResolveIOServer.getServerConfig();\n\t\tconst options: MongoClientOptions = {};\n\n\t\tconst numericOptionKeys: Array<{ key: keyof MongoClientOptions; env: string; configKey: string }> = [\n\t\t\t{ key: 'maxPoolSize', env: 'MONGO_MAX_POOL_SIZE', configKey: 'MONGO_MAX_POOL_SIZE' },\n\t\t\t{ key: 'minPoolSize', env: 'MONGO_MIN_POOL_SIZE', configKey: 'MONGO_MIN_POOL_SIZE' },\n\t\t\t{ key: 'waitQueueTimeoutMS', env: 'MONGO_WAIT_QUEUE_TIMEOUT_MS', configKey: 'MONGO_WAIT_QUEUE_TIMEOUT_MS' },\n\t\t\t{ key: 'maxIdleTimeMS', env: 'MONGO_MAX_IDLE_TIME_MS', configKey: 'MONGO_MAX_IDLE_TIME_MS' }\n\t\t];\n\n\t\tfor (const option of numericOptionKeys) {\n\t\t\tconst value = ResolveIOServer.pickMongoOptionValue(option.env, option.configKey);\n\t\t\tif (typeof value === 'number') {\n\t\t\t\tObject.assign(options, { [option.key]: value });\n\t\t\t}\n\t\t}\n\n\t\tconst booleanOptionKeys: Array<{ key: keyof MongoClientOptions; env: string; configKey: string }> = [\n\t\t\t{ key: 'retryWrites', env: 'MONGO_RETRY_WRITES', configKey: 'MONGO_RETRY_WRITES' }\n\t\t];\n\n\t\tfor (const option of booleanOptionKeys) {\n\t\t\tconst value = ResolveIOServer.pickMongoBooleanOptionValue(option.env, option.configKey);\n\t\t\tif (typeof value === 'boolean') {\n\t\t\t\tObject.assign(options, { [option.key]: value });\n\t\t\t}\n\t\t}\n\n\t\tconst structuredOptions = config?.['MONGO_CLIENT_OPTIONS'];\n\t\tif (structuredOptions && typeof structuredOptions === 'object' && !Array.isArray(structuredOptions)) {\n\t\t\tObject.assign(options, structuredOptions);\n\t\t}\n\n\t\treturn Object.keys(options).length ? options : undefined;\n\t}\n\n\tprivate static pickMongoOptionValue(envKey: string, configKey: string): number | undefined {\n\t\tconst rawEnv = process.env[envKey];\n\t\tif (rawEnv && !Number.isNaN(Number(rawEnv))) {\n\t\t\tconst parsed = parseInt(rawEnv, 10);\n\t\t\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n\t\t}\n\n\t\tconst config = ResolveIOServer.getServerConfig();\n\t\tconst configValue = config?.[configKey];\n\t\tif (typeof configValue === 'number' && Number.isFinite(configValue) && configValue > 0) {\n\t\t\treturn configValue;\n\t\t}\n\n\t\tif (typeof configValue === 'string' && configValue.trim().length && !Number.isNaN(Number(configValue))) {\n\t\t\tconst parsed = parseInt(configValue, 10);\n\t\t\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tprivate static pickMongoBooleanOptionValue(envKey: string, configKey: string): boolean | undefined {\n\t\tconst rawEnv = process.env[envKey];\n\t\tif (typeof rawEnv === 'string' && rawEnv.length) {\n\t\t\tif (['true', '1', 'yes'].includes(rawEnv.toLowerCase())) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse if (['false', '0', 'no'].includes(rawEnv.toLowerCase())) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tconst config = ResolveIOServer.getServerConfig();\n\t\tconst configValue = config?.[configKey];\n\t\tif (typeof configValue === 'boolean') {\n\t\t\treturn configValue;\n\t\t}\n\n\t\tif (typeof configValue === 'string' && configValue.length) {\n\t\t\tif (['true', '1', 'yes'].includes(configValue.toLowerCase())) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse if (['false', '0', 'no'].includes(configValue.toLowerCase())) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tconstructor() {}\n\t\n\tpublic static async create(serverConfig, clientRoutes: string[], client: string, clientDir, sesMail = true, standardProgram = false) {\n\t\tconst resolveioServer = new ResolveIOServer();\n\t\tawait resolveioServer.initialize(serverConfig, clientRoutes, client, clientDir, sesMail, standardProgram);\n\t\treturn resolveioServer;\n\t}\n\n\tprivate async initialize(serverConfig, clientRoutes: string[], client: string, clientDir, sesMail = true, standardProgram = false) {\n\t\tResolveIOServer._serverConfig = serverConfig;\n\t\tResolveIOServer._clientRoutes = clientRoutes;\n\t\tResolveIOServer._client = client;\n\t\tResolveIOServer._clientDir = clientDir;\n\t\tResolveIOServer._sesMail = sesMail;\n\t\tResolveIOServer._standardProgram = standardProgram;\n\t\t\n\t\ttry {\n\t\t\tlet dbConnection = await ResolveIOServer.connectMongo();\n\t\t\tprocess.removeAllListeners('unhandledRejection');\n\n\t\t\tResolveIOServer.setMongoConnection(dbConnection);\n\t\t\tResolveIOServer.setMainDB(dbConnection.db(ResolveIOServer.getServerConfig()['DATABASE']));\n\n\t\t\t// dbConnection\n\t\t\t// .on('error', error => {\n\t\t\t// \tif (typeof error.message === 'string' && error.message.includes('ns does not exist')) {\n\t\t\t// \t\treturn;\n\t\t\t// \t}\n\t\t\t\t\t\n\t\t\t// \t// Otherwise log normally\n\t\t\t// \tthrow error;\n\t\t\t// })\n\t\t\t// .on('close', () => process.exit(1));\n\t\n\t\t\tlet LocalLogManager = (await import('./managers/local-log.manager')).LocalLogManager;\n\t\t\tlet localLogManager = LocalLogManager.create();\n\t\t\tResolveIOServer.setLocalLogManager(localLogManager);\n\n\t\t\tlet MongoManager = (await import('./managers/mongo.manager')).MongoManager;\n\t\t\tlet mongoManager = await MongoManager.create();\n\t\t\tResolveIOServer.setMongoManager(mongoManager);\n\t\t\t\n\t\t\tlet serverApp = (await import('./server-app')).ResolveIOMainServer;\n\t\t\tlet app = await serverApp.create();\n\t\t\tResolveIOServer.setMainServer(app);\n\t\t\t\n\t\t\treturn true;\n\t\t}\n\t\tcatch (err) {\n\t\t\terr.message = 'Error in ResolveIOServer (initialize): Mongo Client Connect And Run ResolveIO Server App Library - ' + err.message;\n\t\t\tconsole.error(err.message);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tpublic static getClientName() {\n\t\treturn this._client;\n\t}\n\n\tpublic static getMainServer(): ResolveIOMainServer {\n\t\treturn ResolveIOServer._mainServer;\n\t}\n\n\tpublic static setMainServer(mainServer: ResolveIOMainServer) {\n\t\tResolveIOServer._mainServer = mainServer;\n\t}\n\n\tpublic static setMongoConnection(mongoConnection: MongoClient) {\n\t\tResolveIOServer._mongoConnection = mongoConnection;\n\t}\n\n\tpublic static getMongoConnection(): MongoClient {\n\t\treturn ResolveIOServer._mongoConnection;\n\t}\n\n\tpublic static getMainDB(): Db {\n\t\treturn ResolveIOServer._mainDB;\n\t}\n\n\tpublic static setMainDB(mainDB: Db) {\n\t\tResolveIOServer._mainDB = mainDB\n\t}\n\n\tpublic static getMongoManager(): MongoManager {\n\t\treturn ResolveIOServer._mongoManager;\n\t}\n\n\tpublic static setMongoManager(mongoManager: MongoManager) {\n\t\tResolveIOServer._mongoManager = mongoManager;\n\t}\n\n\tpublic static getLocalLogManager(): LocalLogManager {\n\t\treturn ResolveIOServer._localLogManager;\n\t}\n\n\tpublic static setLocalLogManager(localLogManager: LocalLogManager) {\n\t\tResolveIOServer._localLogManager = localLogManager;\n\t}\n\n\tpublic static getServerConfig() {\n\t\treturn ResolveIOServer._serverConfig;\n\t}\n\n\tpublic static getClientRoutes() {\n\t\treturn ResolveIOServer._clientRoutes;\n\t}\n\n\tpublic static getClientDir(): string {\n\t\treturn ResolveIOServer._clientDir;\n\t}\n\n\tpublic static getSESMail(): boolean {\n\t\treturn ResolveIOServer._sesMail;\n\t}\n\n\tpublic static getStandardProgram(): boolean {\n\t\treturn ResolveIOServer._standardProgram;\n\t}\n}\n"]}
|
package/server-app.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export declare class ResolveIOMainServer {
|
|
|
28
28
|
private _clientRoutes;
|
|
29
29
|
private _workerDispatcherManager;
|
|
30
30
|
private _workerServerManager;
|
|
31
|
+
private _httpServerClosePromise;
|
|
32
|
+
private _websocketServerClosePromise;
|
|
31
33
|
private _serverStartTime;
|
|
32
34
|
private _lastErrorMsg;
|
|
33
35
|
private _debugMsgRecv;
|
|
@@ -41,6 +43,9 @@ export declare class ResolveIOMainServer {
|
|
|
41
43
|
constructor();
|
|
42
44
|
static create(): Promise<ResolveIOMainServer>;
|
|
43
45
|
private initialize;
|
|
46
|
+
private shutdownNetworkServers;
|
|
47
|
+
private closeHttpServerGracefully;
|
|
48
|
+
private closeWebSocketServerGracefully;
|
|
44
49
|
private startServerInstance;
|
|
45
50
|
private safeShutdown;
|
|
46
51
|
getIsWorkersEnabled(): boolean;
|
package/server-app.js
CHANGED
|
@@ -107,6 +107,8 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
107
107
|
this._rebootFlag = false;
|
|
108
108
|
this.LOGGER = 'ERROR'; //ERROR / DEBUG
|
|
109
109
|
this._clientRoutes = [];
|
|
110
|
+
this._httpServerClosePromise = null;
|
|
111
|
+
this._websocketServerClosePromise = null;
|
|
110
112
|
this._lastErrorMsg = null;
|
|
111
113
|
this._debugMsgRecv = 0;
|
|
112
114
|
this._debugMsgQueue = 0;
|
|
@@ -291,45 +293,72 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
291
293
|
}); });
|
|
292
294
|
//PM2 wants to reboot/restart
|
|
293
295
|
process.on('SIGINT', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
296
|
+
var error_1;
|
|
294
297
|
return __generator(this, function (_a) {
|
|
295
298
|
switch (_a.label) {
|
|
296
299
|
case 0:
|
|
297
300
|
this._rebootFlag = true;
|
|
298
|
-
|
|
299
|
-
this._serverHTTP.close();
|
|
300
|
-
}
|
|
301
|
-
return [4 /*yield*/, this.safeShutdown()];
|
|
301
|
+
_a.label = 1;
|
|
302
302
|
case 1:
|
|
303
|
+
_a.trys.push([1, 3, , 4]);
|
|
304
|
+
return [4 /*yield*/, this.shutdownNetworkServers()];
|
|
305
|
+
case 2:
|
|
306
|
+
_a.sent();
|
|
307
|
+
return [3 /*break*/, 4];
|
|
308
|
+
case 3:
|
|
309
|
+
error_1 = _a.sent();
|
|
310
|
+
console.error(new Date(), 'Error closing network servers (SIGINT)', error_1);
|
|
311
|
+
return [3 /*break*/, 4];
|
|
312
|
+
case 4: return [4 /*yield*/, this.safeShutdown()];
|
|
313
|
+
case 5:
|
|
303
314
|
_a.sent();
|
|
304
315
|
return [2 /*return*/];
|
|
305
316
|
}
|
|
306
317
|
});
|
|
307
318
|
}); });
|
|
308
319
|
process.on('SIGTERM', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
320
|
+
var error_2;
|
|
309
321
|
return __generator(this, function (_a) {
|
|
310
322
|
switch (_a.label) {
|
|
311
323
|
case 0:
|
|
312
324
|
this._rebootFlag = true;
|
|
313
|
-
|
|
314
|
-
this._serverHTTP.close();
|
|
315
|
-
}
|
|
316
|
-
return [4 /*yield*/, this.safeShutdown()];
|
|
325
|
+
_a.label = 1;
|
|
317
326
|
case 1:
|
|
327
|
+
_a.trys.push([1, 3, , 4]);
|
|
328
|
+
return [4 /*yield*/, this.shutdownNetworkServers()];
|
|
329
|
+
case 2:
|
|
330
|
+
_a.sent();
|
|
331
|
+
return [3 /*break*/, 4];
|
|
332
|
+
case 3:
|
|
333
|
+
error_2 = _a.sent();
|
|
334
|
+
console.error(new Date(), 'Error closing network servers (SIGTERM)', error_2);
|
|
335
|
+
return [3 /*break*/, 4];
|
|
336
|
+
case 4: return [4 /*yield*/, this.safeShutdown()];
|
|
337
|
+
case 5:
|
|
318
338
|
_a.sent();
|
|
319
339
|
return [2 /*return*/];
|
|
320
340
|
}
|
|
321
341
|
});
|
|
322
342
|
}); });
|
|
323
343
|
process.on('SIGQUIT', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
344
|
+
var error_3;
|
|
324
345
|
return __generator(this, function (_a) {
|
|
325
346
|
switch (_a.label) {
|
|
326
347
|
case 0:
|
|
327
348
|
this._rebootFlag = true;
|
|
328
|
-
|
|
329
|
-
this._serverHTTP.close();
|
|
330
|
-
}
|
|
331
|
-
return [4 /*yield*/, this.safeShutdown()];
|
|
349
|
+
_a.label = 1;
|
|
332
350
|
case 1:
|
|
351
|
+
_a.trys.push([1, 3, , 4]);
|
|
352
|
+
return [4 /*yield*/, this.shutdownNetworkServers()];
|
|
353
|
+
case 2:
|
|
354
|
+
_a.sent();
|
|
355
|
+
return [3 /*break*/, 4];
|
|
356
|
+
case 3:
|
|
357
|
+
error_3 = _a.sent();
|
|
358
|
+
console.error(new Date(), 'Error closing network servers (SIGQUIT)', error_3);
|
|
359
|
+
return [3 /*break*/, 4];
|
|
360
|
+
case 4: return [4 /*yield*/, this.safeShutdown()];
|
|
361
|
+
case 5:
|
|
333
362
|
_a.sent();
|
|
334
363
|
return [2 /*return*/];
|
|
335
364
|
}
|
|
@@ -371,6 +400,107 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
371
400
|
});
|
|
372
401
|
});
|
|
373
402
|
};
|
|
403
|
+
ResolveIOMainServer.prototype.shutdownNetworkServers = function () {
|
|
404
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
405
|
+
return __generator(this, function (_a) {
|
|
406
|
+
switch (_a.label) {
|
|
407
|
+
case 0: return [4 /*yield*/, this.closeWebSocketServerGracefully()];
|
|
408
|
+
case 1:
|
|
409
|
+
_a.sent();
|
|
410
|
+
return [4 /*yield*/, this.closeHttpServerGracefully()];
|
|
411
|
+
case 2:
|
|
412
|
+
_a.sent();
|
|
413
|
+
return [2 /*return*/];
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
ResolveIOMainServer.prototype.closeHttpServerGracefully = function () {
|
|
419
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
420
|
+
var _this = this;
|
|
421
|
+
return __generator(this, function (_a) {
|
|
422
|
+
switch (_a.label) {
|
|
423
|
+
case 0:
|
|
424
|
+
if (!this._serverHTTP) {
|
|
425
|
+
return [2 /*return*/];
|
|
426
|
+
}
|
|
427
|
+
if (!(this._httpServerClosePromise !== null)) return [3 /*break*/, 2];
|
|
428
|
+
return [4 /*yield*/, this._httpServerClosePromise];
|
|
429
|
+
case 1:
|
|
430
|
+
_a.sent();
|
|
431
|
+
return [2 /*return*/];
|
|
432
|
+
case 2:
|
|
433
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
434
|
+
this._httpServerClosePromise = new Promise(function (resolve) {
|
|
435
|
+
try {
|
|
436
|
+
_this._serverHTTP.close(function (error) {
|
|
437
|
+
if (error && error['code'] !== 'ERR_SERVER_NOT_RUNNING') {
|
|
438
|
+
console.error(new Date(), 'Error closing HTTP server before shutdown', error);
|
|
439
|
+
}
|
|
440
|
+
resolve();
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
if (error && error['code'] !== 'ERR_SERVER_NOT_RUNNING') {
|
|
445
|
+
console.error(new Date(), 'Error closing HTTP server before shutdown', error);
|
|
446
|
+
}
|
|
447
|
+
resolve();
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
return [4 /*yield*/, this._httpServerClosePromise];
|
|
451
|
+
case 3:
|
|
452
|
+
_a.sent();
|
|
453
|
+
return [2 /*return*/];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
ResolveIOMainServer.prototype.closeWebSocketServerGracefully = function () {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
460
|
+
var _this = this;
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
switch (_a.label) {
|
|
463
|
+
case 0:
|
|
464
|
+
if (!this._serverWSS) {
|
|
465
|
+
return [2 /*return*/];
|
|
466
|
+
}
|
|
467
|
+
if (!(this._websocketServerClosePromise !== null)) return [3 /*break*/, 2];
|
|
468
|
+
return [4 /*yield*/, this._websocketServerClosePromise];
|
|
469
|
+
case 1:
|
|
470
|
+
_a.sent();
|
|
471
|
+
return [2 /*return*/];
|
|
472
|
+
case 2:
|
|
473
|
+
this._serverWSS.clients.forEach(function (ws) {
|
|
474
|
+
try {
|
|
475
|
+
ws.close(1001, 'Server restarting');
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
console.error(new Date(), 'Error closing WebSocket client before shutdown', error);
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
482
|
+
this._websocketServerClosePromise = new Promise(function (resolve) {
|
|
483
|
+
try {
|
|
484
|
+
_this._serverWSS.close(function (error) {
|
|
485
|
+
if (error) {
|
|
486
|
+
console.error(new Date(), 'Error closing WebSocket server before shutdown', error);
|
|
487
|
+
}
|
|
488
|
+
resolve();
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
console.error(new Date(), 'Error closing WebSocket server before shutdown', error);
|
|
493
|
+
resolve();
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
return [4 /*yield*/, this._websocketServerClosePromise];
|
|
497
|
+
case 3:
|
|
498
|
+
_a.sent();
|
|
499
|
+
return [2 /*return*/];
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
};
|
|
374
504
|
ResolveIOMainServer.prototype.startServerInstance = function () {
|
|
375
505
|
// Start express app
|
|
376
506
|
this._app = express();
|
package/server-app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAmC;AACnC,kDAAoD;AACpD,6BAA4C;AAC5C,kCAAoC;AACpC,wCAA0C;AAC1C,qCAAkC;AAClC,2BAA0B;AAC1B,8BAAgC;AAEhC,+DAAoD;AACpD,iEAAsD;AACtD,wDAAsD;AACtD,4DAA0D;AAC1D,8DAAoF;AACpF,wEAAsE;AAEtE,wCAA+F;AAC/F,wDAAsD;AACtD,wDAAmE;AAEnE,mCAAmD;AACnD,oCAA8C;AAC9C,wCAAkD;AAClD,oCAA8C;AAE9C,kEAAgE;AAChE,kFAA+E;AAC/E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iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;wBAC5C,CAAC;;;;;KACD;IAID;;OAEG;IACU,2CAAa,GAA1B,UAA2B,EAAa;;;;;wBACvC,IAAI,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,EAAE,CAAC;4BACvE,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;wBAChF,CAAC;wBACD,qBAAM,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,CAAC,EAAA;;wBAAlD,SAAkD,CAAC;wBACnD,EAAE,CAAC,kBAAkB,EAAE,CAAC;wBACxB,EAAE,GAAG,IAAI,CAAC;;;;;KACV;IAEM,oCAAM,GAAb;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,6CAAe,GAAtB;QACC,OAAO,sCAAe,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IAEM,wDAA0B,GAAjC;QACC,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACtC,CAAC;IAEM,oDAAsB,GAA7B;QACC,OAAO,IAAI,CAAC,oBAAoB,CAAC;IAClC,CAAC;IACF,0BAAC;AAAD,CAhtCA,AAgtCC,IAAA;AAhtCY,kDAAmB","file":"server-app.js","sourcesContent":["import * as express from 'express';\nimport * as xmlParser from 'express-xml-bodyparser';\nimport { createServer, Server } from 'http';\nimport * as jwt from 'jsonwebtoken';\nimport * as moment from 'moment-timezone';\nimport { unpack } from 'msgpackr';\nimport { URL } from 'url';\nimport * as WebSocket from 'ws';\n\nimport { Logs } from './collections/log.collection';\nimport { Users } from './collections/user.collection';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { MonitorManager, MonitorManagerFunction } from './managers/monitor.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { ServerResponseModel } from './models/server-message.model';\nimport { dateReviver, getBinarySize, isAllowedOrigin, objectIdHexString } from './util/common';\nimport { ErrorReporter } from './util/error-reporter';\nimport { ensureErrorWithCorrelation } from './util/error-tracking';\n\nimport { MongoNetworkTimeoutError } from 'mongodb';\nimport { setupAuthRoutes } from './http/auth';\nimport { setupHealthRoutes } from './http/health';\nimport { setupHomeRoutes } from './http/home';\n\nimport { WebSocketManager } from './managers/websocket.manager';\nimport { WorkerDispatcherManager } from './managers/worker-dispatcher.manager';\nimport { WorkerServerManager } from './managers/worker-server.manager';\nimport { ResolveIOServer } from './resolveio-server-app';\n\nexport class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _serverHTTP: Server;\n\tprivate _portHTTP: string | number;\n\tprivate _serverWSS: WebSocket.Server;\n\tprivate _offlineUpdates = [];\n\tpublic sesMail = false;\n\tprivate standardProgram = false;\n\tprivate publicProgram = false;\n\tprivate _rebootFlag = false;\n\n\tprivate LOGGER = 'ERROR'; //ERROR / DEBUG\n\n\tprivate _websocketManager: WebSocketManager;\n\tprivate _monitorManager: MonitorManager;\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _cronManager: CronManager;\n\tprivate _clientRoutes: string[] = [];\n\tprivate _workerDispatcherManager: WorkerDispatcherManager;\n\tprivate _workerServerManager: WorkerServerManager;\n\n\tprivate _serverStartTime: Date;\n\tprivate _lastErrorMsg: Date = null;\n\n\tprivate _debugMsgRecv = 0;\n\tprivate _debugMsgQueue = 0;\n\n\tprivate _isWorkersEnabled = false;\n\tprivate _isWorkerInstance = false;\n\n\tprivate _safeShutdown = false;\n\n\tprivate readonly _clientHeartbeatIntervalMs = 20000;\n\tprivate readonly _clientHeartbeatInitialDelayMs = 5000;\n\tprivate readonly _clientHeartbeatBackpressureBytes = 5 * 1024 * 1024;\n\n\tconstructor() {}\n\n\tstatic async create() {\n\t\tconst resolveioMainServer = new ResolveIOMainServer();\n\t\tawait resolveioMainServer.initialize();\n\t\treturn resolveioMainServer;\n\t}\n\n\tprivate async initialize() {\n\t\tthis._serverStartTime = new Date();\n\t\tthis._lastErrorMsg = null;\n\t\tthis._monitorManager = await MonitorManager.create();\n\t\tthis._monitorManagerFunction = new MonitorManagerFunction();\n\n\t\t// Check for workers and decide what to start\n\t\tthis._isWorkersEnabled = process.env.IS_WORKERS_ENABLED === 'true';\n\t\tthis._isWorkerInstance = process.env.IS_WORKER_INSTANCE === 'true';\n\n\t\tsetInterval(() => {\n\t\t\tif (this._methodManager && this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Server App', 'Msg Recv Hits', this._debugMsgRecv);\n\t\t\t\tconsole.log(new Date(), 'Server App', 'Msg Queue Hits', this._debugMsgQueue);\n\t\t\t}\n\n\t\t\tthis._debugMsgQueue = 0;\n\t\t\tthis._debugMsgRecv = 0;\n\t\t}, 60000);\n\n\t\tlet initServerFlag = false;\n\n\t\tsetTimeout(() => {\n\t\t\tinitServerFlag = true;\n\t\t}, 5000);\n\n\t\tprocess.removeAllListeners('unhandledRejection');\n\n\t\tprocess.on('unhandledRejection', async (error, rej) => {\n\t\t\tconst { error: normalizedError, correlationId } = ensureErrorWithCorrelation(error);\n\n\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.error(new Date(), 'ERROR DETECTED w/ Debug Flag Active: unhandledRejection', [normalizedError, rej, { correlationId }]);\n\t\t\t}\n\n\t\t\t// Condition to filter out the MongoError with specific codes\n\t\t\tif (normalizedError && normalizedError['name'] === 'MongoError' && (normalizedError['code'] === 48 || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 251)) {\n\t\t\t\treturn; // Simply return without doing anything further\n\t\t\t}\n\n\t\t\tif (normalizedError && normalizedError['name'] === 'MongoServerError' && (!initServerFlag || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 86 || normalizedError['code'] === 251)) {\n\t\t\t\treturn; // Simply return without doing anything further\n\t\t\t}\n\n\t\t\tconst errorDetails = {\n\t\t\t\tid: correlationId,\n\t\t\t\tname: normalizedError?.name,\n\t\t\t\tmessage: normalizedError?.message,\n\t\t\t\tstack: normalizedError?.stack,\n\t\t\t\tcode: normalizedError?.code,\n\t\t\t\tcodeName: normalizedError?.codeName\n\t\t\t};\n\n\t\t\tconsole.error(new Date(), 'Unhandled Rejection at Promise', [errorDetails]);\n\t\t\t\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\t// If this is a MongoNetworkTimeoutError, handle it specifically\n\t\t\tif (normalizedError && (normalizedError['name'] === 'MongoNetworkTimeoutError' || normalizedError instanceof MongoNetworkTimeoutError)) {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - MongoNetworkTimeoutError - Quitting NodeJS - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tObject.assign({ scenario: 'MongoNetworkTimeoutError' }, errorDetails),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'MongoNetworkTimeoutError'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\t// Exiting the process\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - Unhandled Rejection - Quitting NodeJS - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tObject.assign({ scenario: 'MongoNotMaster' }, errorDetails),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'MongoNotMaster'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master and slaveOk=false') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - Unhandled Rejection - Quitting NodeJS - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tObject.assign({ scenario: 'MongoNotMasterSlaveOk' }, errorDetails),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'MongoNotMasterSlaveOk'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (normalizedError && normalizedError['name'] !== 'StatusError' && normalizedError['message'] !== '') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - Unhandled Rejection - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\terrorDetails,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'General'\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\n\t\tprocess.on('uncaughtException', async error => {\n\t\t\tconst { error: normalizedError, correlationId } = ensureErrorWithCorrelation(error);\n\t\t\tconsole.error(normalizedError, 'Uncaught Exception thrown', { correlationId });\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t}, 60000);\n\t\t\t\t\n\t\t\t\tconst errorDetails = {\n\t\t\t\t\tid: correlationId,\n\t\t\t\t\tname: normalizedError?.name,\n\t\t\t\t\tmessage: normalizedError?.message,\n\t\t\t\t\tstack: normalizedError?.stack,\n\t\t\t\t\tcode: normalizedError?.code,\n\t\t\t\t\tcodeName: normalizedError?.codeName\n\t\t\t\t};\n\n\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t'SERVER - Unhandled Exception - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\terrorDetails,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontext: 'uncaughtException'\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t//PM2 wants to reboot/restart\n\t\tprocess.on('SIGINT', async () => {\n\t\t\tthis._rebootFlag = true;\n\t\t\tif (this._serverHTTP) {\n\t\t\t\tthis._serverHTTP.close();\n\t\t\t}\n\t\t\tawait this.safeShutdown();\n\t\t});\n\n\t\tprocess.on('SIGTERM', async () => {\n\t\t\tthis._rebootFlag = true;\n\t\t\tif (this._serverHTTP) {\n\t\t\t\tthis._serverHTTP.close();\n\t\t\t}\n\t\t\tawait this.safeShutdown();\n\t\t});\n\n\t\tprocess.on('SIGQUIT', async () => {\n\t\t\tthis._rebootFlag = true;\n\t\t\tif (this._serverHTTP) {\n\t\t\t\tthis._serverHTTP.close();\n\t\t\t}\n\t\t\tawait this.safeShutdown();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Starting ResolveIO Server');\n\t\t}\n\n\t\tif (this._isWorkersEnabled) {\n\t\t\tif (this._isWorkerInstance) {\n\t\t\t\tconsole.log('Running as a Worker instance', process.env.NODE_APP_INSTANCE);\n\t\t\t\tthis._methodManager = MethodManager.create(null, this._monitorManagerFunction, this._isWorkersEnabled, this._isWorkerInstance);\n\t\t\t\tthis._workerServerManager = WorkerServerManager.create(this._methodManager, this.getServerConfig());\n\n\t\t\t\tif (process.env.WORKER_INDEX === '0') {\n\t\t\t\t\tthis._cronManager = CronManager.create();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log('Running as a Server instance', process.env.NODE_APP_INSTANCE);\n\t\t\t\tthis._websocketManager = WebSocketManager.create(this);\n\t\t\t\tthis._methodManager = MethodManager.create(this._websocketManager, this._monitorManagerFunction, this._isWorkersEnabled, this._isWorkerInstance);\n\t\t\t\tthis._workerDispatcherManager = WorkerDispatcherManager.create(this._websocketManager, this._methodManager);\n\t\t\t\tthis._subscriptionManager = SubscriptionManager.create(this._serverWSS, ResolveIOServer.getServerConfig(), this._monitorManagerFunction);\n\t\t\t\tthis.startServerInstance();\n\t\t\t\tthis.listen();\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tconsole.log('Running with Workers Disabled', process.env.NODE_APP_INSTANCE);\n\t\t\tthis._websocketManager = WebSocketManager.create(this);\n\t\t\tthis._methodManager = MethodManager.create(this._websocketManager, this._monitorManagerFunction, this._isWorkersEnabled, this._isWorkerInstance);\n\t\t\tthis._subscriptionManager = SubscriptionManager.create(this._serverWSS, ResolveIOServer.getServerConfig(), this._monitorManagerFunction);\n\t\t\tthis._cronManager = CronManager.create();\n\t\t\tthis.startServerInstance();\n\t\t\tthis.listen();\n\t\t}\n\t}\n\n\tprivate startServerInstance() {\n\t\t// Start express app\n\t\tthis._app = express();\n\n\t\t// Use built-in express JSON parser\n\t\tthis._app.use(express.json({\n\t\t\tlimit: '50mb',\n\t\t\treviver: dateReviver // Note: 'reviver' is an option for JSON.parse, which can be passed here\n\t\t}));\n\n\t\t// Use built-in express URL-encoded parser\n\t\tthis._app.use(express.urlencoded({\n\t\t\tlimit: '50mb',\n\t\t\textended: true, // `extended` must be explicitly true or false\n\t\t\tparameterLimit: 1000000\n\t\t}));\n\n\n\t\tthis._app.use(xmlParser());\n\t\t\n\t\t// Set port\n\t\tthis._portHTTP = process.env.NODE_APP_INSTANCE ? parseInt('808' + process.env.NODE_APP_INSTANCE) : 8080;\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup ports');\n\t\t}\n\n\t\t// Create http server and websock server\n\t\tthis.createServer();\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Create server');\n\t\t}\n\n\t\t// Set CORS\n\t\tthis._app.use(function (req, res, next) {\n\t\t\tres.setHeader('Access-Control-Allow-Origin', '*');\n\t\t\tres.setHeader('Access-Control-Allow-Methods', 'GET, POST');\n\t\t\tres.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');\n\t\t\tres.setHeader('Access-Control-Allow-Credentials', 'false');\n\t\t\tnext();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup cors');\n\t\t}\n\n\t\t// Set up http login route\n\t\tsetupAuthRoutes(this, this._app, ResolveIOServer.getServerConfig());\n\t\tsetupHealthRoutes(this._app);\n\n\t\tif (ResolveIOServer.getServerConfig()['CLIENT_NAME'] === 'ResolveIO' || this.standardProgram) {\n\t\t\tsetupHomeRoutes(this, this._app, ResolveIOServer.getServerConfig());\n\t\t}\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup express routes');\n\t\t}\n\t}\n\n\tprivate async safeShutdown() {\n\t\tif (!this._safeShutdown) {\n\t\t\tconsole.log(new Date(), 'Safe Shutdown Command Received');\n\t\t}\n\n\t\tif (\n\t\t\t!this._monitorManagerFunction.getActiveMonitorFunctions().length\n\t\t\t&& !this._offlineUpdates.length && (!this._workerDispatcherManager || this._workerDispatcherManager.isSafeShutdown())\n\t\t) {\n\t\t\tif (ResolveIOServer.getMongoConnection()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait ResolveIOServer.getMongoConnection().close(false);\n\t\t\t\t\tconsole.log(new Date(), 'Safe Exit Complete, Process Exit');\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t\tcatch { \n\t\t\t\t\tprocess.exit(1); \n\t\t\t\t};\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (!this._safeShutdown) {\n\t\t\t\tthis._safeShutdown = true;\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._safeShutdown = false;\n\t\t\t\t}, 1000);\n\n\t\t\t\tconsole.log(new Date(), 'Safe Exit In Progress', \n\t\t\t\t\tthis._monitorManagerFunction.getActiveMonitorFunctions().length,\n\t\t\t\t\tthis._offlineUpdates.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tsetImmediate(async () => {\n\t\t\t\tawait this.safeShutdown();\n\t\t\t});\n\t\t}\n\t}\n\n\tgetIsWorkersEnabled() {\n\t\treturn this._isWorkersEnabled;\n\t}\n\n\tgetIsWorkerInstance() {\n\t\treturn this._isWorkerInstance;\n\t}\n\n\tpublic getWSList() {\n\t\tlet res = [];\n\t\tthis._serverWSS.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_socket']);\n\t\t});\n\t\treturn res;\n\t}\n\n\tpublic getWSUserList() {\n\t\tlet res = [];\n\t\tthis._serverWSS.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_user']);\n\t\t});\n\t\treturn res;\n\t}\n\n\tpublic getHTTPServer() {\n\t\treturn this._serverHTTP;\n\t}\n\n\tpublic getCronManager() {\n\t\treturn this._cronManager;\n\t}\n\n\tprivate async reportServerError(\n\t\tsubject: string,\n\t\tcorrelationId: string,\n\t\tcontext: Record<string, any>,\n\t\tmeta?: Record<string, any>,\n\t\tseverity = 'error',\n\t\tstackOverride?: string\n\t) {\n\t\tconst config = ResolveIOServer.getServerConfig();\n\t\tconst metadata = Object.assign({}, meta || {});\n\t\tif (correlationId && !metadata.correlationId) {\n\t\t\tmetadata.correlationId = correlationId;\n\t\t}\n\n\t\tawait ErrorReporter.report({\n\t\t\tsourceApp: 'server-app',\n\t\t\tmessage: subject,\n\t\t\tenvironment: config?.ROOT_URL || process.env.NODE_ENV || 'unknown',\n\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\tclientName: config?.CLIENT_NAME,\n\t\t\tseverity,\n\t\t\tstack: stackOverride || (typeof context?.stack === 'string' ? context.stack : undefined),\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tcorrelationId\n\t\t});\n\t}\n\n\tpublic getMethodManager() {\n\t\treturn this._methodManager;\n\t}\n\n\tpublic getSubscriptionManager() {\n\t\treturn this._subscriptionManager;\n\t}\n\n\tpublic getMonitorManager() {\n\t\treturn this._monitorManager;\n\t}\n\n\tpublic getRebootFlag() {\n\t\treturn this._rebootFlag;\n\t}\n\n\tpublic getWebSocketManager(): WebSocketManager {\n\t\treturn this._websocketManager;\n\t}\n\n\tprivate createServer(): void {\n\t\tthis._serverHTTP = createServer(this._app);\n\t\tthis._serverHTTP.keepAliveTimeout = 65000;\n\t\tthis._serverHTTP.headersTimeout = 66000;\n\n\t\tthis._serverWSS = new WebSocket.Server({\n\t\t\tserver: this._serverHTTP,\n\t\t\tverifyClient: this.publicProgram ? null : (info, cb) => {\n\t\t\t\tif (this._rebootFlag) {\n\t\t\t\t\tcb(false, 409, 'Unable To Process');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\t\tconsole.log('Verify Client', info, cb);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If it's a worker, we might skip token checks or do a simple check:\n\t\t\t\t\tif (info.req.url && info.req.url.includes('workerToken=')) {\n\t\t\t\t\t\tlet requestUrl: URL;\n\t\t\t\t\t\tlet rootUrl = ResolveIOServer.getServerConfig()['ROOT_URL'] || 'http://localhost';\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\trequestUrl = new URL(info.req.url, rootUrl);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tcb(false, 400, 'Bad Request');\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet workerToken = requestUrl.searchParams.get('workerToken') || '';\n\t\t\t\t\t\tlet workerIndex = requestUrl.searchParams.get('workerIndex');\n\n\t\t\t\t\t\tif (workerToken === ResolveIOServer.getServerConfig()['WORKER_TOKEN']) {\n\t\t\t\t\t\t\tif (workerIndex) {\n\t\t\t\t\t\t\t\tinfo.req['workerIndex'] = workerIndex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet infoData = (<string>info.req.headers['sec-websocket-protocol']).split(/,/);\n\n\t\t\t\t\tif (!isAllowedOrigin(info.origin, ResolveIOServer.getServerConfig())) {\n\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlet token = infoData[0];\n\t\t\t\t\t\tif (!token) {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tjwt.verify(token, ResolveIOServer.getServerConfig()['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tinfo.req['id_user'] = decoded['id_user'];\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']);\n\t\t\t\t\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user'] = user.fullname;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user_readonly'] = user.readonly || false;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['doc_user'] = user;\n\t\t\t\t\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tcb(false);\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\tcatch {\n\t\t\t\t\t\t\t\t\t\tcb(false);\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}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Listen for connections from clients or workers.\n\t */\n\tprivate listen(): void {\n\t\tthis._serverHTTP.listen(this._portHTTP, () => {\n\t\t\tconsole.log('Running HTTP/WS server on port %s', this._portHTTP);\n\t\t});\n\n\t\t\tthis._serverWSS.on('connection', async (ws, req) => {\n\t\t\t\tif (req.url && req.url.includes('workerToken=')) {\n\t\t\t\t\t// It's a WORKER\n\t\t\t\t\tlet workerId = objectIdHexString();\n\t\t\t\t\tws['id_worker'] = workerId;\n\t\t\t\t\tlet workerIndex = null;\n\n\t\t\t\t\tif (req.url) {\n\t\t\t\t\t\tlet rootUrl = ResolveIOServer.getServerConfig()['ROOT_URL'] || 'http://localhost';\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet requestUrl = new URL(req.url, rootUrl);\n\t\t\t\t\t\t\tworkerIndex = requestUrl.searchParams.get('workerIndex');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tworkerIndex = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!workerIndex && req['workerIndex']) {\n\t\t\t\t\t\tworkerIndex = req['workerIndex'];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (workerIndex !== null && workerIndex !== undefined) {\n\t\t\t\t\t\tws['workerIndex'] = workerIndex;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet workerIndexForLog = ws['workerIndex'] || 'UNKNOWN';\n\t\t\t\t\tconsole.log(new Date(), 'Worker Connected', workerIndexForLog, process.env.NODE_APP_INSTANCE);\n\n\t\t\t\t\tthis._workerDispatcherManager.addWorker(ws);\n\n\t\t\t\tlet interval = null;\n\t\t\t\tlet lastComm = null;\n\n\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'ping');\n\t\n\t\t\t\tinterval = setInterval(() => {\n\t\t\t\t\tif (!lastComm) {\n\t\t\t\t\t\tthis._workerDispatcherManager.disconnectWorker(ws['id_worker']);\n\t\t\t\t\t\tws.close();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlastComm = null;\n\t\t\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'ping');\n\t\t\t\t\t}\n\t\t\t\t}, 30000);\n\n\t\t\t\t\tws.on('message', (message: WebSocket.RawData) => {\n\t\t\t\t\t\tif (typeof message === 'string') {\n\t\t\t\t\t\t\tif (message === 'ping') {\n\t\t\t\t\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'pong');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (message === 'pong') {\n\t\t\t\t\t\t\t\tlastComm = new Date();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthis._workerDispatcherManager.handleWorkerMessage(ws['id_worker'], message);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet buffer: Buffer;\n\n\t\t\t\t\t\tif (Buffer.isBuffer(message)) {\n\t\t\t\t\t\t\tbuffer = message;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (Array.isArray(message)) {\n\t\t\t\t\t\t\tconst chunks = message as unknown as ReadonlyArray<Uint8Array>;\n\t\t\t\t\t\t\tbuffer = Buffer.concat(chunks);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (message instanceof ArrayBuffer) {\n\t\t\t\t\t\t\tbuffer = Buffer.from(message);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (ArrayBuffer.isView(message)) {\n\t\t\t\t\t\t\tconst view = message as NodeJS.ArrayBufferView;\n\t\t\t\t\t\t\tbuffer = Buffer.from(view.buffer, view.byteOffset, view.byteLength);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tbuffer = Buffer.from(message as any);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (buffer.length === 4) {\n\t\t\t\t\t\t\tlet heartbeat = buffer.toString('utf8');\n\n\t\t\t\t\t\t\tif (heartbeat === 'ping') {\n\t\t\t\t\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'pong');\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (heartbeat === 'pong') {\n\t\t\t\t\t\t\t\tlastComm = new Date();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._workerDispatcherManager.handleWorkerMessage(ws['id_worker'], buffer);\n\t\t\t\t\t});\n\n\t\t\t\tws.on('close', () => {\n\t\t\t\t\tthis._workerDispatcherManager.disconnectWorker(ws['id_worker']);\n\n\t\t\t\t\tconsole.log(new Date(), 'Worker disconnected:', workerId);\n\t\t\t\t\t\n\t\t\t\t\tif (interval) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tws.on('error', (error) => {\n\t\t\t\t\tthis._workerDispatcherManager.disconnectWorker(ws['id_worker']);\n\n\t\t\t\t\tconsole.error('Error on WS Worker', error);\n\t\t\t\t\tws.close();\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Normal client\n\t\t\t\tws['id_socket'] = objectIdHexString();\n\t\t\t\tws['id_user'] = req['id_user'];\n\t\t\t\tws['user'] = req['user'];\n\t\t\t\tws['user_readonly'] = req['user_readonly'];\n\t\t\t\tws['doc_user'] = req['doc_user'];\n\n\t\t\t\tthis._websocketManager.addWebSocket(ws);\n\n\t\t\t\tawait this._subscriptionManager.createLoggedInUser(ws['id_socket']);\n\t\t\t\t\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tawait this.triggerClientHeartbeat(ws);\n\t\t\t\t}, this._clientHeartbeatInitialDelayMs);\n\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Connection from user: ' + req['user']);\n\t\t\t\t}\n\t\t\t\n\t\t\t\tws['isAlive'] = true;\n\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\tws.on('pong', () => {\n\t\t\t\t\tws['isAlive'] = true;\n\t\t\t\t\tws['pongTime'] = new Date();\n\t\t\t\t\tif (ws['pingTime']) {\n\t\t\t\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\t\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tws.on('message', async (message: WebSocket.RawData) => {\n\t\t\t\t\tthis._debugMsgRecv += 1;\n\t\t\t\t\tlet socketData = [];\n\t\t\t\t\tlet usedBinary = false;\n\t\t\t\t\tlet bufferPayload: Buffer;\n\t\t\t\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (typeof message === 'string') {\n\t\t\t\t\t\t\tif (message === 'ping' || message === 'pong') {\n\t\t\t\t\t\t\t\tsocketData = message;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tsocketData = JSON.parse(message, dateReviver);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (Buffer.isBuffer(message)) {\n\t\t\t\t\t\t\tbufferPayload = message;\n\t\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (Array.isArray(message)) {\n\t\t\t\t\t\t\tbufferPayload = Buffer.concat(message as unknown as ReadonlyArray<Uint8Array>);\n\t\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (message instanceof ArrayBuffer) {\n\t\t\t\t\t\t\tbufferPayload = Buffer.from(message);\n\t\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t\t}\n\t\t\t\t\telse if (ArrayBuffer.isView(message)) {\n\t\t\t\t\t\tconst view = message as NodeJS.ArrayBufferView;\n\t\t\t\t\t\tbufferPayload = Buffer.from(view.buffer, view.byteOffset, view.byteLength);\n\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthrow new Error('Unsupported WebSocket message type: ' + typeof message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tconsole.log('Error - WS message parse', e);\n\t\t\t\t\tconst correlationId = objectIdHexString();\n\t\t\t\t\tconst context = {\n\t\t\t\t\t\trawBinary: bufferPayload ? bufferPayload.toString('base64') : undefined,\n\t\t\t\t\t\trawMessage: typeof message === 'string' ? message : undefined,\n\t\t\t\t\t\terror: e instanceof Error ? { name: e.name, message: e.message, stack: e.stack } : e\n\t\t\t\t\t};\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - JSON Parse Error - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t{ context: 'websocket-message-parse' },\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\te instanceof Error ? e.stack : undefined\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t\tif (usedBinary) {\n\t\t\t\t\t\tws['supportsBinary'] = true;\n\t\t\t\t\t}\n\t\n\t\t\t\t\t// call our existing processSocketMessage\n\t\t\t\t\tawait this.processSocketMessage(ws, socketData);\n\t\t\t\t})\n\t\t\t\t.on('end', () => {\n\t\t\t\t\tws.close();\n\t\t\t\t})\n\t\t\t\t.on('error', () => {\n\t\t\t\t\tws.close()\n\t\t\t\t})\n\t\t\t\t.on('close', async () => {\n\t\t\t\t\tawait this.unsubscribeWS(ws);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// Keep alive timer\n\t\tsetInterval(async () => {\n\t\t\tfor (let ws of this._serverWSS.clients) {\n\t\t\t\tif (ws['pingTime'] && Date.now() - ws['pingTime'].getTime() >= this._clientHeartbeatIntervalMs) {\n\t\t\t\t\tif (this.shouldDeferHeartbeat(ws)) {\n\t\t\t\t\t\tws['isAlive'] = true;\n\t\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ws['isAlive'] === false) {\n\t\t\t\t\t\tws['retryCnt']++;\n\t\t\t\t\t\tif (ws['retryCnt'] >= 3) {\n\t\t\t\t\t\t\tawait this.unsubscribeWS(ws);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tawait this.triggerClientHeartbeat(ws);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\t\tws['isAlive'] = false;\n\t\t\t\t\t\tawait this.triggerClientHeartbeat(ws);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, this._clientHeartbeatIntervalMs);\n\t}\n\n\tprivate async processSocketMessage(ws: WebSocket, socketData: any) {\n\t\tif (typeof socketData === 'string' && socketData === 'ping') {\n\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\tws.send('pong');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\telse if (typeof socketData === 'string' && socketData === 'pong') {\n\t\t\tws['isAlive'] = true;\n\t\t\tws['pongTime'] = new Date();\n\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\treturn;\n\t\t}\n\n\t\t// If the top level is not an array, let's skip\n\t\tif (!Array.isArray(socketData[0])) {\n\t\t\tconsole.log('Invalid message format (expected array of arrays)', socketData);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle each sub-message\n\t\tfor (let message of socketData) {\n\t\t\tawait this.handleClientMessage(ws, message);\n\t\t}\n\t}\n\n\tprivate decodeBufferPayload(buffer: Buffer): { data: any; usedBinary: boolean } {\n\t\tconst textPayload = buffer.toString('utf8');\n\n\t\tif (this.looksLikeTextPayload(textPayload)) {\n\t\t\ttry {\n\t\t\t\treturn { data: this.parseTextFallback(textPayload), usedBinary: false };\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// fall through to attempt MessagePack decode\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn { data: unpack(buffer), usedBinary: true };\n\t\t}\n\t\tcatch (binaryErr) {\n\t\t\ttry {\n\t\t\t\treturn { data: this.parseTextFallback(textPayload), usedBinary: false };\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\tthrow binaryErr;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate parseTextFallback(rawMessage: string): any {\n\t\tif (rawMessage === 'ping' || rawMessage === 'pong') {\n\t\t\treturn rawMessage;\n\t\t}\n\n\t\ttry {\n\t\t\treturn JSON.parse(rawMessage, dateReviver);\n\t\t}\n\t\tcatch (err) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate looksLikeTextPayload(text: string): boolean {\n\t\tif (!text) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst trimmed = text.trim();\n\t\tif (!trimmed) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst first = trimmed[0];\n\t\treturn first === '[' || first === '{' || first === '\"' || first === 'p' || first === 'P';\n\t}\n\n\tprivate async triggerClientHeartbeat(ws: WebSocket): Promise<void> {\n\t\tif (!ws || ws.readyState !== ws.OPEN) {\n\t\t\treturn;\n\t\t}\n\n\t\tws['pingTime'] = new Date();\n\n\t\ttry {\n\t\t\tif (typeof ws.ping === 'function') {\n\t\t\t\tws.ping();\n\t\t\t}\n\t\t}\n\t\tcatch (err) {\n\t\t\tif (this._methodManager?.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Server App', 'Error WS Ping Frame', err);\n\t\t\t}\n\t\t\tawait this.unsubscribeWS(ws);\n\t\t\treturn;\n\t\t}\n\n\t\tws.send('ping', async (error) => {\n\t\t\tif (error) {\n\t\t\t\tif (this._methodManager?.getEnableDebug()) {\n\t\t\t\t\tconsole.log(new Date(), 'Server App', 'Error WS Ping');\n\t\t\t\t}\n\t\t\t\tawait this.unsubscribeWS(ws);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate shouldDeferHeartbeat(ws: WebSocket): boolean {\n\t\tif (!ws || ws.readyState !== ws.OPEN) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst bufferedAmount = typeof ws.bufferedAmount === 'number' ? ws.bufferedAmount : 0;\n\t\treturn bufferedAmount >= this._clientHeartbeatBackpressureBytes;\n\t}\n\n\tprivate async handleClientMessage(ws: WebSocket, msg: any[]): Promise<void> {\n\t\t// This is basically your old logic from processSocketMessage,\n\t\t// but we'll insert our worker-queue logic for \"method\" calls.\n\n\t\tlet messageRoute = msg[0];\n\t\tlet messageDate = msg[1];\n\t\tlet messageId = msg[2];\n\t\tlet type = msg[3];\n\n\t\tif (!this.publicProgram && this._clientRoutes.some(a => messageRoute.includes(a)) && !ws['doc_user'].roles.groups.some(a => a.views.some(b => messageRoute.includes(b) || b.includes(messageRoute))) && !ws['doc_user'].roles.super_admin) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (type === 'subscription') {\n\t\t\tlet subType = msg[4];\n\t\t\tlet pub = msg[5];\n\n\t\t\tif (subType === 'sub') {\n\t\t\t\tawait this._subscriptionManager.subscribe(messageRoute, messageDate, ws, messageId, pub, msg.slice(6));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._subscriptionManager.unsubscribe(messageRoute, messageDate, ws, messageId, pub, msg.slice(6));\n\t\t\t}\n\t\t}\n\t\telse if (!this.publicProgram && type === 'offline') {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: 'ACK'\n\t\t\t};\n\n\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\tthis._websocketManager.send(ws, serverRes);\n\t\t\t}\n\n\t\t\tthis._offlineUpdates.push(ws);\n\t\t\tlet offlineUpdates = msg[4];\n\n\t\t\tfor (let i = 0; i < offlineUpdates.length; i++) {\n\t\t\t\tlet update = offlineUpdates[i];\n\n\t\t\t\tlet data = update.data;\n\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tlet updateRoute = data.shift();\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tlet updateDate = data.shift();\n\t\t\t\tlet updateMessageId = data.shift();\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tlet updateType = data.shift();\n\t\t\t\tlet method = data.shift();\n\n\t\t\t\tlet serverResMethod: ServerResponseModel = {\n\t\t\t\t\tmessageId: updateMessageId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: 'ACK'\n\t\t\t\t};\n\n\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\tthis._websocketManager.send(ws, serverResMethod);\n\t\t\t\t}\n\n\t\t\t\tif (method === 'insertDocument' && data[0] === 'driver-gps') {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'getDrivers' && method !== 'processAirdropDistribution' && method !== 'qbHandleResponse') {\n\t\t\t\t\tif (\n\t\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t\t) {\n\t\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([data])) < 1000000 ? JSON.stringify([data], null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\troute: messageRoute\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\telse {\n\t\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([data])) < 1000000 ? JSON.stringify([data], null, 2) : 'Too Big',\n\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\troute: messageRoute,\n\t\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || ''\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._methodManager.callMethod.call(Object.assign({}, this._methodManager, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), method, ...data);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Offline Error', JSON.stringify(err, null, 2));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (method === 'updateDocumentOffline' || method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\tResolveIOServer.getMongoManager().invalidateQueryCache(data[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log('Offline - Could not find method: ' + method);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._offlineUpdates.splice(this._offlineUpdates.map(a => a['id_socket']).indexOf(ws['id_socket']), 1);\n\t\t}\n\t\telse {\n\t\t\t// It's presumably a 'method' or something else\n\t\t\tlet dataCopy = [...msg];\n\n\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\tlet route = dataCopy.shift();\n\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\tlet date = dataCopy.shift();\n\t\t\tlet msgId = dataCopy.shift();\n\t\t\tlet msgType = dataCopy.shift();\n\t\t\t\n\t\t\tif (msgType === 'method') {\n\t\t\t\tlet methodName = dataCopy.shift();\n\n\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (methodName !== 'reportBuilderGetResults' && methodName !== 'reportBuilderGetDistinctValue' && methodName !== 'reportBuilderBuildTree' && methodName !== 'generatePDF' && methodName !== 'getWOOfflineData' && methodName !== 'countQuery' && methodName !== 'countWithQuery' && methodName !== 'countCollectionWithQuery' && methodName !== 'find' && methodName !== 'findOne' && methodName !== 'findWithOptions' && methodName !== 'getDrivers' && methodName !== 'processAirdropDistribution') {\n\t\t\t\t\tif (\n\t\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t\t) {\n\t\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([dataCopy])) < 1000000 ? JSON.stringify([dataCopy], null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\troute: messageRoute\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\telse {\n\t\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([dataCopy])) < 1000000 ? JSON.stringify([dataCopy], null, 2) : 'Too Big',\n\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\troute: messageRoute,\n\t\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || ''\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Immediately ACK\n\t\t\t\tlet ack: ServerResponseModel = {\n\t\t\t\t\tmessageId: msgId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: 'ACK'\n\t\t\t\t};\n\n\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\tthis._websocketManager.send(ws, ack);\n\t\t\t\t}\n\n\t\t\t\tlet method = this._methodManager.getMethod(methodName);\n\n\t\t\t\tif (method &&\n\t\t\t\t\t!method.skipWorker &&\n\t\t\t\t\tthis._isWorkersEnabled &&\n\t\t\t\t\tthis._workerDispatcherManager &&\n\t\t\t\t\tthis._workerDispatcherManager.hasWorkers() &&\n\t\t\t\t\tmethodName !== 'find' &&\n\t\t\t\t\tmethodName !== 'insertDocument' &&\n\t\t\t\t\tmethodName !== 'countWithQuery' &&\n\t\t\t\t\tmethodName !== 'findOne' &&\n\t\t\t\t\tmethodName !== 'updateDocumentProps' &&\n\t\t\t\t\tmethodName !== 'findWithOptions' &&\n\t\t\t\t\tmethodName !== 'updateDocument' &&\n\t\t\t\t\tmethodName !== 'insertErrorLog' &&\n\t\t\t\t\tmethodName !== 'removeDocument' &&\n\t\t\t\t\tmethodName !== 'supportCreateBillingUser' &&\n\t\t\t\t\tmethodName !== 'getSignedUrl' &&\n\t\t\t\t\tmethodName !== 'getSignedUrls' &&\n\t\t\t\t\tmethodName !== 'getSignedUrlWithId' &&\n\t\t\t\t\tmethodName !== 'incorrectUser' &&\n\t\t\t\t\tmethodName !== 'reloadWS' &&\n\t\t\t\t\tmethodName !== 'reconnectWS' &&\n\t\t\t\t\tmethodName !== 'disconnectWS'\n\t\t\t\t) {\n\t\t\t\t\tthis._workerDispatcherManager.sendClientTask(msgId, methodName, dataCopy, {\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\tid_ws: ws['id_socket']\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// No worker available: do method locally\n\t\t\t\t\tawait this.callMethodLocally(ws, msgId, methodName, dataCopy);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * callMethodLocally is your old approach for invoking the method in-process.\n\t */\n\tprivate async callMethodLocally(ws: WebSocket, messageId: number, method: string, params: any[]) {\n\t\tlet serverRes: ServerResponseModel = {\n\t\t\tmessageId: messageId,\n\t\t\thasError: false,\n\t\t\tdata: null\n\t\t};\n\n\t\ttry {\n\t\t\t// You can keep your logging code (LogMethodLatencies, Logs.insertOne, etc.)\n\t\t\tlet result = await this._methodManager.callMethod.call(\n\t\t\t\tObject.assign({}, this._methodManager, MethodManager.prototype, {\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\tid_ws: ws['id_socket']\n\t\t\t\t}),\n\t\t\t\tmethod,\n\t\t\t\t...params\n\t\t\t);\n\n\t\t\tserverRes.data = result;\n\t\t}\n\t\tcatch (err) {\n\t\t\tserverRes.hasError = true;\n\t\t\tserverRes.data = err || 'Unknown error';\n\t\t}\n\n\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\tthis._websocketManager.send(ws, serverRes);\n\t\t}\n\t}\n\n\t\n\n\t/**\n\t * Cleanly remove a client from the subscription manager, etc.\n\t */\n\tpublic async unsubscribeWS(ws: WebSocket) {\n\t\tif (this._subscriptionManager && this._methodManager.getEnableDebug()) {\n\t\t\tconsole.log(new Date(), 'Server App', 'Unsub WS', ws['user'], ws['id_socket']);\n\t\t}\n\t\tawait this._subscriptionManager.unsubscribeAll(ws);\n\t\tws.removeAllListeners();\n\t\tws = null;\n\t}\n\n\tpublic getApp() {\n\t\treturn this._app;\n\t}\n\n\tpublic getServerConfig() {\n\t\treturn ResolveIOServer.getServerConfig();\n\t}\n\n\tpublic getWorkerDispatcherManager() {\n\t\treturn this._workerDispatcherManager;\n\t}\n\n\tpublic getWorkerServerManager() {\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O,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,6CAAe,GAAtB;QACC,OAAO,sCAAe,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IAEM,wDAA0B,GAAjC;QACC,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACtC,CAAC;IAEM,oDAAsB,GAA7B;QACC,OAAO,IAAI,CAAC,oBAAoB,CAAC;IAClC,CAAC;IACF,0BAAC;AAAD,CAtyCA,AAsyCC,IAAA;AAtyCY,kDAAmB","file":"server-app.js","sourcesContent":["import * as express from 'express';\nimport * as xmlParser from 'express-xml-bodyparser';\nimport { createServer, Server } from 'http';\nimport * as jwt from 'jsonwebtoken';\nimport * as moment from 'moment-timezone';\nimport { unpack } from 'msgpackr';\nimport { URL } from 'url';\nimport * as WebSocket from 'ws';\n\nimport { Logs } from './collections/log.collection';\nimport { Users } from './collections/user.collection';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { MonitorManager, MonitorManagerFunction } from './managers/monitor.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { ServerResponseModel } from './models/server-message.model';\nimport { dateReviver, getBinarySize, isAllowedOrigin, objectIdHexString } from './util/common';\nimport { ErrorReporter } from './util/error-reporter';\nimport { ensureErrorWithCorrelation } from './util/error-tracking';\n\nimport { MongoNetworkTimeoutError } from 'mongodb';\nimport { setupAuthRoutes } from './http/auth';\nimport { setupHealthRoutes } from './http/health';\nimport { setupHomeRoutes } from './http/home';\n\nimport { WebSocketManager } from './managers/websocket.manager';\nimport { WorkerDispatcherManager } from './managers/worker-dispatcher.manager';\nimport { WorkerServerManager } from './managers/worker-server.manager';\nimport { ResolveIOServer } from './resolveio-server-app';\n\nexport class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _serverHTTP: Server;\n\tprivate _portHTTP: string | number;\n\tprivate _serverWSS: WebSocket.Server;\n\tprivate _offlineUpdates = [];\n\tpublic sesMail = false;\n\tprivate standardProgram = false;\n\tprivate publicProgram = false;\n\tprivate _rebootFlag = false;\n\n\tprivate LOGGER = 'ERROR'; //ERROR / DEBUG\n\n\tprivate _websocketManager: WebSocketManager;\n\tprivate _monitorManager: MonitorManager;\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _cronManager: CronManager;\n\tprivate _clientRoutes: string[] = [];\n\tprivate _workerDispatcherManager: WorkerDispatcherManager;\n\tprivate _workerServerManager: WorkerServerManager;\n\tprivate _httpServerClosePromise: Promise<void> | null = null;\n\tprivate _websocketServerClosePromise: Promise<void> | null = null;\n\n\tprivate _serverStartTime: Date;\n\tprivate _lastErrorMsg: Date = null;\n\n\tprivate _debugMsgRecv = 0;\n\tprivate _debugMsgQueue = 0;\n\n\tprivate _isWorkersEnabled = false;\n\tprivate _isWorkerInstance = false;\n\n\tprivate _safeShutdown = false;\n\n\tprivate readonly _clientHeartbeatIntervalMs = 20000;\n\tprivate readonly _clientHeartbeatInitialDelayMs = 5000;\n\tprivate readonly _clientHeartbeatBackpressureBytes = 5 * 1024 * 1024;\n\n\tconstructor() {}\n\n\tstatic async create() {\n\t\tconst resolveioMainServer = new ResolveIOMainServer();\n\t\tawait resolveioMainServer.initialize();\n\t\treturn resolveioMainServer;\n\t}\n\n\tprivate async initialize() {\n\t\tthis._serverStartTime = new Date();\n\t\tthis._lastErrorMsg = null;\n\t\tthis._monitorManager = await MonitorManager.create();\n\t\tthis._monitorManagerFunction = new MonitorManagerFunction();\n\n\t\t// Check for workers and decide what to start\n\t\tthis._isWorkersEnabled = process.env.IS_WORKERS_ENABLED === 'true';\n\t\tthis._isWorkerInstance = process.env.IS_WORKER_INSTANCE === 'true';\n\n\t\tsetInterval(() => {\n\t\t\tif (this._methodManager && this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Server App', 'Msg Recv Hits', this._debugMsgRecv);\n\t\t\t\tconsole.log(new Date(), 'Server App', 'Msg Queue Hits', this._debugMsgQueue);\n\t\t\t}\n\n\t\t\tthis._debugMsgQueue = 0;\n\t\t\tthis._debugMsgRecv = 0;\n\t\t}, 60000);\n\n\t\tlet initServerFlag = false;\n\n\t\tsetTimeout(() => {\n\t\t\tinitServerFlag = true;\n\t\t}, 5000);\n\n\t\tprocess.removeAllListeners('unhandledRejection');\n\n\t\tprocess.on('unhandledRejection', async (error, rej) => {\n\t\t\tconst { error: normalizedError, correlationId } = ensureErrorWithCorrelation(error);\n\n\t\t\tif (this._methodManager.getEnableDebug()) {\n\t\t\t\tconsole.error(new Date(), 'ERROR DETECTED w/ Debug Flag Active: unhandledRejection', [normalizedError, rej, { correlationId }]);\n\t\t\t}\n\n\t\t\t// Condition to filter out the MongoError with specific codes\n\t\t\tif (normalizedError && normalizedError['name'] === 'MongoError' && (normalizedError['code'] === 48 || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 251)) {\n\t\t\t\treturn; // Simply return without doing anything further\n\t\t\t}\n\n\t\t\tif (normalizedError && normalizedError['name'] === 'MongoServerError' && (!initServerFlag || normalizedError['code'] === 26 || normalizedError['code'] === 11000 || normalizedError['code'] === 86 || normalizedError['code'] === 251)) {\n\t\t\t\treturn; // Simply return without doing anything further\n\t\t\t}\n\n\t\t\tconst errorDetails = {\n\t\t\t\tid: correlationId,\n\t\t\t\tname: normalizedError?.name,\n\t\t\t\tmessage: normalizedError?.message,\n\t\t\t\tstack: normalizedError?.stack,\n\t\t\t\tcode: normalizedError?.code,\n\t\t\t\tcodeName: normalizedError?.codeName\n\t\t\t};\n\n\t\t\tconsole.error(new Date(), 'Unhandled Rejection at Promise', [errorDetails]);\n\t\t\t\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\t// If this is a MongoNetworkTimeoutError, handle it specifically\n\t\t\tif (normalizedError && (normalizedError['name'] === 'MongoNetworkTimeoutError' || normalizedError instanceof MongoNetworkTimeoutError)) {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - MongoNetworkTimeoutError - Quitting NodeJS - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tObject.assign({ scenario: 'MongoNetworkTimeoutError' }, errorDetails),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'MongoNetworkTimeoutError'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\t// Exiting the process\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - Unhandled Rejection - Quitting NodeJS - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tObject.assign({ scenario: 'MongoNotMaster' }, errorDetails),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'MongoNotMaster'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (normalizedError && normalizedError['name'] === 'MongoError' && normalizedError['message'] === 'not master and slaveOk=false') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - Unhandled Rejection - Quitting NodeJS - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tObject.assign({ scenario: 'MongoNotMasterSlaveOk' }, errorDetails),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'MongoNotMasterSlaveOk'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (normalizedError && normalizedError['name'] !== 'StatusError' && normalizedError['message'] !== '') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - Unhandled Rejection - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\terrorDetails,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontext: 'unhandledRejection',\n\t\t\t\t\t\t\tscenario: 'General'\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\n\t\tprocess.on('uncaughtException', async error => {\n\t\t\tconst { error: normalizedError, correlationId } = ensureErrorWithCorrelation(error);\n\t\t\tconsole.error(normalizedError, 'Uncaught Exception thrown', { correlationId });\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t}, 60000);\n\t\t\t\t\n\t\t\t\tconst errorDetails = {\n\t\t\t\t\tid: correlationId,\n\t\t\t\t\tname: normalizedError?.name,\n\t\t\t\t\tmessage: normalizedError?.message,\n\t\t\t\t\tstack: normalizedError?.stack,\n\t\t\t\t\tcode: normalizedError?.code,\n\t\t\t\t\tcodeName: normalizedError?.codeName\n\t\t\t\t};\n\n\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t'SERVER - Unhandled Exception - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\terrorDetails,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontext: 'uncaughtException'\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t//PM2 wants to reboot/restart\n\t\tprocess.on('SIGINT', async () => {\n\t\t\tthis._rebootFlag = true;\n\t\t\ttry {\n\t\t\t\tawait this.shutdownNetworkServers();\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconsole.error(new Date(), 'Error closing network servers (SIGINT)', error);\n\t\t\t}\n\t\t\tawait this.safeShutdown();\n\t\t});\n\n\t\tprocess.on('SIGTERM', async () => {\n\t\t\tthis._rebootFlag = true;\n\t\t\ttry {\n\t\t\t\tawait this.shutdownNetworkServers();\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconsole.error(new Date(), 'Error closing network servers (SIGTERM)', error);\n\t\t\t}\n\t\t\tawait this.safeShutdown();\n\t\t});\n\n\t\tprocess.on('SIGQUIT', async () => {\n\t\t\tthis._rebootFlag = true;\n\t\t\ttry {\n\t\t\t\tawait this.shutdownNetworkServers();\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconsole.error(new Date(), 'Error closing network servers (SIGQUIT)', error);\n\t\t\t}\n\t\t\tawait this.safeShutdown();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Starting ResolveIO Server');\n\t\t}\n\n\t\tif (this._isWorkersEnabled) {\n\t\t\tif (this._isWorkerInstance) {\n\t\t\t\tconsole.log('Running as a Worker instance', process.env.NODE_APP_INSTANCE);\n\t\t\t\tthis._methodManager = MethodManager.create(null, this._monitorManagerFunction, this._isWorkersEnabled, this._isWorkerInstance);\n\t\t\t\tthis._workerServerManager = WorkerServerManager.create(this._methodManager, this.getServerConfig());\n\n\t\t\t\tif (process.env.WORKER_INDEX === '0') {\n\t\t\t\t\tthis._cronManager = CronManager.create();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log('Running as a Server instance', process.env.NODE_APP_INSTANCE);\n\t\t\t\tthis._websocketManager = WebSocketManager.create(this);\n\t\t\t\tthis._methodManager = MethodManager.create(this._websocketManager, this._monitorManagerFunction, this._isWorkersEnabled, this._isWorkerInstance);\n\t\t\t\tthis._workerDispatcherManager = WorkerDispatcherManager.create(this._websocketManager, this._methodManager);\n\t\t\t\tthis._subscriptionManager = SubscriptionManager.create(this._serverWSS, ResolveIOServer.getServerConfig(), this._monitorManagerFunction);\n\t\t\t\tthis.startServerInstance();\n\t\t\t\tthis.listen();\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tconsole.log('Running with Workers Disabled', process.env.NODE_APP_INSTANCE);\n\t\t\tthis._websocketManager = WebSocketManager.create(this);\n\t\t\tthis._methodManager = MethodManager.create(this._websocketManager, this._monitorManagerFunction, this._isWorkersEnabled, this._isWorkerInstance);\n\t\t\tthis._subscriptionManager = SubscriptionManager.create(this._serverWSS, ResolveIOServer.getServerConfig(), this._monitorManagerFunction);\n\t\t\tthis._cronManager = CronManager.create();\n\t\t\tthis.startServerInstance();\n\t\t\tthis.listen();\n\t\t}\n\t}\n\n\tprivate async shutdownNetworkServers() {\n\t\tawait this.closeWebSocketServerGracefully();\n\t\tawait this.closeHttpServerGracefully();\n\t}\n\n\tprivate async closeHttpServerGracefully() {\n\t\tif (!this._serverHTTP) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._httpServerClosePromise !== null) {\n\t\t\tawait this._httpServerClosePromise;\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tthis._httpServerClosePromise = new Promise(resolve => {\n\t\t\ttry {\n\t\t\t\tthis._serverHTTP.close(error => {\n\t\t\t\t\tif (error && error['code'] !== 'ERR_SERVER_NOT_RUNNING') {\n\t\t\t\t\t\tconsole.error(new Date(), 'Error closing HTTP server before shutdown', error);\n\t\t\t\t\t}\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tif (error && error['code'] !== 'ERR_SERVER_NOT_RUNNING') {\n\t\t\t\t\tconsole.error(new Date(), 'Error closing HTTP server before shutdown', error);\n\t\t\t\t}\n\t\t\t\tresolve();\n\t\t\t}\n\t\t});\n\n\t\tawait this._httpServerClosePromise;\n\t}\n\n\tprivate async closeWebSocketServerGracefully() {\n\t\tif (!this._serverWSS) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this._websocketServerClosePromise !== null) {\n\t\t\tawait this._websocketServerClosePromise;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._serverWSS.clients.forEach(ws => {\n\t\t\ttry {\n\t\t\t\tws.close(1001, 'Server restarting');\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconsole.error(new Date(), 'Error closing WebSocket client before shutdown', error);\n\t\t\t}\n\t\t});\n\n\t\t// eslint-disable-next-line no-restricted-syntax\n\t\tthis._websocketServerClosePromise = new Promise(resolve => {\n\t\t\ttry {\n\t\t\t\tthis._serverWSS.close(error => {\n\t\t\t\t\tif (error) {\n\t\t\t\t\t\tconsole.error(new Date(), 'Error closing WebSocket server before shutdown', error);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconsole.error(new Date(), 'Error closing WebSocket server before shutdown', error);\n\t\t\t\tresolve();\n\t\t\t}\n\t\t});\n\n\t\tawait this._websocketServerClosePromise;\n\t}\n\n\tprivate startServerInstance() {\n\t\t// Start express app\n\t\tthis._app = express();\n\n\t\t// Use built-in express JSON parser\n\t\tthis._app.use(express.json({\n\t\t\tlimit: '50mb',\n\t\t\treviver: dateReviver // Note: 'reviver' is an option for JSON.parse, which can be passed here\n\t\t}));\n\n\t\t// Use built-in express URL-encoded parser\n\t\tthis._app.use(express.urlencoded({\n\t\t\tlimit: '50mb',\n\t\t\textended: true, // `extended` must be explicitly true or false\n\t\t\tparameterLimit: 1000000\n\t\t}));\n\n\n\t\tthis._app.use(xmlParser());\n\t\t\n\t\t// Set port\n\t\tthis._portHTTP = process.env.NODE_APP_INSTANCE ? parseInt('808' + process.env.NODE_APP_INSTANCE) : 8080;\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup ports');\n\t\t}\n\n\t\t// Create http server and websock server\n\t\tthis.createServer();\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Create server');\n\t\t}\n\n\t\t// Set CORS\n\t\tthis._app.use(function (req, res, next) {\n\t\t\tres.setHeader('Access-Control-Allow-Origin', '*');\n\t\t\tres.setHeader('Access-Control-Allow-Methods', 'GET, POST');\n\t\t\tres.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');\n\t\t\tres.setHeader('Access-Control-Allow-Credentials', 'false');\n\t\t\tnext();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup cors');\n\t\t}\n\n\t\t// Set up http login route\n\t\tsetupAuthRoutes(this, this._app, ResolveIOServer.getServerConfig());\n\t\tsetupHealthRoutes(this._app);\n\n\t\tif (ResolveIOServer.getServerConfig()['CLIENT_NAME'] === 'ResolveIO' || this.standardProgram) {\n\t\t\tsetupHomeRoutes(this, this._app, ResolveIOServer.getServerConfig());\n\t\t}\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup express routes');\n\t\t}\n\t}\n\n\tprivate async safeShutdown() {\n\t\tif (!this._safeShutdown) {\n\t\t\tconsole.log(new Date(), 'Safe Shutdown Command Received');\n\t\t}\n\n\t\tif (\n\t\t\t!this._monitorManagerFunction.getActiveMonitorFunctions().length\n\t\t\t&& !this._offlineUpdates.length && (!this._workerDispatcherManager || this._workerDispatcherManager.isSafeShutdown())\n\t\t) {\n\t\t\tif (ResolveIOServer.getMongoConnection()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait ResolveIOServer.getMongoConnection().close(false);\n\t\t\t\t\tconsole.log(new Date(), 'Safe Exit Complete, Process Exit');\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t\tcatch { \n\t\t\t\t\tprocess.exit(1); \n\t\t\t\t};\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (!this._safeShutdown) {\n\t\t\t\tthis._safeShutdown = true;\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._safeShutdown = false;\n\t\t\t\t}, 1000);\n\n\t\t\t\tconsole.log(new Date(), 'Safe Exit In Progress', \n\t\t\t\t\tthis._monitorManagerFunction.getActiveMonitorFunctions().length,\n\t\t\t\t\tthis._offlineUpdates.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tsetImmediate(async () => {\n\t\t\t\tawait this.safeShutdown();\n\t\t\t});\n\t\t}\n\t}\n\n\tgetIsWorkersEnabled() {\n\t\treturn this._isWorkersEnabled;\n\t}\n\n\tgetIsWorkerInstance() {\n\t\treturn this._isWorkerInstance;\n\t}\n\n\tpublic getWSList() {\n\t\tlet res = [];\n\t\tthis._serverWSS.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_socket']);\n\t\t});\n\t\treturn res;\n\t}\n\n\tpublic getWSUserList() {\n\t\tlet res = [];\n\t\tthis._serverWSS.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_user']);\n\t\t});\n\t\treturn res;\n\t}\n\n\tpublic getHTTPServer() {\n\t\treturn this._serverHTTP;\n\t}\n\n\tpublic getCronManager() {\n\t\treturn this._cronManager;\n\t}\n\n\tprivate async reportServerError(\n\t\tsubject: string,\n\t\tcorrelationId: string,\n\t\tcontext: Record<string, any>,\n\t\tmeta?: Record<string, any>,\n\t\tseverity = 'error',\n\t\tstackOverride?: string\n\t) {\n\t\tconst config = ResolveIOServer.getServerConfig();\n\t\tconst metadata = Object.assign({}, meta || {});\n\t\tif (correlationId && !metadata.correlationId) {\n\t\t\tmetadata.correlationId = correlationId;\n\t\t}\n\n\t\tawait ErrorReporter.report({\n\t\t\tsourceApp: 'server-app',\n\t\t\tmessage: subject,\n\t\t\tenvironment: config?.ROOT_URL || process.env.NODE_ENV || 'unknown',\n\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\tclientName: config?.CLIENT_NAME,\n\t\t\tseverity,\n\t\t\tstack: stackOverride || (typeof context?.stack === 'string' ? context.stack : undefined),\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tcorrelationId\n\t\t});\n\t}\n\n\tpublic getMethodManager() {\n\t\treturn this._methodManager;\n\t}\n\n\tpublic getSubscriptionManager() {\n\t\treturn this._subscriptionManager;\n\t}\n\n\tpublic getMonitorManager() {\n\t\treturn this._monitorManager;\n\t}\n\n\tpublic getRebootFlag() {\n\t\treturn this._rebootFlag;\n\t}\n\n\tpublic getWebSocketManager(): WebSocketManager {\n\t\treturn this._websocketManager;\n\t}\n\n\tprivate createServer(): void {\n\t\tthis._serverHTTP = createServer(this._app);\n\t\tthis._serverHTTP.keepAliveTimeout = 65000;\n\t\tthis._serverHTTP.headersTimeout = 66000;\n\n\t\tthis._serverWSS = new WebSocket.Server({\n\t\t\tserver: this._serverHTTP,\n\t\t\tverifyClient: this.publicProgram ? null : (info, cb) => {\n\t\t\t\tif (this._rebootFlag) {\n\t\t\t\t\tcb(false, 409, 'Unable To Process');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\t\tconsole.log('Verify Client', info, cb);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If it's a worker, we might skip token checks or do a simple check:\n\t\t\t\t\tif (info.req.url && info.req.url.includes('workerToken=')) {\n\t\t\t\t\t\tlet requestUrl: URL;\n\t\t\t\t\t\tlet rootUrl = ResolveIOServer.getServerConfig()['ROOT_URL'] || 'http://localhost';\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\trequestUrl = new URL(info.req.url, rootUrl);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tcb(false, 400, 'Bad Request');\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet workerToken = requestUrl.searchParams.get('workerToken') || '';\n\t\t\t\t\t\tlet workerIndex = requestUrl.searchParams.get('workerIndex');\n\n\t\t\t\t\t\tif (workerToken === ResolveIOServer.getServerConfig()['WORKER_TOKEN']) {\n\t\t\t\t\t\t\tif (workerIndex) {\n\t\t\t\t\t\t\t\tinfo.req['workerIndex'] = workerIndex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet infoData = (<string>info.req.headers['sec-websocket-protocol']).split(/,/);\n\n\t\t\t\t\tif (!isAllowedOrigin(info.origin, ResolveIOServer.getServerConfig())) {\n\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlet token = infoData[0];\n\t\t\t\t\t\tif (!token) {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tjwt.verify(token, ResolveIOServer.getServerConfig()['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tinfo.req['id_user'] = decoded['id_user'];\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']);\n\t\t\t\t\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user'] = user.fullname;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user_readonly'] = user.readonly || false;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['doc_user'] = user;\n\t\t\t\t\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tcb(false);\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\tcatch {\n\t\t\t\t\t\t\t\t\t\tcb(false);\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}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Listen for connections from clients or workers.\n\t */\n\tprivate listen(): void {\n\t\tthis._serverHTTP.listen(this._portHTTP, () => {\n\t\t\tconsole.log('Running HTTP/WS server on port %s', this._portHTTP);\n\t\t});\n\n\t\t\tthis._serverWSS.on('connection', async (ws, req) => {\n\t\t\t\tif (req.url && req.url.includes('workerToken=')) {\n\t\t\t\t\t// It's a WORKER\n\t\t\t\t\tlet workerId = objectIdHexString();\n\t\t\t\t\tws['id_worker'] = workerId;\n\t\t\t\t\tlet workerIndex = null;\n\n\t\t\t\t\tif (req.url) {\n\t\t\t\t\t\tlet rootUrl = ResolveIOServer.getServerConfig()['ROOT_URL'] || 'http://localhost';\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlet requestUrl = new URL(req.url, rootUrl);\n\t\t\t\t\t\t\tworkerIndex = requestUrl.searchParams.get('workerIndex');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tworkerIndex = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!workerIndex && req['workerIndex']) {\n\t\t\t\t\t\tworkerIndex = req['workerIndex'];\n\t\t\t\t\t}\n\n\t\t\t\t\tif (workerIndex !== null && workerIndex !== undefined) {\n\t\t\t\t\t\tws['workerIndex'] = workerIndex;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet workerIndexForLog = ws['workerIndex'] || 'UNKNOWN';\n\t\t\t\t\tconsole.log(new Date(), 'Worker Connected', workerIndexForLog, process.env.NODE_APP_INSTANCE);\n\n\t\t\t\t\tthis._workerDispatcherManager.addWorker(ws);\n\n\t\t\t\tlet interval = null;\n\t\t\t\tlet lastComm = null;\n\n\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'ping');\n\t\n\t\t\t\tinterval = setInterval(() => {\n\t\t\t\t\tif (!lastComm) {\n\t\t\t\t\t\tthis._workerDispatcherManager.disconnectWorker(ws['id_worker']);\n\t\t\t\t\t\tws.close();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlastComm = null;\n\t\t\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'ping');\n\t\t\t\t\t}\n\t\t\t\t}, 30000);\n\n\t\t\t\t\tws.on('message', (message: WebSocket.RawData) => {\n\t\t\t\t\t\tif (typeof message === 'string') {\n\t\t\t\t\t\t\tif (message === 'ping') {\n\t\t\t\t\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'pong');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (message === 'pong') {\n\t\t\t\t\t\t\t\tlastComm = new Date();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthis._workerDispatcherManager.handleWorkerMessage(ws['id_worker'], message);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet buffer: Buffer;\n\n\t\t\t\t\t\tif (Buffer.isBuffer(message)) {\n\t\t\t\t\t\t\tbuffer = message;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (Array.isArray(message)) {\n\t\t\t\t\t\t\tconst chunks = message as unknown as ReadonlyArray<Uint8Array>;\n\t\t\t\t\t\t\tbuffer = Buffer.concat(chunks);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (message instanceof ArrayBuffer) {\n\t\t\t\t\t\t\tbuffer = Buffer.from(message);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (ArrayBuffer.isView(message)) {\n\t\t\t\t\t\t\tconst view = message as NodeJS.ArrayBufferView;\n\t\t\t\t\t\t\tbuffer = Buffer.from(view.buffer, view.byteOffset, view.byteLength);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tbuffer = Buffer.from(message as any);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (buffer.length === 4) {\n\t\t\t\t\t\t\tlet heartbeat = buffer.toString('utf8');\n\n\t\t\t\t\t\t\tif (heartbeat === 'ping') {\n\t\t\t\t\t\t\t\tthis._workerDispatcherManager.sendWorkerPayload(ws, 'pong');\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (heartbeat === 'pong') {\n\t\t\t\t\t\t\t\tlastComm = new Date();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._workerDispatcherManager.handleWorkerMessage(ws['id_worker'], buffer);\n\t\t\t\t\t});\n\n\t\t\t\tws.on('close', () => {\n\t\t\t\t\tthis._workerDispatcherManager.disconnectWorker(ws['id_worker']);\n\n\t\t\t\t\tconsole.log(new Date(), 'Worker disconnected:', workerId);\n\t\t\t\t\t\n\t\t\t\t\tif (interval) {\n\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tws.on('error', (error) => {\n\t\t\t\t\tthis._workerDispatcherManager.disconnectWorker(ws['id_worker']);\n\n\t\t\t\t\tconsole.error('Error on WS Worker', error);\n\t\t\t\t\tws.close();\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Normal client\n\t\t\t\tws['id_socket'] = objectIdHexString();\n\t\t\t\tws['id_user'] = req['id_user'];\n\t\t\t\tws['user'] = req['user'];\n\t\t\t\tws['user_readonly'] = req['user_readonly'];\n\t\t\t\tws['doc_user'] = req['doc_user'];\n\n\t\t\t\tthis._websocketManager.addWebSocket(ws);\n\n\t\t\t\tawait this._subscriptionManager.createLoggedInUser(ws['id_socket']);\n\t\t\t\t\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tawait this.triggerClientHeartbeat(ws);\n\t\t\t\t}, this._clientHeartbeatInitialDelayMs);\n\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Connection from user: ' + req['user']);\n\t\t\t\t}\n\t\t\t\n\t\t\t\tws['isAlive'] = true;\n\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\tws.on('pong', () => {\n\t\t\t\t\tws['isAlive'] = true;\n\t\t\t\t\tws['pongTime'] = new Date();\n\t\t\t\t\tif (ws['pingTime']) {\n\t\t\t\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\t\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tws.on('message', async (message: WebSocket.RawData) => {\n\t\t\t\t\tthis._debugMsgRecv += 1;\n\t\t\t\t\tlet socketData = [];\n\t\t\t\t\tlet usedBinary = false;\n\t\t\t\t\tlet bufferPayload: Buffer;\n\t\t\t\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (typeof message === 'string') {\n\t\t\t\t\t\t\tif (message === 'ping' || message === 'pong') {\n\t\t\t\t\t\t\t\tsocketData = message;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tsocketData = JSON.parse(message, dateReviver);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (Buffer.isBuffer(message)) {\n\t\t\t\t\t\t\tbufferPayload = message;\n\t\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (Array.isArray(message)) {\n\t\t\t\t\t\t\tbufferPayload = Buffer.concat(message as unknown as ReadonlyArray<Uint8Array>);\n\t\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (message instanceof ArrayBuffer) {\n\t\t\t\t\t\t\tbufferPayload = Buffer.from(message);\n\t\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t\t}\n\t\t\t\t\telse if (ArrayBuffer.isView(message)) {\n\t\t\t\t\t\tconst view = message as NodeJS.ArrayBufferView;\n\t\t\t\t\t\tbufferPayload = Buffer.from(view.buffer, view.byteOffset, view.byteLength);\n\t\t\t\t\t\tlet decodeResult = this.decodeBufferPayload(bufferPayload);\n\t\t\t\t\t\tsocketData = decodeResult.data;\n\t\t\t\t\t\tusedBinary = decodeResult.usedBinary;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthrow new Error('Unsupported WebSocket message type: ' + typeof message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tconsole.log('Error - WS message parse', e);\n\t\t\t\t\tconst correlationId = objectIdHexString();\n\t\t\t\t\tconst context = {\n\t\t\t\t\t\trawBinary: bufferPayload ? bufferPayload.toString('base64') : undefined,\n\t\t\t\t\t\trawMessage: typeof message === 'string' ? message : undefined,\n\t\t\t\t\t\terror: e instanceof Error ? { name: e.name, message: e.message, stack: e.stack } : e\n\t\t\t\t\t};\n\t\t\t\t\tawait this.reportServerError(\n\t\t\t\t\t\t'SERVER - JSON Parse Error - ' + ResolveIOServer.getServerConfig()['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t{ context: 'websocket-message-parse' },\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\te instanceof Error ? e.stack : undefined\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t\tif (usedBinary) {\n\t\t\t\t\t\tws['supportsBinary'] = true;\n\t\t\t\t\t}\n\t\n\t\t\t\t\t// call our existing processSocketMessage\n\t\t\t\t\tawait this.processSocketMessage(ws, socketData);\n\t\t\t\t})\n\t\t\t\t.on('end', () => {\n\t\t\t\t\tws.close();\n\t\t\t\t})\n\t\t\t\t.on('error', () => {\n\t\t\t\t\tws.close()\n\t\t\t\t})\n\t\t\t\t.on('close', async () => {\n\t\t\t\t\tawait this.unsubscribeWS(ws);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// Keep alive timer\n\t\tsetInterval(async () => {\n\t\t\tfor (let ws of this._serverWSS.clients) {\n\t\t\t\tif (ws['pingTime'] && Date.now() - ws['pingTime'].getTime() >= this._clientHeartbeatIntervalMs) {\n\t\t\t\t\tif (this.shouldDeferHeartbeat(ws)) {\n\t\t\t\t\t\tws['isAlive'] = true;\n\t\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ws['isAlive'] === false) {\n\t\t\t\t\t\tws['retryCnt']++;\n\t\t\t\t\t\tif (ws['retryCnt'] >= 3) {\n\t\t\t\t\t\t\tawait this.unsubscribeWS(ws);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tawait this.triggerClientHeartbeat(ws);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\t\tws['isAlive'] = false;\n\t\t\t\t\t\tawait this.triggerClientHeartbeat(ws);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, this._clientHeartbeatIntervalMs);\n\t}\n\n\tprivate async processSocketMessage(ws: WebSocket, socketData: any) {\n\t\tif (typeof socketData === 'string' && socketData === 'ping') {\n\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\tws.send('pong');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\telse if (typeof socketData === 'string' && socketData === 'pong') {\n\t\t\tws['isAlive'] = true;\n\t\t\tws['pongTime'] = new Date();\n\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\treturn;\n\t\t}\n\n\t\t// If the top level is not an array, let's skip\n\t\tif (!Array.isArray(socketData[0])) {\n\t\t\tconsole.log('Invalid message format (expected array of arrays)', socketData);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle each sub-message\n\t\tfor (let message of socketData) {\n\t\t\tawait this.handleClientMessage(ws, message);\n\t\t}\n\t}\n\n\tprivate decodeBufferPayload(buffer: Buffer): { data: any; usedBinary: boolean } {\n\t\tconst textPayload = buffer.toString('utf8');\n\n\t\tif (this.looksLikeTextPayload(textPayload)) {\n\t\t\ttry {\n\t\t\t\treturn { data: this.parseTextFallback(textPayload), usedBinary: false };\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// fall through to attempt MessagePack decode\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn { data: unpack(buffer), usedBinary: true };\n\t\t}\n\t\tcatch (binaryErr) {\n\t\t\ttry {\n\t\t\t\treturn { data: this.parseTextFallback(textPayload), usedBinary: false };\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\tthrow binaryErr;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate parseTextFallback(rawMessage: string): any {\n\t\tif (rawMessage === 'ping' || rawMessage === 'pong') {\n\t\t\treturn rawMessage;\n\t\t}\n\n\t\ttry {\n\t\t\treturn JSON.parse(rawMessage, dateReviver);\n\t\t}\n\t\tcatch (err) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tprivate looksLikeTextPayload(text: string): boolean {\n\t\tif (!text) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst trimmed = text.trim();\n\t\tif (!trimmed) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst first = trimmed[0];\n\t\treturn first === '[' || first === '{' || first === '\"' || first === 'p' || first === 'P';\n\t}\n\n\tprivate async triggerClientHeartbeat(ws: WebSocket): Promise<void> {\n\t\tif (!ws || ws.readyState !== ws.OPEN) {\n\t\t\treturn;\n\t\t}\n\n\t\tws['pingTime'] = new Date();\n\n\t\ttry {\n\t\t\tif (typeof ws.ping === 'function') {\n\t\t\t\tws.ping();\n\t\t\t}\n\t\t}\n\t\tcatch (err) {\n\t\t\tif (this._methodManager?.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Server App', 'Error WS Ping Frame', err);\n\t\t\t}\n\t\t\tawait this.unsubscribeWS(ws);\n\t\t\treturn;\n\t\t}\n\n\t\tws.send('ping', async (error) => {\n\t\t\tif (error) {\n\t\t\t\tif (this._methodManager?.getEnableDebug()) {\n\t\t\t\t\tconsole.log(new Date(), 'Server App', 'Error WS Ping');\n\t\t\t\t}\n\t\t\t\tawait this.unsubscribeWS(ws);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate shouldDeferHeartbeat(ws: WebSocket): boolean {\n\t\tif (!ws || ws.readyState !== ws.OPEN) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst bufferedAmount = typeof ws.bufferedAmount === 'number' ? ws.bufferedAmount : 0;\n\t\treturn bufferedAmount >= this._clientHeartbeatBackpressureBytes;\n\t}\n\n\tprivate async handleClientMessage(ws: WebSocket, msg: any[]): Promise<void> {\n\t\t// This is basically your old logic from processSocketMessage,\n\t\t// but we'll insert our worker-queue logic for \"method\" calls.\n\n\t\tlet messageRoute = msg[0];\n\t\tlet messageDate = msg[1];\n\t\tlet messageId = msg[2];\n\t\tlet type = msg[3];\n\n\t\tif (!this.publicProgram && this._clientRoutes.some(a => messageRoute.includes(a)) && !ws['doc_user'].roles.groups.some(a => a.views.some(b => messageRoute.includes(b) || b.includes(messageRoute))) && !ws['doc_user'].roles.super_admin) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (type === 'subscription') {\n\t\t\tlet subType = msg[4];\n\t\t\tlet pub = msg[5];\n\n\t\t\tif (subType === 'sub') {\n\t\t\t\tawait this._subscriptionManager.subscribe(messageRoute, messageDate, ws, messageId, pub, msg.slice(6));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._subscriptionManager.unsubscribe(messageRoute, messageDate, ws, messageId, pub, msg.slice(6));\n\t\t\t}\n\t\t}\n\t\telse if (!this.publicProgram && type === 'offline') {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: 'ACK'\n\t\t\t};\n\n\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\tthis._websocketManager.send(ws, serverRes);\n\t\t\t}\n\n\t\t\tthis._offlineUpdates.push(ws);\n\t\t\tlet offlineUpdates = msg[4];\n\n\t\t\tfor (let i = 0; i < offlineUpdates.length; i++) {\n\t\t\t\tlet update = offlineUpdates[i];\n\n\t\t\t\tlet data = update.data;\n\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tlet updateRoute = data.shift();\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tlet updateDate = data.shift();\n\t\t\t\tlet updateMessageId = data.shift();\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tlet updateType = data.shift();\n\t\t\t\tlet method = data.shift();\n\n\t\t\t\tlet serverResMethod: ServerResponseModel = {\n\t\t\t\t\tmessageId: updateMessageId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: 'ACK'\n\t\t\t\t};\n\n\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\tthis._websocketManager.send(ws, serverResMethod);\n\t\t\t\t}\n\n\t\t\t\tif (method === 'insertDocument' && data[0] === 'driver-gps') {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'getDrivers' && method !== 'processAirdropDistribution' && method !== 'qbHandleResponse') {\n\t\t\t\t\tif (\n\t\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t\t) {\n\t\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([data])) < 1000000 ? JSON.stringify([data], null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\troute: messageRoute\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\telse {\n\t\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([data])) < 1000000 ? JSON.stringify([data], null, 2) : 'Too Big',\n\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\troute: messageRoute,\n\t\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || ''\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._methodManager.callMethod.call(Object.assign({}, this._methodManager, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), method, ...data);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Offline Error', JSON.stringify(err, null, 2));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (method === 'updateDocumentOffline' || method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\tResolveIOServer.getMongoManager().invalidateQueryCache(data[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log('Offline - Could not find method: ' + method);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._offlineUpdates.splice(this._offlineUpdates.map(a => a['id_socket']).indexOf(ws['id_socket']), 1);\n\t\t}\n\t\telse {\n\t\t\t// It's presumably a 'method' or something else\n\t\t\tlet dataCopy = [...msg];\n\n\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\tlet route = dataCopy.shift();\n\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\tlet date = dataCopy.shift();\n\t\t\tlet msgId = dataCopy.shift();\n\t\t\tlet msgType = dataCopy.shift();\n\t\t\t\n\t\t\tif (msgType === 'method') {\n\t\t\t\tlet methodName = dataCopy.shift();\n\n\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (methodName !== 'reportBuilderGetResults' && methodName !== 'reportBuilderGetDistinctValue' && methodName !== 'reportBuilderBuildTree' && methodName !== 'generatePDF' && methodName !== 'getWOOfflineData' && methodName !== 'countQuery' && methodName !== 'countWithQuery' && methodName !== 'countCollectionWithQuery' && methodName !== 'find' && methodName !== 'findOne' && methodName !== 'findWithOptions' && methodName !== 'getDrivers' && methodName !== 'processAirdropDistribution') {\n\t\t\t\t\tif (\n\t\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t\t\t) {\n\t\t\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\t\t\ttype: 'log',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([dataCopy])) < 1000000 ? JSON.stringify([dataCopy], null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\troute: messageRoute\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\telse {\n\t\t\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([dataCopy])) < 1000000 ? JSON.stringify([dataCopy], null, 2) : 'Too Big',\n\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\troute: messageRoute,\n\t\t\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || ''\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Immediately ACK\n\t\t\t\tlet ack: ServerResponseModel = {\n\t\t\t\t\tmessageId: msgId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: 'ACK'\n\t\t\t\t};\n\n\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\tthis._websocketManager.send(ws, ack);\n\t\t\t\t}\n\n\t\t\t\tlet method = this._methodManager.getMethod(methodName);\n\n\t\t\t\tif (method &&\n\t\t\t\t\t!method.skipWorker &&\n\t\t\t\t\tthis._isWorkersEnabled &&\n\t\t\t\t\tthis._workerDispatcherManager &&\n\t\t\t\t\tthis._workerDispatcherManager.hasWorkers() &&\n\t\t\t\t\tmethodName !== 'find' &&\n\t\t\t\t\tmethodName !== 'insertDocument' &&\n\t\t\t\t\tmethodName !== 'countWithQuery' &&\n\t\t\t\t\tmethodName !== 'findOne' &&\n\t\t\t\t\tmethodName !== 'updateDocumentProps' &&\n\t\t\t\t\tmethodName !== 'findWithOptions' &&\n\t\t\t\t\tmethodName !== 'updateDocument' &&\n\t\t\t\t\tmethodName !== 'insertErrorLog' &&\n\t\t\t\t\tmethodName !== 'removeDocument' &&\n\t\t\t\t\tmethodName !== 'supportCreateBillingUser' &&\n\t\t\t\t\tmethodName !== 'getSignedUrl' &&\n\t\t\t\t\tmethodName !== 'getSignedUrls' &&\n\t\t\t\t\tmethodName !== 'getSignedUrlWithId' &&\n\t\t\t\t\tmethodName !== 'incorrectUser' &&\n\t\t\t\t\tmethodName !== 'reloadWS' &&\n\t\t\t\t\tmethodName !== 'reconnectWS' &&\n\t\t\t\t\tmethodName !== 'disconnectWS'\n\t\t\t\t) {\n\t\t\t\t\tthis._workerDispatcherManager.sendClientTask(msgId, methodName, dataCopy, {\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\tid_ws: ws['id_socket']\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// No worker available: do method locally\n\t\t\t\t\tawait this.callMethodLocally(ws, msgId, methodName, dataCopy);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * callMethodLocally is your old approach for invoking the method in-process.\n\t */\n\tprivate async callMethodLocally(ws: WebSocket, messageId: number, method: string, params: any[]) {\n\t\tlet serverRes: ServerResponseModel = {\n\t\t\tmessageId: messageId,\n\t\t\thasError: false,\n\t\t\tdata: null\n\t\t};\n\n\t\ttry {\n\t\t\t// You can keep your logging code (LogMethodLatencies, Logs.insertOne, etc.)\n\t\t\tlet result = await this._methodManager.callMethod.call(\n\t\t\t\tObject.assign({}, this._methodManager, MethodManager.prototype, {\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\tid_ws: ws['id_socket']\n\t\t\t\t}),\n\t\t\t\tmethod,\n\t\t\t\t...params\n\t\t\t);\n\n\t\t\tserverRes.data = result;\n\t\t}\n\t\tcatch (err) {\n\t\t\tserverRes.hasError = true;\n\t\t\tserverRes.data = err || 'Unknown error';\n\t\t}\n\n\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\tthis._websocketManager.send(ws, serverRes);\n\t\t}\n\t}\n\n\t\n\n\t/**\n\t * Cleanly remove a client from the subscription manager, etc.\n\t */\n\tpublic async unsubscribeWS(ws: WebSocket) {\n\t\tif (this._subscriptionManager && this._methodManager.getEnableDebug()) {\n\t\t\tconsole.log(new Date(), 'Server App', 'Unsub WS', ws['user'], ws['id_socket']);\n\t\t}\n\t\tawait this._subscriptionManager.unsubscribeAll(ws);\n\t\tws.removeAllListeners();\n\t\tws = null;\n\t}\n\n\tpublic getApp() {\n\t\treturn this._app;\n\t}\n\n\tpublic getServerConfig() {\n\t\treturn ResolveIOServer.getServerConfig();\n\t}\n\n\tpublic getWorkerDispatcherManager() {\n\t\treturn this._workerDispatcherManager;\n\t}\n\n\tpublic getWorkerServerManager() {\n\t\treturn this._workerServerManager;\n\t}\n}\n"]}
|