@resolveio/server-lib 20.11.8 → 20.11.10
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/client-server-app.js +2 -2
- package/collections/app-status.collection.js.map +1 -1
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +2 -2
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/flag-update.collection.js.map +1 -1
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-function.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.d.ts +5 -5
- package/cron/cron.js +169 -51
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +3 -4
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +3 -4
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +13 -14
- package/http/auth.js.map +1 -1
- package/http/health.js +3 -4
- package/http/health.js.map +1 -1
- package/http/home.js +5 -6
- package/http/home.js.map +1 -1
- package/managers/cron.manager.js +95 -59
- package/managers/cron.manager.js.map +1 -1
- package/managers/local-log.manager.js.map +1 -1
- package/managers/method.manager.js +12 -12
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +6 -7
- package/managers/mongo.manager.js +135 -138
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +2 -2
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +20 -20
- package/managers/subscription.manager.js.map +1 -1
- package/managers/websocket.manager.js.map +1 -1
- package/managers/worker-dispatcher.manager.js.map +1 -1
- package/managers/worker-server.manager.js +6 -6
- package/managers/worker-server.manager.js.map +1 -1
- package/methods/accounts.js +7 -8
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +3 -4
- package/methods/aws.js.map +1 -1
- package/methods/collections.js +3 -4
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +3 -4
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +4 -5
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flag-updates.js +1 -2
- package/methods/flag-updates.js.map +1 -1
- package/methods/flags.js +1 -2
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +4 -5
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +3 -4
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +30 -31
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +16 -17
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +3 -4
- package/methods/support.js.map +1 -1
- package/package.json +57 -59
- package/private/images/ResolveIO.png +0 -0
- package/publications/app-status.js +1 -2
- package/publications/app-status.js.map +1 -1
- package/publications/cron-jobs.js +1 -2
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -2
- package/publications/files.js.map +1 -1
- package/publications/flags-update.js +1 -2
- package/publications/flags-update.js.map +1 -1
- package/publications/flags.js +1 -2
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -2
- package/publications/logs.js.map +1 -1
- package/publications/notifications.js +1 -2
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -2
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +3 -4
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -2
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -2
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -2
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -2
- package/publications/user-guides.js.map +1 -1
- package/resolveio-server-app.js +10 -10
- package/resolveio-server-app.js.map +1 -1
- package/server-app.d.ts +0 -1
- package/server-app.js +18 -10
- package/server-app.js.map +1 -1
- package/util/common.js +24 -25
- package/util/common.js.map +1 -1
- package/util/error-reporter.js +3 -3
- package/util/error-reporter.js.map +1 -1
- package/util/error-tracking.js +7 -8
- package/util/error-tracking.js.map +1 -1
- package/util/schema-report-builder.js +7 -8
- package/util/schema-report-builder.js.map +1 -1
- package/util/subscription-dependency-context.js +5 -6
- package/util/subscription-dependency-context.js.map +1 -1
|
@@ -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,g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cesContent":["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\tthis.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\tthis.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\tthis.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\tthis._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\tthis._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 removeCronJob(cron_name: string) {\n\t\tif (this.doesCronJobNameExist(cron_name)) {\n\t\t\tthis._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 stopCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tthis._cronManager.stop(cron.name);\n\t\t}\n\t}\n\n\tprivate stopAllCronJobs() {\n\t\tthis._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}"]}
|
|
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,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AE,GAAG,CAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAC,EAAC,CAAC,EAAA;;wBAAtF,SAAsF,CAAC;;6BAGvF,qBAAM,8BAAQ,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAC,CAAC,EAAA;;wBAAxC,SAAwC,CAAC;;6BAG1C,qBAAM,8CAAgB,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,aAAW,CAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAE;gCAC/D,cAAc,EAAE,KAAK;gCACrB,MAAM,EAAE,aAAW,CAAC,MAAM;gCAC1B,KAAK,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}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":[],"mappings":";;;AAAA;;iBAEiB;AACjB,uBAAyB;AACzB,gEAA0D;AAgB1D;IAGC;IAAe,CAAC;IAET,sBAAM,GAAb;QACC,IAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,eAAe,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,eAAe,CAAC;IACxB,CAAC;IAEO,oCAAU,GAAlB;QACC,IACC,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,KAAK,uBAAuB;eACtE,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,KAAK,uBAAuB,EAC3E;
|
|
1
|
+
{"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":[],"mappings":";;;AAAA;;iBAEiB;AACjB,uBAAyB;AACzB,gEAA0D;AAgB1D;IAGC;IAAe,CAAC;IAET,sBAAM,GAAb;QACC,IAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,eAAe,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,eAAe,CAAC;IACxB,CAAC;IAEO,oCAAU,GAAlB;QACC,IACC,sCAAe,CAAC,eAAe,EAAE,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\n****************/\nimport * as fs from 'fs';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nexport type LocalLogType = 'monitor-mongo' \n\t| 'monitor-memory'\n\t| 'monitor-cpu'\n\t| 'monitor-function'\n\t| 'log'\n\t| 'log-subscription'\n\t| 'log-method-latency';\n\nexport interface LocalLogModel {\n\ttype: LocalLogType;\n\tdata: any;\n\tinstance_index?: string;\n}\n\nexport class LocalLogManager {\n\tprivate _logFilePath: string;\n\n\tconstructor() {}\n\n\tstatic create() {\n\t\tconst localLogManager = new LocalLogManager();\n\t\tlocalLogManager.initialize();\n\t\treturn localLogManager;\n\t}\n\n\tprivate initialize() {\n\t\tif (\n\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t) {\n\t\t\tif (!fs.existsSync('/home/ubuntu/resolveio/logs')) {\n\t\t\t\tfs.mkdirSync('/home/ubuntu/resolveio/logs');\n\t\t\t}\n\t\t}\n\t\t\n\t\tthis._logFilePath = '/home/ubuntu/resolveio/logs/local-logs.jsonl';\n\t}\n\n\t// Internal method to append a JSON line to the file\n\tpublic writeLog(logEntry: LocalLogModel): void {\n\t\ttry {\n\t\t\tlogEntry.instance_index = process.env.NODE_APP_INSTANCE || '';\n\n\t\t\tlet log = JSON.stringify(logEntry) + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, log, { encoding: 'utf8' });\n\t\t}\n\t\tcatch(err) {\n\t\t\t// If there's an error writing logs, you might want to handle it or queue it\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write log to file:', err);\n\t\t}\n\t}\n\n\tpublic writeLogs(logEntries: LocalLogModel[]): void {\n\t\tif (!logEntries || logEntries.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert each item to a JSON string, add newline\n\t\t\tlet logs = logEntries.map(logEntry => {\n\t\t\t\tlogEntry.instance_index = process.env.NODE_APP_INSTANCE || '';\n\t\t\t\treturn JSON.stringify(logEntry);\n\t\t\t}).join('\\n') + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, logs, { encoding: 'utf8' });\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write logs batch:', err);\n\t\t}\n\t}\n\n\t/**\n\t * Reads all logs from disk, then empties the file.\n\t */\n\tpublic offloadLogs(): any[] {\n\t\tlet result = [];\n\n\t\ttry {\n\t\t\tif (!fs.existsSync(this._logFilePath)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tlet fileData = fs.readFileSync(this._logFilePath, 'utf8');\n\t\t\tif (fileData.trim().length === 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tresult = fileData.split('\\n').filter(l => l.trim() !== '');\n\n\t\t\t// Truncate the file so we don't send logs more than once\n\t\t\tfs.writeFileSync(this._logFilePath, '');\n\t\t}\n\t\tcatch(err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to offload logs:', err);\n\t\t}\n\n\t\treturn result;\n\t}\n}"]}
|
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -296,9 +296,9 @@ var MethodManager = /** @class */ (function () {
|
|
|
296
296
|
}));
|
|
297
297
|
if (!resolveio_server_app_1.ResolveIOServer.getSESMail()) {
|
|
298
298
|
this._mailerCustom = nodemailer.createTransport({
|
|
299
|
-
host: resolveio_server_app_1.ResolveIOServer.getServerConfig()['MAIL_HOST'],
|
|
300
|
-
port: resolveio_server_app_1.ResolveIOServer.getServerConfig()['MAIL_PORT'],
|
|
301
|
-
secure: false,
|
|
299
|
+
host: resolveio_server_app_1.ResolveIOServer.getServerConfig()['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server
|
|
300
|
+
port: resolveio_server_app_1.ResolveIOServer.getServerConfig()['MAIL_PORT'], //587, // secure SMTP
|
|
301
|
+
secure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely
|
|
302
302
|
auth: {
|
|
303
303
|
user: resolveio_server_app_1.ResolveIOServer.getServerConfig()['MAIL_USERNAME'],
|
|
304
304
|
pass: resolveio_server_app_1.ResolveIOServer.getServerConfig()['MAIL_PASSWORD']
|
|
@@ -347,9 +347,9 @@ var MethodManager = /** @class */ (function () {
|
|
|
347
347
|
this._methods = Object.assign(this._methods, method);
|
|
348
348
|
};
|
|
349
349
|
MethodManager.prototype.reportMethodError = function (subject, correlationId, context, meta, stack) {
|
|
350
|
-
var _a, _b;
|
|
351
350
|
return __awaiter(this, void 0, void 0, function () {
|
|
352
351
|
var metadata;
|
|
352
|
+
var _a, _b;
|
|
353
353
|
return __generator(this, function (_c) {
|
|
354
354
|
switch (_c.label) {
|
|
355
355
|
case 0:
|
|
@@ -578,8 +578,8 @@ var MethodManager = /** @class */ (function () {
|
|
|
578
578
|
if (!(!method.bypassSession &&
|
|
579
579
|
!session &&
|
|
580
580
|
![
|
|
581
|
-
'insertErrorLog',
|
|
582
|
-
'countWithQuery',
|
|
581
|
+
'insertErrorLog', // CIRCULAR LOOP - DO NOT REMOVE
|
|
582
|
+
'countWithQuery', // MONGO SESSIONS/TRANSACTIONS DONT WORK WITH COUNTS
|
|
583
583
|
'sendEmail' // ALWAYS SEND SO ALWAYS HAVE RECORD - DONT ROLL BACK - BYPASS SESSION
|
|
584
584
|
].includes(methodName) &&
|
|
585
585
|
!methodName.startsWith('monitor-') &&
|
|
@@ -1114,11 +1114,11 @@ var MethodManager = /** @class */ (function () {
|
|
|
1114
1114
|
});
|
|
1115
1115
|
});
|
|
1116
1116
|
};
|
|
1117
|
-
MethodManager.prototype.sendEmail = function (
|
|
1118
|
-
|
|
1119
|
-
if (local_override === void 0) { local_override = false; }
|
|
1120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1117
|
+
MethodManager.prototype.sendEmail = function (sendTo_1, subject_1, text_1, html_1, attachments_1, send_from_1, reply_to_1) {
|
|
1118
|
+
return __awaiter(this, arguments, void 0, function (sendTo, subject, text, html, attachments, send_from, reply_to, force_ses, local_override, options) {
|
|
1121
1119
|
var normalizedSubject, correlationId, finalSubject, groupByCorrelationId, normalizedText, normalizedHtml, occurrence, allowGrouping, normalizedAttachments, merged, emailHistory, _a, aggregatedText, aggregatedHtml, history_1, err_7;
|
|
1120
|
+
if (force_ses === void 0) { force_ses = false; }
|
|
1121
|
+
if (local_override === void 0) { local_override = false; }
|
|
1122
1122
|
return __generator(this, function (_b) {
|
|
1123
1123
|
switch (_b.label) {
|
|
1124
1124
|
case 0:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/method.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwC;AACxC,uBAAyB;AACzB,uCAAyC;AACzC,uDAAyD;AACzD,2BAA6B;AAC7B,oFAAyE;AACzE,kEAAuD;AACvD,gEAAqD;AACrD,mDAA2D;AAC3D,yCAAkD;AAClD,gDAAyD;AACzD,sCAAgD;AAChD,sDAA+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AI,CAAC,sCAAe,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;iBACvG;gBACD,OAAO,GAAG,EAAE;oBACX,GAAG,CAAC,OAAO,GAAG,8BAAuB,GAAG,CAAC,OAAO,CAAE,CAAC;oBACnD,MAAM,GAAG,CAAC;iBACV;aACD;SACD;QAED,MAAM,IAAI,KAAK,CAAE,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAEM,sCAAc,GAArB;QACC,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACF,oBAAC;AAAD,CAnhCA,AAmhCC,IAAA;AAnhCY,sCAAa","file":"method.manager.js","sourcesContent":["import { S3 } from '@aws-sdk/client-s3';\nimport * as fs from 'fs';\nimport * as nodemailer from 'nodemailer';\nimport * as sesTransport from 'nodemailer-ses-transport';\nimport * as path from 'path';\nimport { EmailHistories } from '../collections/email-history.collection';\nimport { Flags } from '../collections/flag.collection';\nimport { Logs } from '../collections/log.collection';\nimport { loadServerCronJobs } from '../fixtures/cron-jobs';\nimport { loadServerInit } from '../fixtures/init';\nimport { loadAccountMethods } from '../methods/accounts';\nimport { loadAWSMethods } from '../methods/aws';\nimport { loadCollectionMethods } from '../methods/collections';\nimport { loadCounterMethods } from '../methods/counters';\nimport { loadCronJobMethods } from '../methods/cron-jobs';\nimport { loadFlagUpdatesMethods } from '../methods/flag-updates';\nimport { loadFlagMethods } from '../methods/flags';\nimport { loadLogMethods } from '../methods/logs';\nimport { loadMonitorMethods } from '../methods/monitor';\nimport { loadPDFMethods } from '../methods/pdf';\nimport { loadReportBuilderMethods } from '../methods/report-builder';\nimport { loadSupportMethods } from '../methods/support';\nimport { EmailHistoryModel, EmailHistoryOccurrence } from '../models/email-history.model';\nimport { MethodAllModel, MethodModel } from '../models/method.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { getBinarySize, objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\nimport { ensureErrorWithCorrelation, getCorrelationId, runWithCorrelationContext } from '../util/error-tracking';\nimport { MonitorManagerFunction } from './monitor.manager';\nimport { WebSocketManager } from './websocket.manager';\n\ninterface SendEmailOptions {\n\tcorrelationId?: string;\n\tmeta?: Record<string, any>;\n}\n\nfunction appendCorrelationIdToSubject(subject: string, correlationId?: string): string {\n\tif (!correlationId) {\n\t\treturn subject;\n\t}\n\n\tconst correlationTag = `[${correlationId}]`;\n\n\tif (subject && subject.includes(correlationTag)) {\n\t\treturn subject;\n\t}\n\n\treturn `${subject} ${correlationTag}`.trim();\n}\n\nfunction createEmailOccurrence(subject: string, text?: string, html?: string, meta?: Record<string, any>): EmailHistoryOccurrence {\n\treturn {\n\t\t_id: objectIdHexString(),\n\t\tcreatedAt: new Date(),\n\t\tsubject,\n\t\ttext,\n\t\thtml,\n\t\tmeta\n\t};\n}\n\nfunction formatGroupedEmailContent(correlationId: string, occurrences: EmailHistoryOccurrence[]): { text: string; html: string } {\n\tconst lines: string[] = [];\n\tlines.push(`Correlation ID: ${correlationId}`);\n\n\toccurrences.forEach((occurrence, index) => {\n\t\tconst timestamp = occurrence.createdAt instanceof Date ? occurrence.createdAt.toISOString() : new Date(occurrence.createdAt).toISOString();\n\t\tlines.push('');\n\t\tlines.push(`Occurrence #${index + 1} (${timestamp})`);\n\t\tlines.push(`Subject: ${occurrence.subject}`);\n\t\tif (occurrence.text) {\n\t\t\tlines.push(occurrence.text);\n\t\t}\n\t});\n\n\tconst htmlSections = occurrences.map((occurrence, index) => {\n\t\tconst timestamp = occurrence.createdAt instanceof Date ? occurrence.createdAt.toISOString() : new Date(occurrence.createdAt).toISOString();\n\t\tconst escapedText = occurrence.text ? occurrence.text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>') : '';\n\t\treturn `<div><h4>Occurrence #${index + 1} (${timestamp})</h4><p><strong>Subject:</strong> ${occurrence.subject}</p>${escapedText ? `<pre>${escapedText}</pre>` : ''}</div>`;\n\t});\n\n\tconst html = [\n\t\t`<p><strong>Correlation ID:</strong> ${correlationId}</p>`,\n\t\t...htmlSections\n\t].join('');\n\n\treturn {\n\t\ttext: lines.join('\\n'),\n\t\thtml\n\t};\n}\n\nexport class AWS {\n\tprivate _s3: S3 = null;\n\tprivate _s3USEast1: S3 = null;\n\n\tconstructor() {}\n\n\tpublic create() {\n\t\tconst aws = new AWS();\n\t\taws.initialize();\n\t\treturn aws;\n\t}\n\n\tprivate initialize() {\n\n\t}\n\n\tpublic s3(): S3 {\n\t\tif (this._s3) {\n\t\t\treturn this._s3;\n\t\t}\n\n\t\tthis._s3 = new S3({\n\t\t\tcredentials: {\n\t\t\t\taccessKeyId: process.env.AWS_ACCESS_KEY,\n\t\t\t\tsecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY\n\t\t\t},\n\t\t\tregion: process.env.AWS_REGION,\n\t\t\tapiVersion: '2006-03-01'\n\t\t});\n\n\t\treturn this._s3;\n\t}\n\n\tpublic s3USEast1(): S3 {\n\t\tif (process.env.AWS_REGION === 'us-east-1') {\n\t\t\treturn this.s3();\n\t\t}\n\t\telse {\n\t\t\tif (this._s3USEast1) {\n\t\t\t\treturn this._s3USEast1;\n\t\t\t}\n\t\t\t\n\t\t\tthis._s3USEast1 = new S3({\n\t\t\t\tcredentials: {\n\t\t\t\t\taccessKeyId: process.env.AWS_ACCESS_KEY,\n\t\t\t\t\tsecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY\n\t\t\t\t},\n\t\t\t\tregion: 'us-east-1',\n\t\t\t\tapiVersion: '2006-03-01'\n\t\t\t});\n\t\n\t\t\treturn this._s3USEast1;\n\t\t}\n\t}\n}\n\nexport class MethodManager {\n\tprivate _websocketManager: WebSocketManager;\n\tpublic _methods: MethodModel = {};\n\tprivate _mailerSES: nodemailer.Transporter;\n\tprivate _mailerCustom: nodemailer.Transporter;\n\tprivate _aws: AWS;\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\tprivate _isWorkersEnabled = false;\n\tprivate _isWorkerInstance = false;\n\n\tprivate emailQueue: Set<string> = new Set(); // Set to store pending email IDs\n\tprivate isEmailProcessing = false;\n\tprivate readonly _emailProcessingDelayMs = 5000;\n\n\tprivate _debugcallMethodHits = 0;\n\tprivate _debugCallMethodHits = 0;\n\tprivate _debugCallMethodCronJobHits = 0;\n\tprivate _debugSendQueueHits = 0;\n\tprivate _enableDebug = false;\n\n\tpublic clientDir = '';\n\tpublic serverConfig: Record<string, any> = {};\n\n\tconstructor() {}\n\n\tstatic create(websocketManager: WebSocketManager, monitorManagerFunction: MonitorManagerFunction, isWorkersEnabled, isWorkerInstance) {\n\t\tconst methodManager = new MethodManager();\n\t\tmethodManager.initialize(websocketManager, monitorManagerFunction, isWorkersEnabled, isWorkerInstance);\n\t\treturn methodManager;\n\t}\n\n\tprivate initialize(websocketManager: WebSocketManager, monitorManagerFunction: MonitorManagerFunction, isWorkersEnabled, isWorkerInstance) {\n\t\tthis._websocketManager = websocketManager;\n\t\tthis._monitorManagerFunction = monitorManagerFunction;\n\t\tthis._isWorkersEnabled = isWorkersEnabled;\n\t\tthis._isWorkerInstance = isWorkerInstance;\n\t\t\n\t\tthis.clientDir = ResolveIOServer.getClientDir();\n\t\tthis.serverConfig = ResolveIOServer.getServerConfig();\n\n\t\t// Fixtures\n\t\tif (!process.env.IS_WORKERS_ENABLED || process.env.IS_WORKERS_ENABLED === 'false' || (process.env.IS_WORKER_INSTANCE === 'true' && process.env.WORKER_INDEX === '0')) {\n\t\t\tif (!process.env.NODE_APP_INSTANCE || process.env.NODE_APP_INSTANCE === '0') {\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tconsole.log(new Date(), 'Start Server Fixture');\n\t\t\t\t\tawait loadServerInit();\n\t\t\t\t\tconsole.log(new Date(), 'End Server Fixture');\n\t\t\t\t}, 5000);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsetImmediate(async () => {\n\t\t\t// Methods\n\t\t\tawait loadServerCronJobs();\n\n\t\t\tloadAccountMethods(this);\n\t\t\tloadAWSMethods(this);\n\t\t\tloadCollectionMethods(this);\n\t\t\tloadCounterMethods(this);\n\t\t\tloadLogMethods(this);\n\t\t\tloadPDFMethods(this);\n\t\t\tloadCronJobMethods(this);\n\t\t\tloadFlagMethods(this);\n\t\t\tloadFlagUpdatesMethods(this);\n\t\t\tloadReportBuilderMethods(this);\n\t\t\tloadSupportMethods(this);\n\t\t\tloadMonitorMethods(this);\n\n\t\t\tlet flag = await Flags.findOne({type: 'Enable Debug'});\n\t\n\t\t\tif (flag && flag.value) {\n\t\t\t\tthis._enableDebug = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._enableDebug = false;\n\t\t\t}\n\n\t\t\tawait this.loadPendingEmails();\n\t\t});\n\t\t\n\t\tthis._aws = new AWS();\n\n\t\tthis._mailerSES = nodemailer.createTransport(sesTransport({\n\t\t\taccessKeyId: process.env.AWS_ACCESS_KEY,\n\t\t\tsecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n\t\t\tregion: process.env.AWS_SES_REGION\n\t\t}));\n\t\t\n\t\tif (!ResolveIOServer.getSESMail()) {\n\t\t\tthis._mailerCustom = nodemailer.createTransport({\n\t\t\t\thost: ResolveIOServer.getServerConfig()['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server\n\t\t\t\tport: ResolveIOServer.getServerConfig()['MAIL_PORT'], //587, // secure SMTP\n\t\t\t\tsecure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely\n\t\t\t\tauth: {\n\t\t\t\t\tuser: ResolveIOServer.getServerConfig()['MAIL_USERNAME'],\n\t\t\t\t\tpass: ResolveIOServer.getServerConfig()['MAIL_PASSWORD']\n\t\t\t\t},\n\t\t\t\ttls: {\n\t\t\t\t\tciphers: 'SSLv3'\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tsetInterval(async () => {\n\t\t\tlet flag = await Flags.findOne({type: 'Enable Debug'});\n\t\n\t\t\tif (flag && flag.value) {\n\t\t\t\tthis._enableDebug = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._enableDebug = false;\n\t\t\t}\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Send Queue Hits', this._debugSendQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Call Method Internal Hits', this._debugcallMethodHits);\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Call Method Hits', this._debugCallMethodHits);\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Call Method Cron Hits', this._debugCallMethodCronJobHits);\n\t\t\t}\n\n\t\t\tthis._debugcallMethodHits = 0;\n\t\t\tthis._debugCallMethodHits = 0;\n\t\t\tthis._debugCallMethodCronJobHits = 0;\n\t\t\tthis._debugSendQueueHits = 0;\n\t\t}, 60000);\n\n\t\tif (!this._isWorkersEnabled || this._isWorkerInstance) {\n\t\t\tthis.setupEmailWatcher();\n\t\t}\n\t}\n\n\tpublic getMethod(methodName: string): MethodAllModel {\n\t\treturn this._methods[methodName];\n\t}\n\n\t// Add methods to private methods object\n\tpublic methods(method: MethodModel) {\n\t\tthis._methods = Object.assign(this._methods, method);\n\t}\n\n\tprivate async reportMethodError(\n\t\tsubject: string,\n\t\tcorrelationId: string,\n\t\tcontext: Record<string, any> | string,\n\t\tmeta: Record<string, any>,\n\t\tstack?: string\n\t) {\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: 'method-manager',\n\t\t\tmessage: subject,\n\t\t\tenvironment: this.serverConfig?.ROOT_URL,\n\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\tclientName: this.serverConfig?.CLIENT_NAME,\n\t\t\tseverity: 'error',\n\t\t\tstack,\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tcorrelationId\n\t\t});\n\t}\n\n\tpublic async callMethodCron(method: string, ...methodData: any[]) {\n\t\tthis._debugCallMethodCronJobHits += 1;\n\n\t\tconst existingCorrelationId = getCorrelationId();\n\t\tconst correlationId = existingCorrelationId || objectIdHexString();\n\n\t\tconst execute = async () => {\n\t\t\tconst cronMethod = this._methods[method];\n\n\t\t\tif (!cronMethod) {\n\t\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\t{ message: 'No Method registered for cron execution', method },\n\t\t\t\t\t{ context: 'callMethodCron', method }\n\t\t\t\t);\n\n\t\t\t\tthrow new Error('No Method: ' + method);\n\t\t\t}\n\t\t\t\n\t\t\tif ((methodData.length > 1 || methodData[0]) && !cronMethod.skipValidation) {\n\t\t\t\tif (!cronMethod.check) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Function For Cron Method ' + method);\n\n\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\t{ message: 'Missing check function for cron method', method },\n\t\t\t\t\t\t{ context: 'callMethodCron-validation', method }\n\t\t\t\t\t);\n\t\t\n\t\t\t\t\tthrow new Error('No Check Function For Cron Method ' + method);\n\t\t\t\t}\n\t\t\t\telse if (!cronMethod.check._schema) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Schema For Cron Method ' + method);\n\n\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\t{ message: 'Missing check schema for cron method', method },\n\t\t\t\t\t\t{ context: 'callMethodCron-validation', method }\n\t\t\t\t\t);\n\t\t\n\t\t\t\t\tthrow new Error('No Check Schema For Cron Method ' + method);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconst valObj = {};\n\t\t\t\t\tconst valKeys = Object.keys(cronMethod.check._schema);\n\n\t\t\t\t\tconst rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcronMethod.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\tconsole.error(new Date(), 'Error in Cron Method Check (' + method + ')', err);\n\n\t\t\t\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmessage: 'Match error on cron method',\n\t\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\t\tdata: valObj,\n\t\t\t\t\t\t\t\t\tvalidationError: normalizedError\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{ context: 'callMethodCron-validation-error', method },\n\t\t\t\t\t\t\t\tnormalizedError.stack\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Cron Method Check (${method}): ${normalizedError.message}`;\n\n\t\t\t\t\t\t\tthrow normalizedError;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst monitor = this._monitorManagerFunction.startMonitorFunction('Cron Method', method, '', '', methodData);\n\n\t\t\ttry {\n\t\t\t\tconst res = await cronMethod.function.call(Object.assign({}, this, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData);\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: 'Error detected during cron method execution',\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tdata: methodData,\n\t\t\t\t\t\terror: normalizedError\n\t\t\t\t\t},\n\t\t\t\t\t{ context: 'callMethodCron-execution', method },\n\t\t\t\t\tnormalizedError.stack\n\t\t\t\t);\n\t\t\t\t\n\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Cron Method (${method}): ${normalizedError.message}`;\n\t\t\t\t\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t}\n\t\t};\n\n\t\treturn await runWithCorrelationContext(correlationId, execute);\n\t}\n\n\t// Call/run method internal (No Emit on Socket)\n\tpublic async callMethod(methodName: string, ...methodData: any[]): Promise<any> {\n\t\tthis._debugcallMethodHits += 1;\n\n\t\tconst existingCorrelationId = getCorrelationId();\n\t\tconst correlationId = existingCorrelationId || objectIdHexString();\n\n\t\treturn await runWithCorrelationContext(correlationId, async () => await this.callMethodInternal(correlationId, methodName, methodData));\n\t}\n\n\tprivate async callMethodInternal(correlationId: string, methodName: string, methodData: any[]): Promise<any> {\n\t\tconst method = this.getMethod(methodName);\n\n\t\tif (!method) {\n\t\t\tconsole.log('No Method: ' + methodName);\n\t\t\tthrow new Error(`No Method: ${methodName}`);\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof methodData[0] !== 'function')) && !method.skipValidation) {\n\t\t\tif (!method.check) {\n\t\t\t\tconsole.error(new Date(), 'No Check Function For Method ' + methodName);\n\t\t\t\tthrow new Error(`No Check Function For Method: ${methodName}`);\n\t\t\t}\n\t\t\telse if (!method.check._schema) {\n\t\t\t\tconsole.error(new Date(), 'No Check Schema For Method ' + methodName);\n\t\t\t\tthrow new Error(`No Check Schema For Method: ${methodName}`);\n\t\t\t}\n\t\t}\n\n\t\tif (methodName !== 'insertSubscriptionLog' && methodName !== 'getDataURIfromURL' && methodName !== 'processAirdropDistribution' && methodName !== 'incCounter' && methodName !== 'supportCreateBillingUser' && methodName !== 'countCollectionWithQuery') {\n\t\t\tif (\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t) {\n\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\ttype: 'log',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\ttype: 'callMethod',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([methodData])) < 1000000 ? JSON.stringify([methodData], null, 2) : 'Too Big',\n\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\tid_user: this['id_user'] || '',\n\t\t\t\t\t\tuser: this['user'] || '', \n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\ttype: 'callMethod',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tid_document: '',\n\t\t\t\t\tpayload: getBinarySize(JSON.stringify([methodData])) < 1000000 ? JSON.stringify([methodData], null, 2) : 'Too Big',\n\t\t\t\t\tmethod: methodName,\n\t\t\t\t\tid_user: this['id_user'] || '',\n\t\t\t\t\tuser: this['user'] || '',\n\t\t\t\t\tmessageId: 0,\n\t\t\t\t\troute: '',\n\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '',\n\t\t\t\t\tcorrelationId\n\t\t\t\t})\n\t\t\t};\n\t\t}\n\n\t\tconst functionMethodData = typeof(methodData[methodData.length - 1]) === 'function' ? methodData.slice(0, -1) : methodData;\n\n\t\tconst session = ResolveIOServer.getMongoManager().getSession();\n\n\t\tif (!method.bypassSession &&\n\t\t\t!session && \n\t\t\t![\n\t\t\t\t'insertErrorLog', // CIRCULAR LOOP - DO NOT REMOVE\n\t\t\t\t'countWithQuery', // MONGO SESSIONS/TRANSACTIONS DONT WORK WITH COUNTS\n\t\t\t\t'sendEmail' // ALWAYS SEND SO ALWAYS HAVE RECORD - DONT ROLL BACK - BYPASS SESSION\n\t\t\t].includes(methodName) &&\n\t\t\t!methodName.startsWith('monitor-') &&\n\t\t\t!methodName.startsWith('log')\n\t\t) {\n\t\t\tlet monitor = null;\n\t\t\t\n\t\t\treturn ResolveIOServer.getMongoManager().oneTimeTransaction(async () => {\n\t\t\t\t// console.log(new Date(), 'Calling Method - New Session', methodName);\n\n\t\t\t\tmonitor = this._monitorManagerFunction.startMonitorFunction('Method', methodName, this['user'] || '', '', functionMethodData);\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tlet res = await method.function.call(Object.assign({}, this, MethodManager.prototype), ...functionMethodData);\n\n\t\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\t\tmethodData[methodData.length - 1](null, res);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\tif (err.code === 112 || err.codeName === 'WriteConflict' || err.code === 251 || err.codeName === 'NoSuchTransaction') {\n\t\t\t\t\t\tthrow err; // Write error, retry\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\t\tconsole.log(JSON.stringify([new Date(), 'Error Method Manager - Run Method - New Session', methodName, {\n\t\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\t\tcodeName: normalizedError.codeName,\n\t\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t\t}], null, 2));\n\n\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: 'Error detected during method execution (new session)',\n\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\tdata: methodData,\n\t\t\t\t\t\t\terror: normalizedError\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ context: 'callMethod-new-session', methodName },\n\t\t\t\t\t\tnormalizedError.stack\n\t\t\t\t\t);\n\t\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Method With Session (${methodName}) - New Session: ${normalizedError.message}`;\n\n\t\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\t\tmethodData[methodData.length - 1](normalizedError, null);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!process.env.IS_WORKER_INSTANCE) {\n\t\t\t\t\t\tawait this.callMethod(\n\t\t\t\t\t\t\t'insertErrorLog',\n\t\t\t\t\t\t\t`Error in Method: ${methodName}`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\t\tmethodData,\n\t\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\t\t\t\t\tcodeName: normalizedError.codeName\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow normalizedError;\n\t\t\t\t}\n\t\t\t\tfinally {\n\t\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\t// console.log(new Date(), 'Calling Method - Existing Session', methodName);\n\n\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('Method', methodName, this['user'] || '', '', functionMethodData);\n\t\t\t\n\t\t\ttry {\n\t\t\t\tlet res = await method.function.call(Object.assign({}, this, MethodManager.prototype), ...functionMethodData);\n\n\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\tmethodData[methodData.length - 1](null, res);\n\t\t\t\t}\n\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tif (err.code === 112 || err.codeName === 'WriteConflict' || err.code === 251 || err.codeName === 'NoSuchTransaction') {\n\t\t\t\t\tthrow err; // Write error, retry\n\t\t\t\t}\n\n\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\tconsole.log(JSON.stringify([new Date(), 'Error Method Manager - Run Method - Existing Session', methodName, {\n\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\tcodeName: normalizedError.codeName,\n\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t}], null, 2));\n\n\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: 'Error detected during method execution (existing session)',\n\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\tdata: methodData,\n\t\t\t\t\t\terror: normalizedError\n\t\t\t\t\t},\n\t\t\t\t\t{ context: 'callMethod-existing-session', methodName },\n\t\t\t\t\tnormalizedError.stack\n\t\t\t\t);\n\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Method (${methodName}) - Existing Session: ${normalizedError.message}`;\n\t\t\t\t\n\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\tmethodData[methodData.length - 1](normalizedError, null);\n\t\t\t\t}\n\n\t\t\t\tif (!process.env.IS_WORKER_INSTANCE) {\n\t\t\t\t\tawait this.callMethod(\n\t\t\t\t\t\t'insertErrorLog',\n\t\t\t\t\t\t`Error in Method: ${methodName}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\tmethodData,\n\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\t\t\t\tcodeName: normalizedError.codeName\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t}\n\t\t}\n\t}\n\n\tsetupEmailWatcher() {\n\t\tconst changeStream = EmailHistories.watchCollection([]);\n\n\t\tchangeStream.on('change', async (change) => {\n\t\t\tif (change.operationType === 'insert' && change.fullDocument && change.fullDocument.status === 'pending') {\n\t\t\t\tthis.emailQueue.add(change.fullDocument._id.toString());\n\t\t\t\tawait this.tryProcessEmail();\n\t\t\t}\n\t\t\telse if (change.operationType === 'update' || change.operationType === 'replace') {\n\t\t\t\tconst updatedEmail = change.fullDocument;\n\t\t\t\tif (updatedEmail && updatedEmail.status !== 'pending' && this.emailQueue.has(updatedEmail._id.toString())) {\n\t\t\t\t\tthis.emailQueue.delete(updatedEmail._id.toString());\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.on('error', async err => {\n\t\t\tconsole.error('Email history changestream error', err);\n\t\t\tawait changeStream.close();\n\t\t})\n\t\t.on('close', () => {\n\t\t\tthis.setupEmailWatcher();\n\t\t});\n\t}\n\n\tasync loadPendingEmails() {\n\t\t// Load any pending emails on startup\n\t\tconst pendingEmails = await EmailHistories.find({ status: 'pending' }, {sort: {_id: 1}});\n\t\tfor (const email of pendingEmails) {\n\t\t\tthis.emailQueue.add(email._id.toString());\n\t\t}\n\t\t// Try to process emails\n\t\tawait this.tryProcessEmail();\n\t}\n\n\tasync tryProcessEmail() {\n\t\tif (this.isEmailProcessing || this.emailQueue.size === 0) {\n\t\t\treturn;\n\t\t}\n\t\n\t\tthis.isEmailProcessing = true;\n\t\n\t\ttry {\n\t\t\twhile (this.emailQueue.size > 0) {\n\t\t\t\tconst emailId = this.emailQueue.values().next().value;\n\t\t\t\tthis.emailQueue.delete(emailId);\n\t\n\t\t\t\tconst pendingEmail = await EmailHistories.findOne(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: emailId,\n\t\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif (!pendingEmail) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tlet queuedAt: Date;\n\t\t\t\tif (pendingEmail.date instanceof Date) {\n\t\t\t\t\tqueuedAt = pendingEmail.date;\n\t\t\t\t}\n\t\t\t\telse if (pendingEmail.createdAt instanceof Date) {\n\t\t\t\t\tqueuedAt = pendingEmail.createdAt;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tqueuedAt = new Date();\n\t\t\t\t}\n\n\t\t\t\tconst timeSinceQueued = Date.now() - queuedAt.getTime();\n\t\t\t\tconst remainingDelay = this._emailProcessingDelayMs - timeSinceQueued;\n\n\t\t\t\tif (remainingDelay > 0) {\n\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, remainingDelay));\n\t\t\t\t}\n\n\t\t\t\tconst emailHistory = await EmailHistories.findOneAndUpdate(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: emailId,\n\t\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$set: { status: 'processing', processingAt: new Date() },\n\t\t\t\t\t}\n\t\t\t\t);\n\t\n\t\t\t\tif (!emailHistory) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\n\t\t\t\t// Fetch and process attachments\n if (emailHistory.attachments && emailHistory.attachments.length > 0) {\n\t\t\t\t\tconst validAttachments: any[] = [];\n\t\t\t\t\tlet attachmentError = false;\n\n\t\t\t\t\tfor (const att of emailHistory.attachments) {\n\t\t\t\t\t\tif (att.path && att.path.startsWith('http')) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst response = await fetch(att.path);\n\t\t\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\t\t\tattachmentError = true;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst arrayBuffer = await response.arrayBuffer();\n\t\t\t\t\t\t\t\tconst buffer = Buffer.from(arrayBuffer);\n\n\t\t\t\t\t\t\t\t// Check the size of the attachment\n\t\t\t\t\t\t\t\tconst maxSize = 20 * 1024 * 1024; // 20MB in bytes\n\t\t\t\t\t\t\t\tif (buffer.length <= maxSize) {\n\t\t\t\t\t\t\t\t\t// Attachment is within size limits, include it\n\t\t\t\t\t\t\t\t\tatt.content = buffer;\n\t\t\t\t\t\t\t\t\tdelete att.path;\n\t\t\t\t\t\t\t\t\tvalidAttachments.push(att);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\t\tconsole.error('Failed to fetch attachment:', err);\n\t\t\t\t\t\t\t\tattachmentError = true;\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\tvalidAttachments.push(att);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\temailHistory.attachments = validAttachments;\n\t\t\t\t\tif (attachmentError) {\n\t\t\t\t\t\t\temailHistory.text =\n\t\t\t\t\t\t\t\t\t(typeof emailHistory.text === 'string' ? emailHistory.text : '') +\n\t\t\t\t\t\t\t\t\t'\\n\\nCould not load attachments.';\n\t\t\t\t\t\t\temailHistory.html =\n\t\t\t\t\t\t\t\t\t(typeof emailHistory.html === 'string' ? emailHistory.html : '') +\n\t\t\t\t\t\t\t\t\t'<p>Could not load attachments.</p>';\n\t\t\t\t\t}\n }\n\t\n\t\t\t\t// Prepare email options\n\t\t\t\tconst mailOptions: any = {\n\t\t\t\t\treplyTo: emailHistory.reply_to || (ResolveIOServer.getServerConfig()['MAIL_REPLY_TO'] || undefined),\n\t\t\t\t\tfrom: emailHistory.send_from || ResolveIOServer.getServerConfig().MAIL_FROM,\n\t\t\t\t\tto: emailHistory.email,\n\t\t\t\t\tsubject:\n\t\t\t\t\t\t(ResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/dev\\./) ||\n\t\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/www\\.dev\\./)\n\t\t\t\t\t\t\t? '(DEV SERVER) - '\n\t\t\t\t\t\t\t: '') + emailHistory.subject,\n\t\t\t\t\ttext: typeof emailHistory.text === 'string' ? emailHistory.text : '',\n\t\t\t\t\thtml: typeof emailHistory.html === 'string' ? emailHistory.html : '',\n\t\t\t\t\tattachments: emailHistory.attachments || [],\n\t\t\t\t\tforce_ses: emailHistory.force_ses\n\t\t\t\t};\n\t\n\t\t\t\t// Process attachments before sending\n\t\t\t\tif (mailOptions.attachments && mailOptions.attachments.length > 0) {\n\t\t\t\t\tmailOptions.attachments = mailOptions.attachments.map((att) => {\n\t\t\t\t\t\tconst newAtt = { ...att };\n\t\t\t\t\t\t// Handle attachments stored as BinData or Buffer\n\t\t\t\t\t\tif (newAtt.content && typeof newAtt.content === 'object' && !(newAtt.content instanceof Buffer)) {\n\t\t\t\t\t\t\t// Convert MongoDB's Binary data to Buffer\n\t\t\t\t\t\t\tif (newAtt.content._bsontype === 'Binary' && newAtt.content.sub_type === 0) {\n\t\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content.buffer);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Handle other types if necessary\n\t\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Handle attachments stored as Base64 strings\n\t\t\t\t\t\telse if (typeof newAtt.content === 'string' && newAtt.encoding === 'base64') {\n\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content, 'base64');\n\t\t\t\t\t\t\tdelete newAtt.encoding;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Ensure the content is a Buffer\n\t\t\t\t\t\telse if (typeof newAtt.content === 'string') {\n\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn newAtt;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\n\t\t\t\t// Send the email\n\t\t\t\t(!mailOptions.force_ses && this._mailerCustom ? this._mailerCustom : this._mailerSES).sendMail(mailOptions, async err => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\tconsole.error('Failed to send email:', err);\n\t\t\t\t\t\t\tawait EmailHistories.updateOne(\n\t\t\t\t\t\t\t\t{ _id: emailHistory._id },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\t\t\t\t\t\terror: typeof err === 'string' ? err : this.safeStringify(err),\n\t\t\t\t\t\t\t\t\t\tcompletedAt: new Date(),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (emailHistory.email === 'dev@resolveio.com') {\n\t\t\t\t\t\t\t\tawait EmailHistories.deleteOne({ _id: emailHistory._id });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tawait EmailHistories.updateOne(\n\t\t\t\t\t\t\t\t\t{ _id: emailHistory._id },\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\t\t\tstatus: 'completed',\n\t\t\t\t\t\t\t\t\t\t\tcompletedAt: new Date(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\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\tcatch (error) {\n\t\t\t\t\t\tconsole.error('Error in sendMail callback:', error);\n\t\t\t\t\t\tawait EmailHistories.updateOne(\n\t\t\t\t\t\t\t{ _id: emailHistory._id },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\t\t\t\t\terror: typeof error === 'string' ? error : this.safeStringify(error),\n\t\t\t\t\t\t\t\t\tcompletedAt: new Date(),\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\n\t\t\t\t// Wait for at least one second before sending the next email\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t\t\t}\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error('Error processing email queue:', err);\n\t\t}\n\t\tfinally {\n\t\t\tthis.isEmailProcessing = false;\n\t\t\t// Check if new emails arrived while processing\n\t\t\tif (this.emailQueue.size > 0) {\n\t\t\t\tawait this.tryProcessEmail();\n\t\t\t}\n\t\t}\n\t}\n\n\tsafeStringify(obj)\n\t{\n\t\ttry\n\t\t{\n\t\t\treturn JSON.stringify(obj, this.getCircularReplacer());\n\t\t}\n\t\tcatch (e)\n\t\t{\n\t\t\treturn `Error in JSON stringifying: ${e.message}`;\n\t\t}\n\t}\n\n\tgetCircularReplacer()\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\tprivate async tryMergeEmailOccurrence(\n\t\temail: string,\n\t\tsubject: string,\n\t\tcorrelationId: string,\n\t\toccurrence: EmailHistoryOccurrence,\n\t\tmeta?: Record<string, any>\n\t): Promise<EmailHistoryModel | null> {\n\t\tconst existing = await EmailHistories.findOne(\n\t\t\t{\n\t\t\t\temail,\n\t\t\t\tcorrelationId,\n\t\t\t\tstatus: 'pending'\n\t\t\t},\n\t\t\t{ sort: { date: 1 } }\n\t\t);\n\n\t\tif (!existing) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst normalizedOccurrences: EmailHistoryOccurrence[] = Array.isArray(existing.occurrences) && existing.occurrences.length\n\t\t\t? existing.occurrences.map((item: EmailHistoryOccurrence) => ({\n\t\t\t\t_id: item._id || objectIdHexString(),\n\t\t\t\tcreatedAt: item.createdAt instanceof Date ? item.createdAt : new Date(item.createdAt),\n\t\t\t\tsubject: item.subject || existing.subject || '',\n\t\t\t\ttext: item.text,\n\t\t\t\thtml: item.html,\n\t\t\t\tmeta: item.meta\n\t\t\t}))\n\t\t\t: [createEmailOccurrence(\n\t\t\t\texisting.subject || '',\n\t\t\t\ttypeof existing.text === 'string' ? existing.text : undefined,\n\t\t\t\ttypeof existing.html === 'string' ? existing.html : undefined,\n\t\t\t\texisting.meta\n\t\t\t)];\n\n\t\tnormalizedOccurrences.push(occurrence);\n\n\t\tconst { text: aggregatedText, html: aggregatedHtml } = formatGroupedEmailContent(correlationId, normalizedOccurrences);\n\n\t\tconst updated = await EmailHistories.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: existing._id,\n\t\t\t\tstatus: 'pending'\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tsubject,\n\t\t\t\t\ttext: aggregatedText,\n\t\t\t\t\thtml: aggregatedHtml,\n\t\t\t\t\toccurrences: normalizedOccurrences,\n\t\t\t\t\tmeta: meta || existing.meta,\n\t\t\t\t\tupdatedAt: new Date()\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ returnDocument: 'after' }\n\t\t);\n\n\t\treturn updated || null;\n\t}\n\n\tpublic async sendEmail(\n\t\tsendTo: string,\n\t\tsubject: string,\n\t\ttext?: string | null,\n\t\thtml?: string | null,\n\t\tattachments?: any[] | null,\n\t\tsend_from?: string | null,\n\t\treply_to?: string | null,\n\t\tforce_ses = false,\n\t\tlocal_override = false,\n\t\toptions?: SendEmailOptions\n\t) {\n\t\t// Modify sendTo in development environments\n\t\tif (\n\t\t\t(ResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/dev\\./) ||\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/www\\.dev\\./) ||\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] === 'http://localhost:4200') &&\n\t\t\t!sendTo.match(/\\@resolveio\\.com/)\n\t\t) {\n\t\t\tsendTo = 'dev@resolveio.com';\n\t\t}\n\n\t\tconst normalizedSubject = subject || '';\n\t\tconst correlationId = options?.correlationId;\n\t\tconst finalSubject = appendCorrelationIdToSubject(normalizedSubject, correlationId);\n\t\tconst groupByCorrelationId = !!correlationId;\n\t\tconst normalizedText = typeof text === 'string' ? text : '';\n\t\tconst normalizedHtml = typeof html === 'string' ? html : '';\n\t\tconst occurrence = groupByCorrelationId\n\t\t\t? createEmailOccurrence(normalizedSubject, normalizedText, normalizedHtml, options?.meta)\n\t\t\t: null;\n\t\tlet allowGrouping = groupByCorrelationId;\n\n\t\tif (sendTo) {\n\t\t\tif (\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200' ||\n\t\t\t\tlocal_override\n\t\t\t) {\n\t\t\t\tlet normalizedAttachments: any[] = [];\n\t\t\t\tif (Array.isArray(attachments)) {\n\t\t\t\t\tnormalizedAttachments = attachments.slice();\n\t\t\t\t}\n\t\t\t\telse if (attachments) {\n\t\t\t\t\tnormalizedAttachments = [attachments];\n\t\t\t\t}\n\n\t\t\t\tnormalizedAttachments = normalizedAttachments.map(att => {\n\t\t\t\t\tconst newAtt = { ...att };\n\t\t\t\t\tif (Buffer.isBuffer(newAtt.content)) {\n\t\t\t\t\t\tnewAtt.content = newAtt.content.toString('base64');\n\t\t\t\t\t\tnewAtt.encoding = 'base64';\n\t\t\t\t\t}\n\t\t\t\t\treturn newAtt;\n\t\t\t\t});\n\n\t\t\t\tif (normalizedAttachments.length > 0) {\n\t\t\t\t\tallowGrouping = false;\n\t\t\t\t}\n\n\t\t\t\tif (allowGrouping && occurrence && correlationId) {\n\t\t\t\t\tconst merged = await this.tryMergeEmailOccurrence(sendTo, finalSubject, correlationId, occurrence, options?.meta);\n\t\t\t\t\tif (merged) {\n\t\t\t\t\t\treturn merged;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst emailHistory: EmailHistoryModel = {\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\tid_user: this['id_user'] || '',\n\t\t\t\t\tuser: this['user'] || '',\n\t\t\t\t\temail: sendTo,\n\t\t\t\t\tsubject: finalSubject,\n\t\t\t\t\ttext: normalizedText,\n\t\t\t\t\thtml: normalizedHtml,\n\t\t\t\t\tattachments: normalizedAttachments,\n\t\t\t\t\tsend_from: send_from || '',\n\t\t\t\t\treply_to: reply_to || '',\n\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\terror: '',\n\t\t\t\t\tforce_ses\n\t\t\t\t};\n\n\t\t\t\tif (allowGrouping && occurrence && correlationId) {\n\t\t\t\t\tconst { text: aggregatedText, html: aggregatedHtml } = formatGroupedEmailContent(correlationId, [occurrence]);\n\t\t\t\t\temailHistory.text = aggregatedText;\n\t\t\t\t\temailHistory.html = aggregatedHtml;\n\t\t\t\t\temailHistory.occurrences = [occurrence];\n\t\t\t\t\temailHistory.correlationId = correlationId;\n\t\t\t\t\tif (options?.meta) {\n\t\t\t\t\t\temailHistory.meta = options.meta;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (correlationId) {\n\t\t\t\t\t\temailHistory.correlationId = correlationId;\n\t\t\t\t\t}\n\t\t\t\t\tif (options?.meta) {\n\t\t\t\t\t\temailHistory.meta = options.meta;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tlet history = await EmailHistories.insertOne(emailHistory);\n\t\t\t\t\treturn history;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\tconsole.error('Failed to queue email:', err);\n\t\t\t\t\terr.message = `Failed to queue email: ${err.message}`;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log(\n\t\t\t\t\t'Send email',\n\t\t\t\t\tsendTo,\n\t\t\t\t\tfinalSubject,\n\t\t\t\t\tnormalizedText,\n\t\t\t\t\tnormalizedHtml,\n\t\t\t\t\tattachments,\n\t\t\t\t\tsend_from,\n\t\t\t\t\tforce_ses,\n\t\t\t\t\tcorrelationId\n\t\t\t\t);\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tpublic getAWS(): AWS {\n\t\treturn this._aws;\n\t}\n\n\tpublic readFile(fileName) {\n\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\ttry {\n\t\t\t\treturn fs.readFileSync(path.join(__dirname, ('../private/' + fileName)), 'utf-8');\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\terr.message = `Error in readFile: ${err.message}`;\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (fs.existsSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)))) {\n\t\t\t\ttry {\n\t\t\t\t\treturn fs.readFileSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)), 'utf-8');\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.message = `Error in readFile: ${err.message}`;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error ('Error in readFile: File Not Found');\n\t}\n\n\tpublic readImage(fileName) {\n\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\ttry {\n\t\t\t\treturn fs.readFileSync(path.join(__dirname, ('../private/' + fileName)), 'base64');\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\terr.message = `Error in readImage: ${err.message}`;\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (fs.existsSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)))) {\n\t\t\t\ttry {\n\t\t\t\t\treturn fs.readFileSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)), 'base64');\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.message = `Error in readImage: ${err.message}`;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error ('Error in readImage: File Not Found');\n\t}\n\n\tpublic getEnableDebug() {\n\t\treturn this._enableDebug;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/method.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwC;AACxC,uBAAyB;AACzB,uCAAyC;AACzC,uDAAyD;AACzD,2BAA6B;AAC7B,oFAAyE;AACzE,kEAAuD;AACvD,gEAAqD;AACrD,mDAA2D;AAC3D,yCAAkD;AAClD,gDAAyD;AACzD,sCAAgD;AAChD,sDAA+D;AAC/D,gDAAyD;AACzD,kDAA0D;AAC1D,wDAAiE;AACjE,0CAAmD;AACnD,wCAAiD;AACjD,8CAAwD;AACxD,sCAAgD;AAChD,4DAAqE;AACrE,8CAAwD;AAGxD,gEAA0D;AAC1D,yCAAkE;AAClE,yDAAuD;AACvD,yDAAiH;AASjH,SAAS,4BAA4B,CAAC,OAAe,EAAE,aAAsB;IAC5E,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,IAAM,cAAc,GAAG,WAAI,aAAa,MAAG,CAAC;IAE5C,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACjD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,OAAO,UAAG,OAAO,cAAI,cAAc,CAAE,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAe,EAAE,IAAa,EAAE,IAAa,EAAE,IAA0B;IACvG,OAAO;QACN,GAA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AC,OAAO,GAAG,8BAAuB,GAAG,CAAC,OAAO,CAAE,CAAC;gBACnD,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC;aACI,CAAC;YACL,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,sCAAe,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzF,IAAI,CAAC;oBACJ,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,sCAAe,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;gBACxG,CAAC;gBACD,OAAO,GAAG,EAAE,CAAC;oBACZ,GAAG,CAAC,OAAO,GAAG,8BAAuB,GAAG,CAAC,OAAO,CAAE,CAAC;oBACnD,MAAM,GAAG,CAAC;gBACX,CAAC;YACF,CAAC;QACF,CAAC;QAED,MAAM,IAAI,KAAK,CAAE,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAEM,sCAAc,GAArB;QACC,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACF,oBAAC;AAAD,CAnhCA,AAmhCC,IAAA;AAnhCY,sCAAa","file":"method.manager.js","sourcesContent":["import { S3 } from '@aws-sdk/client-s3';\nimport * as fs from 'fs';\nimport * as nodemailer from 'nodemailer';\nimport * as sesTransport from 'nodemailer-ses-transport';\nimport * as path from 'path';\nimport { EmailHistories } from '../collections/email-history.collection';\nimport { Flags } from '../collections/flag.collection';\nimport { Logs } from '../collections/log.collection';\nimport { loadServerCronJobs } from '../fixtures/cron-jobs';\nimport { loadServerInit } from '../fixtures/init';\nimport { loadAccountMethods } from '../methods/accounts';\nimport { loadAWSMethods } from '../methods/aws';\nimport { loadCollectionMethods } from '../methods/collections';\nimport { loadCounterMethods } from '../methods/counters';\nimport { loadCronJobMethods } from '../methods/cron-jobs';\nimport { loadFlagUpdatesMethods } from '../methods/flag-updates';\nimport { loadFlagMethods } from '../methods/flags';\nimport { loadLogMethods } from '../methods/logs';\nimport { loadMonitorMethods } from '../methods/monitor';\nimport { loadPDFMethods } from '../methods/pdf';\nimport { loadReportBuilderMethods } from '../methods/report-builder';\nimport { loadSupportMethods } from '../methods/support';\nimport { EmailHistoryModel, EmailHistoryOccurrence } from '../models/email-history.model';\nimport { MethodAllModel, MethodModel } from '../models/method.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { getBinarySize, objectIdHexString } from '../util/common';\nimport { ErrorReporter } from '../util/error-reporter';\nimport { ensureErrorWithCorrelation, getCorrelationId, runWithCorrelationContext } from '../util/error-tracking';\nimport { MonitorManagerFunction } from './monitor.manager';\nimport { WebSocketManager } from './websocket.manager';\n\ninterface SendEmailOptions {\n\tcorrelationId?: string;\n\tmeta?: Record<string, any>;\n}\n\nfunction appendCorrelationIdToSubject(subject: string, correlationId?: string): string {\n\tif (!correlationId) {\n\t\treturn subject;\n\t}\n\n\tconst correlationTag = `[${correlationId}]`;\n\n\tif (subject && subject.includes(correlationTag)) {\n\t\treturn subject;\n\t}\n\n\treturn `${subject} ${correlationTag}`.trim();\n}\n\nfunction createEmailOccurrence(subject: string, text?: string, html?: string, meta?: Record<string, any>): EmailHistoryOccurrence {\n\treturn {\n\t\t_id: objectIdHexString(),\n\t\tcreatedAt: new Date(),\n\t\tsubject,\n\t\ttext,\n\t\thtml,\n\t\tmeta\n\t};\n}\n\nfunction formatGroupedEmailContent(correlationId: string, occurrences: EmailHistoryOccurrence[]): { text: string; html: string } {\n\tconst lines: string[] = [];\n\tlines.push(`Correlation ID: ${correlationId}`);\n\n\toccurrences.forEach((occurrence, index) => {\n\t\tconst timestamp = occurrence.createdAt instanceof Date ? occurrence.createdAt.toISOString() : new Date(occurrence.createdAt).toISOString();\n\t\tlines.push('');\n\t\tlines.push(`Occurrence #${index + 1} (${timestamp})`);\n\t\tlines.push(`Subject: ${occurrence.subject}`);\n\t\tif (occurrence.text) {\n\t\t\tlines.push(occurrence.text);\n\t\t}\n\t});\n\n\tconst htmlSections = occurrences.map((occurrence, index) => {\n\t\tconst timestamp = occurrence.createdAt instanceof Date ? occurrence.createdAt.toISOString() : new Date(occurrence.createdAt).toISOString();\n\t\tconst escapedText = occurrence.text ? occurrence.text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>') : '';\n\t\treturn `<div><h4>Occurrence #${index + 1} (${timestamp})</h4><p><strong>Subject:</strong> ${occurrence.subject}</p>${escapedText ? `<pre>${escapedText}</pre>` : ''}</div>`;\n\t});\n\n\tconst html = [\n\t\t`<p><strong>Correlation ID:</strong> ${correlationId}</p>`,\n\t\t...htmlSections\n\t].join('');\n\n\treturn {\n\t\ttext: lines.join('\\n'),\n\t\thtml\n\t};\n}\n\nexport class AWS {\n\tprivate _s3: S3 = null;\n\tprivate _s3USEast1: S3 = null;\n\n\tconstructor() {}\n\n\tpublic create() {\n\t\tconst aws = new AWS();\n\t\taws.initialize();\n\t\treturn aws;\n\t}\n\n\tprivate initialize() {\n\n\t}\n\n\tpublic s3(): S3 {\n\t\tif (this._s3) {\n\t\t\treturn this._s3;\n\t\t}\n\n\t\tthis._s3 = new S3({\n\t\t\tcredentials: {\n\t\t\t\taccessKeyId: process.env.AWS_ACCESS_KEY,\n\t\t\t\tsecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY\n\t\t\t},\n\t\t\tregion: process.env.AWS_REGION,\n\t\t\tapiVersion: '2006-03-01'\n\t\t});\n\n\t\treturn this._s3;\n\t}\n\n\tpublic s3USEast1(): S3 {\n\t\tif (process.env.AWS_REGION === 'us-east-1') {\n\t\t\treturn this.s3();\n\t\t}\n\t\telse {\n\t\t\tif (this._s3USEast1) {\n\t\t\t\treturn this._s3USEast1;\n\t\t\t}\n\t\t\t\n\t\t\tthis._s3USEast1 = new S3({\n\t\t\t\tcredentials: {\n\t\t\t\t\taccessKeyId: process.env.AWS_ACCESS_KEY,\n\t\t\t\t\tsecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY\n\t\t\t\t},\n\t\t\t\tregion: 'us-east-1',\n\t\t\t\tapiVersion: '2006-03-01'\n\t\t\t});\n\t\n\t\t\treturn this._s3USEast1;\n\t\t}\n\t}\n}\n\nexport class MethodManager {\n\tprivate _websocketManager: WebSocketManager;\n\tpublic _methods: MethodModel = {};\n\tprivate _mailerSES: nodemailer.Transporter;\n\tprivate _mailerCustom: nodemailer.Transporter;\n\tprivate _aws: AWS;\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\tprivate _isWorkersEnabled = false;\n\tprivate _isWorkerInstance = false;\n\n\tprivate emailQueue: Set<string> = new Set(); // Set to store pending email IDs\n\tprivate isEmailProcessing = false;\n\tprivate readonly _emailProcessingDelayMs = 5000;\n\n\tprivate _debugcallMethodHits = 0;\n\tprivate _debugCallMethodHits = 0;\n\tprivate _debugCallMethodCronJobHits = 0;\n\tprivate _debugSendQueueHits = 0;\n\tprivate _enableDebug = false;\n\n\tpublic clientDir = '';\n\tpublic serverConfig: Record<string, any> = {};\n\n\tconstructor() {}\n\n\tstatic create(websocketManager: WebSocketManager, monitorManagerFunction: MonitorManagerFunction, isWorkersEnabled, isWorkerInstance) {\n\t\tconst methodManager = new MethodManager();\n\t\tmethodManager.initialize(websocketManager, monitorManagerFunction, isWorkersEnabled, isWorkerInstance);\n\t\treturn methodManager;\n\t}\n\n\tprivate initialize(websocketManager: WebSocketManager, monitorManagerFunction: MonitorManagerFunction, isWorkersEnabled, isWorkerInstance) {\n\t\tthis._websocketManager = websocketManager;\n\t\tthis._monitorManagerFunction = monitorManagerFunction;\n\t\tthis._isWorkersEnabled = isWorkersEnabled;\n\t\tthis._isWorkerInstance = isWorkerInstance;\n\t\t\n\t\tthis.clientDir = ResolveIOServer.getClientDir();\n\t\tthis.serverConfig = ResolveIOServer.getServerConfig();\n\n\t\t// Fixtures\n\t\tif (!process.env.IS_WORKERS_ENABLED || process.env.IS_WORKERS_ENABLED === 'false' || (process.env.IS_WORKER_INSTANCE === 'true' && process.env.WORKER_INDEX === '0')) {\n\t\t\tif (!process.env.NODE_APP_INSTANCE || process.env.NODE_APP_INSTANCE === '0') {\n\t\t\t\tsetTimeout(async () => {\n\t\t\t\t\tconsole.log(new Date(), 'Start Server Fixture');\n\t\t\t\t\tawait loadServerInit();\n\t\t\t\t\tconsole.log(new Date(), 'End Server Fixture');\n\t\t\t\t}, 5000);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsetImmediate(async () => {\n\t\t\t// Methods\n\t\t\tawait loadServerCronJobs();\n\n\t\t\tloadAccountMethods(this);\n\t\t\tloadAWSMethods(this);\n\t\t\tloadCollectionMethods(this);\n\t\t\tloadCounterMethods(this);\n\t\t\tloadLogMethods(this);\n\t\t\tloadPDFMethods(this);\n\t\t\tloadCronJobMethods(this);\n\t\t\tloadFlagMethods(this);\n\t\t\tloadFlagUpdatesMethods(this);\n\t\t\tloadReportBuilderMethods(this);\n\t\t\tloadSupportMethods(this);\n\t\t\tloadMonitorMethods(this);\n\n\t\t\tlet flag = await Flags.findOne({type: 'Enable Debug'});\n\t\n\t\t\tif (flag && flag.value) {\n\t\t\t\tthis._enableDebug = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._enableDebug = false;\n\t\t\t}\n\n\t\t\tawait this.loadPendingEmails();\n\t\t});\n\t\t\n\t\tthis._aws = new AWS();\n\n\t\tthis._mailerSES = nodemailer.createTransport(sesTransport({\n\t\t\taccessKeyId: process.env.AWS_ACCESS_KEY,\n\t\t\tsecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n\t\t\tregion: process.env.AWS_SES_REGION\n\t\t}));\n\t\t\n\t\tif (!ResolveIOServer.getSESMail()) {\n\t\t\tthis._mailerCustom = nodemailer.createTransport({\n\t\t\t\thost: ResolveIOServer.getServerConfig()['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server\n\t\t\t\tport: ResolveIOServer.getServerConfig()['MAIL_PORT'], //587, // secure SMTP\n\t\t\t\tsecure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely\n\t\t\t\tauth: {\n\t\t\t\t\tuser: ResolveIOServer.getServerConfig()['MAIL_USERNAME'],\n\t\t\t\t\tpass: ResolveIOServer.getServerConfig()['MAIL_PASSWORD']\n\t\t\t\t},\n\t\t\t\ttls: {\n\t\t\t\t\tciphers: 'SSLv3'\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tsetInterval(async () => {\n\t\t\tlet flag = await Flags.findOne({type: 'Enable Debug'});\n\t\n\t\t\tif (flag && flag.value) {\n\t\t\t\tthis._enableDebug = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._enableDebug = false;\n\t\t\t}\n\n\t\t\tif (this._enableDebug) {\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Send Queue Hits', this._debugSendQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Call Method Internal Hits', this._debugcallMethodHits);\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Call Method Hits', this._debugCallMethodHits);\n\t\t\t\tconsole.log(new Date(), 'Method Manager', 'Call Method Cron Hits', this._debugCallMethodCronJobHits);\n\t\t\t}\n\n\t\t\tthis._debugcallMethodHits = 0;\n\t\t\tthis._debugCallMethodHits = 0;\n\t\t\tthis._debugCallMethodCronJobHits = 0;\n\t\t\tthis._debugSendQueueHits = 0;\n\t\t}, 60000);\n\n\t\tif (!this._isWorkersEnabled || this._isWorkerInstance) {\n\t\t\tthis.setupEmailWatcher();\n\t\t}\n\t}\n\n\tpublic getMethod(methodName: string): MethodAllModel {\n\t\treturn this._methods[methodName];\n\t}\n\n\t// Add methods to private methods object\n\tpublic methods(method: MethodModel) {\n\t\tthis._methods = Object.assign(this._methods, method);\n\t}\n\n\tprivate async reportMethodError(\n\t\tsubject: string,\n\t\tcorrelationId: string,\n\t\tcontext: Record<string, any> | string,\n\t\tmeta: Record<string, any>,\n\t\tstack?: string\n\t) {\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: 'method-manager',\n\t\t\tmessage: subject,\n\t\t\tenvironment: this.serverConfig?.ROOT_URL,\n\t\t\tclientSlug: ResolveIOServer.getClientName(),\n\t\t\tclientName: this.serverConfig?.CLIENT_NAME,\n\t\t\tseverity: 'error',\n\t\t\tstack,\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tcorrelationId\n\t\t});\n\t}\n\n\tpublic async callMethodCron(method: string, ...methodData: any[]) {\n\t\tthis._debugCallMethodCronJobHits += 1;\n\n\t\tconst existingCorrelationId = getCorrelationId();\n\t\tconst correlationId = existingCorrelationId || objectIdHexString();\n\n\t\tconst execute = async () => {\n\t\t\tconst cronMethod = this._methods[method];\n\n\t\t\tif (!cronMethod) {\n\t\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\t{ message: 'No Method registered for cron execution', method },\n\t\t\t\t\t{ context: 'callMethodCron', method }\n\t\t\t\t);\n\n\t\t\t\tthrow new Error('No Method: ' + method);\n\t\t\t}\n\t\t\t\n\t\t\tif ((methodData.length > 1 || methodData[0]) && !cronMethod.skipValidation) {\n\t\t\t\tif (!cronMethod.check) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Function For Cron Method ' + method);\n\n\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\t{ message: 'Missing check function for cron method', method },\n\t\t\t\t\t\t{ context: 'callMethodCron-validation', method }\n\t\t\t\t\t);\n\t\t\n\t\t\t\t\tthrow new Error('No Check Function For Cron Method ' + method);\n\t\t\t\t}\n\t\t\t\telse if (!cronMethod.check._schema) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Schema For Cron Method ' + method);\n\n\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tcorrelationId,\n\t\t\t\t\t\t{ message: 'Missing check schema for cron method', method },\n\t\t\t\t\t\t{ context: 'callMethodCron-validation', method }\n\t\t\t\t\t);\n\t\t\n\t\t\t\t\tthrow new Error('No Check Schema For Cron Method ' + method);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconst valObj = {};\n\t\t\t\t\tconst valKeys = Object.keys(cronMethod.check._schema);\n\n\t\t\t\t\tconst rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcronMethod.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\tconsole.error(new Date(), 'Error in Cron Method Check (' + method + ')', err);\n\n\t\t\t\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tmessage: 'Match error on cron method',\n\t\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t\t\tdata: valObj,\n\t\t\t\t\t\t\t\t\tvalidationError: normalizedError\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{ context: 'callMethodCron-validation-error', method },\n\t\t\t\t\t\t\t\tnormalizedError.stack\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Cron Method Check (${method}): ${normalizedError.message}`;\n\n\t\t\t\t\t\t\tthrow normalizedError;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst monitor = this._monitorManagerFunction.startMonitorFunction('Cron Method', method, '', '', methodData);\n\n\t\t\ttry {\n\t\t\t\tconst res = await cronMethod.function.call(Object.assign({}, this, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData);\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: 'Error detected during cron method execution',\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\tdata: methodData,\n\t\t\t\t\t\terror: normalizedError\n\t\t\t\t\t},\n\t\t\t\t\t{ context: 'callMethodCron-execution', method },\n\t\t\t\t\tnormalizedError.stack\n\t\t\t\t);\n\t\t\t\t\n\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Cron Method (${method}): ${normalizedError.message}`;\n\t\t\t\t\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t}\n\t\t};\n\n\t\treturn await runWithCorrelationContext(correlationId, execute);\n\t}\n\n\t// Call/run method internal (No Emit on Socket)\n\tpublic async callMethod(methodName: string, ...methodData: any[]): Promise<any> {\n\t\tthis._debugcallMethodHits += 1;\n\n\t\tconst existingCorrelationId = getCorrelationId();\n\t\tconst correlationId = existingCorrelationId || objectIdHexString();\n\n\t\treturn await runWithCorrelationContext(correlationId, async () => await this.callMethodInternal(correlationId, methodName, methodData));\n\t}\n\n\tprivate async callMethodInternal(correlationId: string, methodName: string, methodData: any[]): Promise<any> {\n\t\tconst method = this.getMethod(methodName);\n\n\t\tif (!method) {\n\t\t\tconsole.log('No Method: ' + methodName);\n\t\t\tthrow new Error(`No Method: ${methodName}`);\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof methodData[0] !== 'function')) && !method.skipValidation) {\n\t\t\tif (!method.check) {\n\t\t\t\tconsole.error(new Date(), 'No Check Function For Method ' + methodName);\n\t\t\t\tthrow new Error(`No Check Function For Method: ${methodName}`);\n\t\t\t}\n\t\t\telse if (!method.check._schema) {\n\t\t\t\tconsole.error(new Date(), 'No Check Schema For Method ' + methodName);\n\t\t\t\tthrow new Error(`No Check Schema For Method: ${methodName}`);\n\t\t\t}\n\t\t}\n\n\t\tif (methodName !== 'insertSubscriptionLog' && methodName !== 'getDataURIfromURL' && methodName !== 'processAirdropDistribution' && methodName !== 'incCounter' && methodName !== 'supportCreateBillingUser' && methodName !== 'countCollectionWithQuery') {\n\t\t\tif (\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t\t) {\n\t\t\t\tResolveIOServer.getLocalLogManager().writeLog({\n\t\t\t\t\ttype: 'log',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\tcreatedAt: new Date(),\n\t\t\t\t\t\ttype: 'callMethod',\n\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify([methodData])) < 1000000 ? JSON.stringify([methodData], null, 2) : 'Too Big',\n\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\tid_user: this['id_user'] || '',\n\t\t\t\t\t\tuser: this['user'] || '', \n\t\t\t\t\t\tmessageId: 0,\n\t\t\t\t\t\troute: '',\n\t\t\t\t\t\tcorrelationId\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tawait Logs.insertOne({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\ttype: 'callMethod',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tid_document: '',\n\t\t\t\t\tpayload: getBinarySize(JSON.stringify([methodData])) < 1000000 ? JSON.stringify([methodData], null, 2) : 'Too Big',\n\t\t\t\t\tmethod: methodName,\n\t\t\t\t\tid_user: this['id_user'] || '',\n\t\t\t\t\tuser: this['user'] || '',\n\t\t\t\t\tmessageId: 0,\n\t\t\t\t\troute: '',\n\t\t\t\t\tclient: 'ResolveIO',\n\t\t\t\t\tinstance: 'backend.resolveio.com',\n\t\t\t\t\tinstance_index: process.env.NODE_APP_INSTANCE || '',\n\t\t\t\t\tcorrelationId\n\t\t\t\t})\n\t\t\t};\n\t\t}\n\n\t\tconst functionMethodData = typeof(methodData[methodData.length - 1]) === 'function' ? methodData.slice(0, -1) : methodData;\n\n\t\tconst session = ResolveIOServer.getMongoManager().getSession();\n\n\t\tif (!method.bypassSession &&\n\t\t\t!session && \n\t\t\t![\n\t\t\t\t'insertErrorLog', // CIRCULAR LOOP - DO NOT REMOVE\n\t\t\t\t'countWithQuery', // MONGO SESSIONS/TRANSACTIONS DONT WORK WITH COUNTS\n\t\t\t\t'sendEmail' // ALWAYS SEND SO ALWAYS HAVE RECORD - DONT ROLL BACK - BYPASS SESSION\n\t\t\t].includes(methodName) &&\n\t\t\t!methodName.startsWith('monitor-') &&\n\t\t\t!methodName.startsWith('log')\n\t\t) {\n\t\t\tlet monitor = null;\n\t\t\t\n\t\t\treturn ResolveIOServer.getMongoManager().oneTimeTransaction(async () => {\n\t\t\t\t// console.log(new Date(), 'Calling Method - New Session', methodName);\n\n\t\t\t\tmonitor = this._monitorManagerFunction.startMonitorFunction('Method', methodName, this['user'] || '', '', functionMethodData);\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tlet res = await method.function.call(Object.assign({}, this, MethodManager.prototype), ...functionMethodData);\n\n\t\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\t\tmethodData[methodData.length - 1](null, res);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\tif (err.code === 112 || err.codeName === 'WriteConflict' || err.code === 251 || err.codeName === 'NoSuchTransaction') {\n\t\t\t\t\t\tthrow err; // Write error, retry\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\t\tconsole.log(JSON.stringify([new Date(), 'Error Method Manager - Run Method - New Session', methodName, {\n\t\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\t\tcodeName: normalizedError.codeName,\n\t\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t\t}], null, 2));\n\n\t\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: 'Error detected during method execution (new session)',\n\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\tdata: methodData,\n\t\t\t\t\t\t\terror: normalizedError\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ context: 'callMethod-new-session', methodName },\n\t\t\t\t\t\tnormalizedError.stack\n\t\t\t\t\t);\n\t\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Method With Session (${methodName}) - New Session: ${normalizedError.message}`;\n\n\t\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\t\tmethodData[methodData.length - 1](normalizedError, null);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!process.env.IS_WORKER_INSTANCE) {\n\t\t\t\t\t\tawait this.callMethod(\n\t\t\t\t\t\t\t'insertErrorLog',\n\t\t\t\t\t\t\t`Error in Method: ${methodName}`,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\t\tmethodData,\n\t\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\t\t\t\t\tcodeName: normalizedError.codeName\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow normalizedError;\n\t\t\t\t}\n\t\t\t\tfinally {\n\t\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\t// console.log(new Date(), 'Calling Method - Existing Session', methodName);\n\n\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('Method', methodName, this['user'] || '', '', functionMethodData);\n\t\t\t\n\t\t\ttry {\n\t\t\t\tlet res = await method.function.call(Object.assign({}, this, MethodManager.prototype), ...functionMethodData);\n\n\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\tmethodData[methodData.length - 1](null, res);\n\t\t\t\t}\n\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\tif (err.code === 112 || err.codeName === 'WriteConflict' || err.code === 251 || err.codeName === 'NoSuchTransaction') {\n\t\t\t\t\tthrow err; // Write error, retry\n\t\t\t\t}\n\n\t\t\t\tconst { error: normalizedError, correlationId: resolvedCorrelationId } = ensureErrorWithCorrelation(err, correlationId);\n\n\t\t\t\tconsole.log(JSON.stringify([new Date(), 'Error Method Manager - Run Method - Existing Session', methodName, {\n\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\tcodeName: normalizedError.codeName,\n\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t}], null, 2));\n\n\t\t\t\tawait this.reportMethodError(\n\t\t\t\t\t'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'],\n\t\t\t\t\tresolvedCorrelationId,\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: 'Error detected during method execution (existing session)',\n\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\tdata: methodData,\n\t\t\t\t\t\terror: normalizedError\n\t\t\t\t\t},\n\t\t\t\t\t{ context: 'callMethod-existing-session', methodName },\n\t\t\t\t\tnormalizedError.stack\n\t\t\t\t);\n\t\t\t\tnormalizedError.message = `${new Date().toISOString()} - Error in Method (${methodName}) - Existing Session: ${normalizedError.message}`;\n\t\t\t\t\n\t\t\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\t\t\tmethodData[methodData.length - 1](normalizedError, null);\n\t\t\t\t}\n\n\t\t\t\tif (!process.env.IS_WORKER_INSTANCE) {\n\t\t\t\t\tawait this.callMethod(\n\t\t\t\t\t\t'insertErrorLog',\n\t\t\t\t\t\t`Error in Method: ${methodName}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmethod: methodName,\n\t\t\t\t\t\t\tmethodData,\n\t\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\t\tmessage: normalizedError.message,\n\t\t\t\t\t\t\t\tstack: normalizedError.stack,\n\t\t\t\t\t\t\t\tcode: normalizedError.code,\n\t\t\t\t\t\t\t\tcodeName: normalizedError.codeName\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcorrelationId: resolvedCorrelationId\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tawait this._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t}\n\t\t}\n\t}\n\n\tsetupEmailWatcher() {\n\t\tconst changeStream = EmailHistories.watchCollection([]);\n\n\t\tchangeStream.on('change', async (change) => {\n\t\t\tif (change.operationType === 'insert' && change.fullDocument && change.fullDocument.status === 'pending') {\n\t\t\t\tthis.emailQueue.add(change.fullDocument._id.toString());\n\t\t\t\tawait this.tryProcessEmail();\n\t\t\t}\n\t\t\telse if (change.operationType === 'update' || change.operationType === 'replace') {\n\t\t\t\tconst updatedEmail = change.fullDocument;\n\t\t\t\tif (updatedEmail && updatedEmail.status !== 'pending' && this.emailQueue.has(updatedEmail._id.toString())) {\n\t\t\t\t\tthis.emailQueue.delete(updatedEmail._id.toString());\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.on('error', async err => {\n\t\t\tconsole.error('Email history changestream error', err);\n\t\t\tawait changeStream.close();\n\t\t})\n\t\t.on('close', () => {\n\t\t\tthis.setupEmailWatcher();\n\t\t});\n\t}\n\n\tasync loadPendingEmails() {\n\t\t// Load any pending emails on startup\n\t\tconst pendingEmails = await EmailHistories.find({ status: 'pending' }, {sort: {_id: 1}});\n\t\tfor (const email of pendingEmails) {\n\t\t\tthis.emailQueue.add(email._id.toString());\n\t\t}\n\t\t// Try to process emails\n\t\tawait this.tryProcessEmail();\n\t}\n\n\tasync tryProcessEmail() {\n\t\tif (this.isEmailProcessing || this.emailQueue.size === 0) {\n\t\t\treturn;\n\t\t}\n\t\n\t\tthis.isEmailProcessing = true;\n\t\n\t\ttry {\n\t\t\twhile (this.emailQueue.size > 0) {\n\t\t\t\tconst emailId = this.emailQueue.values().next().value;\n\t\t\t\tthis.emailQueue.delete(emailId);\n\t\n\t\t\t\tconst pendingEmail = await EmailHistories.findOne(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: emailId,\n\t\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif (!pendingEmail) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tlet queuedAt: Date;\n\t\t\t\tif (pendingEmail.date instanceof Date) {\n\t\t\t\t\tqueuedAt = pendingEmail.date;\n\t\t\t\t}\n\t\t\t\telse if (pendingEmail.createdAt instanceof Date) {\n\t\t\t\t\tqueuedAt = pendingEmail.createdAt;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tqueuedAt = new Date();\n\t\t\t\t}\n\n\t\t\t\tconst timeSinceQueued = Date.now() - queuedAt.getTime();\n\t\t\t\tconst remainingDelay = this._emailProcessingDelayMs - timeSinceQueued;\n\n\t\t\t\tif (remainingDelay > 0) {\n\t\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, remainingDelay));\n\t\t\t\t}\n\n\t\t\t\tconst emailHistory = await EmailHistories.findOneAndUpdate(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: emailId,\n\t\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$set: { status: 'processing', processingAt: new Date() },\n\t\t\t\t\t}\n\t\t\t\t);\n\t\n\t\t\t\tif (!emailHistory) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\n\t\t\t\t// Fetch and process attachments\n if (emailHistory.attachments && emailHistory.attachments.length > 0) {\n\t\t\t\t\tconst validAttachments: any[] = [];\n\t\t\t\t\tlet attachmentError = false;\n\n\t\t\t\t\tfor (const att of emailHistory.attachments) {\n\t\t\t\t\t\tif (att.path && att.path.startsWith('http')) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst response = await fetch(att.path);\n\t\t\t\t\t\t\t\tif (!response.ok) {\n\t\t\t\t\t\t\t\t\tattachmentError = true;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst arrayBuffer = await response.arrayBuffer();\n\t\t\t\t\t\t\t\tconst buffer = Buffer.from(arrayBuffer);\n\n\t\t\t\t\t\t\t\t// Check the size of the attachment\n\t\t\t\t\t\t\t\tconst maxSize = 20 * 1024 * 1024; // 20MB in bytes\n\t\t\t\t\t\t\t\tif (buffer.length <= maxSize) {\n\t\t\t\t\t\t\t\t\t// Attachment is within size limits, include it\n\t\t\t\t\t\t\t\t\tatt.content = buffer;\n\t\t\t\t\t\t\t\t\tdelete att.path;\n\t\t\t\t\t\t\t\t\tvalidAttachments.push(att);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\t\tconsole.error('Failed to fetch attachment:', err);\n\t\t\t\t\t\t\t\tattachmentError = true;\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\tvalidAttachments.push(att);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\temailHistory.attachments = validAttachments;\n\t\t\t\t\tif (attachmentError) {\n\t\t\t\t\t\t\temailHistory.text =\n\t\t\t\t\t\t\t\t\t(typeof emailHistory.text === 'string' ? emailHistory.text : '') +\n\t\t\t\t\t\t\t\t\t'\\n\\nCould not load attachments.';\n\t\t\t\t\t\t\temailHistory.html =\n\t\t\t\t\t\t\t\t\t(typeof emailHistory.html === 'string' ? emailHistory.html : '') +\n\t\t\t\t\t\t\t\t\t'<p>Could not load attachments.</p>';\n\t\t\t\t\t}\n }\n\t\n\t\t\t\t// Prepare email options\n\t\t\t\tconst mailOptions: any = {\n\t\t\t\t\treplyTo: emailHistory.reply_to || (ResolveIOServer.getServerConfig()['MAIL_REPLY_TO'] || undefined),\n\t\t\t\t\tfrom: emailHistory.send_from || ResolveIOServer.getServerConfig().MAIL_FROM,\n\t\t\t\t\tto: emailHistory.email,\n\t\t\t\t\tsubject:\n\t\t\t\t\t\t(ResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/dev\\./) ||\n\t\t\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/www\\.dev\\./)\n\t\t\t\t\t\t\t? '(DEV SERVER) - '\n\t\t\t\t\t\t\t: '') + emailHistory.subject,\n\t\t\t\t\ttext: typeof emailHistory.text === 'string' ? emailHistory.text : '',\n\t\t\t\t\thtml: typeof emailHistory.html === 'string' ? emailHistory.html : '',\n\t\t\t\t\tattachments: emailHistory.attachments || [],\n\t\t\t\t\tforce_ses: emailHistory.force_ses\n\t\t\t\t};\n\t\n\t\t\t\t// Process attachments before sending\n\t\t\t\tif (mailOptions.attachments && mailOptions.attachments.length > 0) {\n\t\t\t\t\tmailOptions.attachments = mailOptions.attachments.map((att) => {\n\t\t\t\t\t\tconst newAtt = { ...att };\n\t\t\t\t\t\t// Handle attachments stored as BinData or Buffer\n\t\t\t\t\t\tif (newAtt.content && typeof newAtt.content === 'object' && !(newAtt.content instanceof Buffer)) {\n\t\t\t\t\t\t\t// Convert MongoDB's Binary data to Buffer\n\t\t\t\t\t\t\tif (newAtt.content._bsontype === 'Binary' && newAtt.content.sub_type === 0) {\n\t\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content.buffer);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Handle other types if necessary\n\t\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Handle attachments stored as Base64 strings\n\t\t\t\t\t\telse if (typeof newAtt.content === 'string' && newAtt.encoding === 'base64') {\n\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content, 'base64');\n\t\t\t\t\t\t\tdelete newAtt.encoding;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Ensure the content is a Buffer\n\t\t\t\t\t\telse if (typeof newAtt.content === 'string') {\n\t\t\t\t\t\t\tnewAtt.content = Buffer.from(newAtt.content);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn newAtt;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\n\t\t\t\t// Send the email\n\t\t\t\t(!mailOptions.force_ses && this._mailerCustom ? this._mailerCustom : this._mailerSES).sendMail(mailOptions, async err => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\tconsole.error('Failed to send email:', err);\n\t\t\t\t\t\t\tawait EmailHistories.updateOne(\n\t\t\t\t\t\t\t\t{ _id: emailHistory._id },\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\t\t\t\t\t\terror: typeof err === 'string' ? err : this.safeStringify(err),\n\t\t\t\t\t\t\t\t\t\tcompletedAt: new Date(),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (emailHistory.email === 'dev@resolveio.com') {\n\t\t\t\t\t\t\t\tawait EmailHistories.deleteOne({ _id: emailHistory._id });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tawait EmailHistories.updateOne(\n\t\t\t\t\t\t\t\t\t{ _id: emailHistory._id },\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\t\t\tstatus: 'completed',\n\t\t\t\t\t\t\t\t\t\t\tcompletedAt: new Date(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\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\tcatch (error) {\n\t\t\t\t\t\tconsole.error('Error in sendMail callback:', error);\n\t\t\t\t\t\tawait EmailHistories.updateOne(\n\t\t\t\t\t\t\t{ _id: emailHistory._id },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$set: {\n\t\t\t\t\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\t\t\t\t\terror: typeof error === 'string' ? error : this.safeStringify(error),\n\t\t\t\t\t\t\t\t\tcompletedAt: new Date(),\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\n\t\t\t\t// Wait for at least one second before sending the next email\n\t\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t\t\t}\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error('Error processing email queue:', err);\n\t\t}\n\t\tfinally {\n\t\t\tthis.isEmailProcessing = false;\n\t\t\t// Check if new emails arrived while processing\n\t\t\tif (this.emailQueue.size > 0) {\n\t\t\t\tawait this.tryProcessEmail();\n\t\t\t}\n\t\t}\n\t}\n\n\tsafeStringify(obj)\n\t{\n\t\ttry\n\t\t{\n\t\t\treturn JSON.stringify(obj, this.getCircularReplacer());\n\t\t}\n\t\tcatch (e)\n\t\t{\n\t\t\treturn `Error in JSON stringifying: ${e.message}`;\n\t\t}\n\t}\n\n\tgetCircularReplacer()\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\tprivate async tryMergeEmailOccurrence(\n\t\temail: string,\n\t\tsubject: string,\n\t\tcorrelationId: string,\n\t\toccurrence: EmailHistoryOccurrence,\n\t\tmeta?: Record<string, any>\n\t): Promise<EmailHistoryModel | null> {\n\t\tconst existing = await EmailHistories.findOne(\n\t\t\t{\n\t\t\t\temail,\n\t\t\t\tcorrelationId,\n\t\t\t\tstatus: 'pending'\n\t\t\t},\n\t\t\t{ sort: { date: 1 } }\n\t\t);\n\n\t\tif (!existing) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst normalizedOccurrences: EmailHistoryOccurrence[] = Array.isArray(existing.occurrences) && existing.occurrences.length\n\t\t\t? existing.occurrences.map((item: EmailHistoryOccurrence) => ({\n\t\t\t\t_id: item._id || objectIdHexString(),\n\t\t\t\tcreatedAt: item.createdAt instanceof Date ? item.createdAt : new Date(item.createdAt),\n\t\t\t\tsubject: item.subject || existing.subject || '',\n\t\t\t\ttext: item.text,\n\t\t\t\thtml: item.html,\n\t\t\t\tmeta: item.meta\n\t\t\t}))\n\t\t\t: [createEmailOccurrence(\n\t\t\t\texisting.subject || '',\n\t\t\t\ttypeof existing.text === 'string' ? existing.text : undefined,\n\t\t\t\ttypeof existing.html === 'string' ? existing.html : undefined,\n\t\t\t\texisting.meta\n\t\t\t)];\n\n\t\tnormalizedOccurrences.push(occurrence);\n\n\t\tconst { text: aggregatedText, html: aggregatedHtml } = formatGroupedEmailContent(correlationId, normalizedOccurrences);\n\n\t\tconst updated = await EmailHistories.findOneAndUpdate(\n\t\t\t{\n\t\t\t\t_id: existing._id,\n\t\t\t\tstatus: 'pending'\n\t\t\t},\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tsubject,\n\t\t\t\t\ttext: aggregatedText,\n\t\t\t\t\thtml: aggregatedHtml,\n\t\t\t\t\toccurrences: normalizedOccurrences,\n\t\t\t\t\tmeta: meta || existing.meta,\n\t\t\t\t\tupdatedAt: new Date()\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ returnDocument: 'after' }\n\t\t);\n\n\t\treturn updated || null;\n\t}\n\n\tpublic async sendEmail(\n\t\tsendTo: string,\n\t\tsubject: string,\n\t\ttext?: string | null,\n\t\thtml?: string | null,\n\t\tattachments?: any[] | null,\n\t\tsend_from?: string | null,\n\t\treply_to?: string | null,\n\t\tforce_ses = false,\n\t\tlocal_override = false,\n\t\toptions?: SendEmailOptions\n\t) {\n\t\t// Modify sendTo in development environments\n\t\tif (\n\t\t\t(ResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/dev\\./) ||\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'].match(/https:\\/\\/www\\.dev\\./) ||\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] === 'http://localhost:4200') &&\n\t\t\t!sendTo.match(/\\@resolveio\\.com/)\n\t\t) {\n\t\t\tsendTo = 'dev@resolveio.com';\n\t\t}\n\n\t\tconst normalizedSubject = subject || '';\n\t\tconst correlationId = options?.correlationId;\n\t\tconst finalSubject = appendCorrelationIdToSubject(normalizedSubject, correlationId);\n\t\tconst groupByCorrelationId = !!correlationId;\n\t\tconst normalizedText = typeof text === 'string' ? text : '';\n\t\tconst normalizedHtml = typeof html === 'string' ? html : '';\n\t\tconst occurrence = groupByCorrelationId\n\t\t\t? createEmailOccurrence(normalizedSubject, normalizedText, normalizedHtml, options?.meta)\n\t\t\t: null;\n\t\tlet allowGrouping = groupByCorrelationId;\n\n\t\tif (sendTo) {\n\t\t\tif (\n\t\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200' ||\n\t\t\t\tlocal_override\n\t\t\t) {\n\t\t\t\tlet normalizedAttachments: any[] = [];\n\t\t\t\tif (Array.isArray(attachments)) {\n\t\t\t\t\tnormalizedAttachments = attachments.slice();\n\t\t\t\t}\n\t\t\t\telse if (attachments) {\n\t\t\t\t\tnormalizedAttachments = [attachments];\n\t\t\t\t}\n\n\t\t\t\tnormalizedAttachments = normalizedAttachments.map(att => {\n\t\t\t\t\tconst newAtt = { ...att };\n\t\t\t\t\tif (Buffer.isBuffer(newAtt.content)) {\n\t\t\t\t\t\tnewAtt.content = newAtt.content.toString('base64');\n\t\t\t\t\t\tnewAtt.encoding = 'base64';\n\t\t\t\t\t}\n\t\t\t\t\treturn newAtt;\n\t\t\t\t});\n\n\t\t\t\tif (normalizedAttachments.length > 0) {\n\t\t\t\t\tallowGrouping = false;\n\t\t\t\t}\n\n\t\t\t\tif (allowGrouping && occurrence && correlationId) {\n\t\t\t\t\tconst merged = await this.tryMergeEmailOccurrence(sendTo, finalSubject, correlationId, occurrence, options?.meta);\n\t\t\t\t\tif (merged) {\n\t\t\t\t\t\treturn merged;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst emailHistory: EmailHistoryModel = {\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\tid_user: this['id_user'] || '',\n\t\t\t\t\tuser: this['user'] || '',\n\t\t\t\t\temail: sendTo,\n\t\t\t\t\tsubject: finalSubject,\n\t\t\t\t\ttext: normalizedText,\n\t\t\t\t\thtml: normalizedHtml,\n\t\t\t\t\tattachments: normalizedAttachments,\n\t\t\t\t\tsend_from: send_from || '',\n\t\t\t\t\treply_to: reply_to || '',\n\t\t\t\t\tstatus: 'pending',\n\t\t\t\t\terror: '',\n\t\t\t\t\tforce_ses\n\t\t\t\t};\n\n\t\t\t\tif (allowGrouping && occurrence && correlationId) {\n\t\t\t\t\tconst { text: aggregatedText, html: aggregatedHtml } = formatGroupedEmailContent(correlationId, [occurrence]);\n\t\t\t\t\temailHistory.text = aggregatedText;\n\t\t\t\t\temailHistory.html = aggregatedHtml;\n\t\t\t\t\temailHistory.occurrences = [occurrence];\n\t\t\t\t\temailHistory.correlationId = correlationId;\n\t\t\t\t\tif (options?.meta) {\n\t\t\t\t\t\temailHistory.meta = options.meta;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (correlationId) {\n\t\t\t\t\t\temailHistory.correlationId = correlationId;\n\t\t\t\t\t}\n\t\t\t\t\tif (options?.meta) {\n\t\t\t\t\t\temailHistory.meta = options.meta;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tlet history = await EmailHistories.insertOne(emailHistory);\n\t\t\t\t\treturn history;\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\tconsole.error('Failed to queue email:', err);\n\t\t\t\t\terr.message = `Failed to queue email: ${err.message}`;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log(\n\t\t\t\t\t'Send email',\n\t\t\t\t\tsendTo,\n\t\t\t\t\tfinalSubject,\n\t\t\t\t\tnormalizedText,\n\t\t\t\t\tnormalizedHtml,\n\t\t\t\t\tattachments,\n\t\t\t\t\tsend_from,\n\t\t\t\t\tforce_ses,\n\t\t\t\t\tcorrelationId\n\t\t\t\t);\n\t\t\t\t\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tpublic getAWS(): AWS {\n\t\treturn this._aws;\n\t}\n\n\tpublic readFile(fileName) {\n\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\ttry {\n\t\t\t\treturn fs.readFileSync(path.join(__dirname, ('../private/' + fileName)), 'utf-8');\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\terr.message = `Error in readFile: ${err.message}`;\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (fs.existsSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)))) {\n\t\t\t\ttry {\n\t\t\t\t\treturn fs.readFileSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)), 'utf-8');\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.message = `Error in readFile: ${err.message}`;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error ('Error in readFile: File Not Found');\n\t}\n\n\tpublic readImage(fileName) {\n\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\ttry {\n\t\t\t\treturn fs.readFileSync(path.join(__dirname, ('../private/' + fileName)), 'base64');\n\t\t\t}\n\t\t\tcatch (err) {\n\t\t\t\terr.message = `Error in readImage: ${err.message}`;\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (fs.existsSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)))) {\n\t\t\t\ttry {\n\t\t\t\t\treturn fs.readFileSync(path.join(ResolveIOServer.getClientDir(), ('./private/' + fileName)), 'base64');\n\t\t\t\t}\n\t\t\t\tcatch (err) {\n\t\t\t\t\terr.message = `Error in readImage: ${err.message}`;\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error ('Error in readImage: File Not Found');\n\t}\n\n\tpublic getEnableDebug() {\n\t\treturn this._enableDebug;\n\t}\n}\n"]}
|