@resolveio/server-lib 12.5.54 → 12.5.55
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.d.ts +1 -0
- package/client-server-app.js +48 -0
- package/client-server-app.js.map +1 -0
- package/collections/app-status.collection.d.ts +3 -0
- package/collections/app-status.collection.js +51 -0
- package/collections/app-status.collection.js.map +1 -0
- package/collections/counter.collection.d.ts +3 -0
- package/collections/counter.collection.js +54 -0
- package/collections/counter.collection.js.map +1 -0
- package/collections/cron-job-history.collection.d.ts +3 -0
- package/collections/cron-job-history.collection.js +82 -0
- package/collections/cron-job-history.collection.js.map +1 -0
- package/collections/cron-job.collection.d.ts +3 -0
- package/collections/cron-job.collection.js +85 -0
- package/collections/cron-job.collection.js.map +1 -0
- package/collections/email-history.collection.d.ts +3 -0
- package/collections/email-history.collection.js +66 -0
- package/collections/email-history.collection.js.map +1 -0
- package/collections/email-verified.collection.d.ts +3 -0
- package/collections/email-verified.collection.js +61 -0
- package/collections/email-verified.collection.js.map +1 -0
- package/collections/file.collection.d.ts +3 -0
- package/collections/file.collection.js +73 -0
- package/collections/file.collection.js.map +1 -0
- package/collections/flag.collection.d.ts +3 -0
- package/collections/flag.collection.js +56 -0
- package/collections/flag.collection.js.map +1 -0
- package/collections/log-method-latency.collection.d.ts +3 -0
- package/collections/log-method-latency.collection.js +64 -0
- package/collections/log-method-latency.collection.js.map +1 -0
- package/collections/log-subscription.collection.d.ts +3 -0
- package/collections/log-subscription.collection.js +68 -0
- package/collections/log-subscription.collection.js.map +1 -0
- package/collections/log-ts.collection.d.ts +3 -0
- package/collections/log-ts.collection.js +78 -0
- package/collections/log-ts.collection.js.map +1 -0
- package/collections/log.collection.d.ts +3 -0
- package/collections/log.collection.js +77 -0
- package/collections/log.collection.js.map +1 -0
- package/collections/logged-in-users.collection.d.ts +3 -0
- package/collections/logged-in-users.collection.js +65 -0
- package/collections/logged-in-users.collection.js.map +1 -0
- package/collections/method-response.collection.d.ts +3 -0
- package/collections/method-response.collection.js +66 -0
- package/collections/method-response.collection.js.map +1 -0
- package/collections/monitor-cpu.collection.d.ts +3 -0
- package/collections/monitor-cpu.collection.js +63 -0
- package/collections/monitor-cpu.collection.js.map +1 -0
- package/collections/monitor-memory.collection.d.ts +3 -0
- package/collections/monitor-memory.collection.js +75 -0
- package/collections/monitor-memory.collection.js.map +1 -0
- package/collections/monitor-mongo.collection.d.ts +3 -0
- package/collections/monitor-mongo.collection.js +69 -0
- package/collections/monitor-mongo.collection.js.map +1 -0
- package/collections/notification.collection.d.ts +3 -0
- package/collections/notification.collection.js +51 -0
- package/collections/notification.collection.js.map +1 -0
- package/collections/report-builder-dashboard-builder.collection.d.ts +3 -0
- package/collections/report-builder-dashboard-builder.collection.js +109 -0
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -0
- package/collections/report-builder-library.collection.d.ts +3 -0
- package/collections/report-builder-library.collection.js +87 -0
- package/collections/report-builder-library.collection.js.map +1 -0
- package/collections/report-builder-report.collection.d.ts +4 -0
- package/collections/report-builder-report.collection.js +149 -0
- package/collections/report-builder-report.collection.js.map +1 -0
- package/collections/user-group.collection.d.ts +4 -0
- package/collections/user-group.collection.js +90 -0
- package/collections/user-group.collection.js.map +1 -0
- package/collections/user-guide.collection.d.ts +3 -0
- package/collections/user-guide.collection.js +57 -0
- package/collections/user-guide.collection.js.map +1 -0
- package/collections/user.collection.d.ts +4 -0
- package/collections/user.collection.js +259 -0
- package/collections/user.collection.js.map +1 -0
- package/cron/cron.d.ts +5 -0
- package/cron/cron.js +162 -0
- package/cron/cron.js.map +1 -0
- package/fixtures/cron-jobs.d.ts +1 -0
- package/fixtures/cron-jobs.js +73 -0
- package/fixtures/cron-jobs.js.map +1 -0
- package/fixtures/init.d.ts +1 -0
- package/fixtures/init.js +59 -0
- package/fixtures/init.js.map +1 -0
- package/http/auth.d.ts +2 -0
- package/http/auth.js +763 -0
- package/http/auth.js.map +1 -0
- package/http/health.d.ts +1 -0
- package/http/health.js +12 -0
- package/http/health.js.map +1 -0
- package/http/home.d.ts +2 -0
- package/http/home.js +66 -0
- package/http/home.js.map +1 -0
- package/index.d.ts +23 -0
- package/index.js +127 -0
- package/index.js.map +1 -0
- package/managers/cron.manager.d.ts +17 -0
- package/managers/cron.manager.js +242 -0
- package/managers/cron.manager.js.map +1 -0
- package/managers/method.manager.d.ts +38 -0
- package/managers/method.manager.js +595 -0
- package/managers/method.manager.js.map +1 -0
- package/managers/mongo.manager.d.ts +178 -0
- package/managers/mongo.manager.js +2221 -0
- package/managers/mongo.manager.js.map +1 -0
- package/managers/monitor.manager.d.ts +59 -0
- package/managers/monitor.manager.js +351 -0
- package/managers/monitor.manager.js.map +1 -0
- package/managers/subscription.manager.d.ts +50 -0
- package/managers/subscription.manager.js +1091 -0
- package/managers/subscription.manager.js.map +1 -0
- package/managers/subscription.performance.d.ts +1 -0
- package/{src/managers/subscription.performance.ts → managers/subscription.performance.js} +33 -68
- package/managers/subscription.performance.js.map +1 -0
- package/methods/accounts.d.ts +2 -0
- package/methods/accounts.js +274 -0
- package/methods/accounts.js.map +1 -0
- package/methods/aws.d.ts +2 -0
- package/methods/aws.js +617 -0
- package/methods/aws.js.map +1 -0
- package/methods/collections.d.ts +2 -0
- package/methods/collections.js +499 -0
- package/methods/collections.js.map +1 -0
- package/methods/counters.d.ts +2 -0
- package/methods/counters.js +122 -0
- package/methods/counters.js.map +1 -0
- package/methods/cron-jobs.d.ts +2 -0
- package/methods/cron-jobs.js +1315 -0
- package/methods/cron-jobs.js.map +1 -0
- package/methods/flags.d.ts +2 -0
- package/methods/flags.js +9 -0
- package/methods/flags.js.map +1 -0
- package/methods/logs.d.ts +2 -0
- package/methods/logs.js +371 -0
- package/methods/logs.js.map +1 -0
- package/methods/monitor.d.ts +2 -0
- package/methods/monitor.js +565 -0
- package/methods/monitor.js.map +1 -0
- package/methods/pdf.d.ts +2 -0
- package/methods/pdf.js +468 -0
- package/methods/pdf.js.map +1 -0
- package/methods/report-builder.d.ts +2 -0
- package/methods/report-builder.js +858 -0
- package/methods/report-builder.js.map +1 -0
- package/methods/support.d.ts +2 -0
- package/methods/support.js +246 -0
- package/methods/support.js.map +1 -0
- package/{src/models/app-status.model.ts → models/app-status.model.d.ts} +2 -3
- package/models/app-status.model.js +4 -0
- package/models/app-status.model.js.map +1 -0
- package/{src/models/billing-logged-in-users.model.ts → models/billing-logged-in-users.model.d.ts} +4 -5
- package/models/billing-logged-in-users.model.js +4 -0
- package/models/billing-logged-in-users.model.js.map +1 -0
- package/models/collection-document.model.d.ts +19 -0
- package/models/collection-document.model.js +4 -0
- package/models/collection-document.model.js.map +1 -0
- package/{src/models/counter.model.ts → models/counter.model.d.ts} +3 -4
- package/models/counter.model.js +4 -0
- package/models/counter.model.js.map +1 -0
- package/models/cron-job-history.model.d.ts +12 -0
- package/models/cron-job-history.model.js +4 -0
- package/models/cron-job-history.model.js.map +1 -0
- package/models/cron-job.model.d.ts +13 -0
- package/models/cron-job.model.js +4 -0
- package/models/cron-job.model.js.map +1 -0
- package/models/dialog.model.d.ts +23 -0
- package/models/dialog.model.js +4 -0
- package/models/dialog.model.js.map +1 -0
- package/{src/models/email-history.model.ts → models/email-history.model.d.ts} +7 -8
- package/models/email-history.model.js +4 -0
- package/models/email-history.model.js.map +1 -0
- package/{src/models/email-verified.model.ts → models/email-verified.model.d.ts} +5 -6
- package/models/email-verified.model.js +4 -0
- package/models/email-verified.model.js.map +1 -0
- package/{src/models/file.model.ts → models/file.model.d.ts} +7 -8
- package/models/file.model.js +4 -0
- package/models/file.model.js.map +1 -0
- package/{src/models/flag.model.ts → models/flag.model.d.ts} +3 -4
- package/models/flag.model.js +4 -0
- package/models/flag.model.js.map +1 -0
- package/{src/models/log-method-latency.model.ts → models/log-method-latency.model.d.ts} +4 -5
- package/models/log-method-latency.model.js +4 -0
- package/models/log-method-latency.model.js.map +1 -0
- package/{src/models/log-subscription.model.ts → models/log-subscription.model.d.ts} +6 -8
- package/models/log-subscription.model.js +4 -0
- package/models/log-subscription.model.js.map +1 -0
- package/{src/models/log.model.ts → models/log.model.d.ts} +10 -12
- package/models/log.model.js +4 -0
- package/models/log.model.js.map +1 -0
- package/{src/models/logged-in-users.model.ts → models/logged-in-users.model.d.ts} +5 -6
- package/models/logged-in-users.model.js +4 -0
- package/models/logged-in-users.model.js.map +1 -0
- package/{src/models/method-response.model.ts → models/method-response.model.d.ts} +6 -7
- package/models/method-response.model.js +4 -0
- package/models/method-response.model.js.map +1 -0
- package/models/method.model.d.ts +9 -0
- package/models/method.model.js +4 -0
- package/models/method.model.js.map +1 -0
- package/{src/models/monitor-cpu.model.ts → models/monitor-cpu.model.d.ts} +7 -9
- package/models/monitor-cpu.model.js +4 -0
- package/models/monitor-cpu.model.js.map +1 -0
- package/models/monitor-memory.model.d.ts +15 -0
- package/models/monitor-memory.model.js +4 -0
- package/models/monitor-memory.model.js.map +1 -0
- package/models/monitor-mongo.model.d.ts +13 -0
- package/models/monitor-mongo.model.js +4 -0
- package/models/monitor-mongo.model.js.map +1 -0
- package/{src/models/notification.model.ts → models/notification.model.d.ts} +2 -3
- package/models/notification.model.js +4 -0
- package/models/notification.model.js.map +1 -0
- package/models/pagination.model.d.ts +10 -0
- package/models/pagination.model.js +24 -0
- package/models/pagination.model.js.map +1 -0
- package/models/permission.model.d.ts +12 -0
- package/models/permission.model.js +4 -0
- package/models/permission.model.js.map +1 -0
- package/models/report-builder-dashboard-builder.model.d.ts +25 -0
- package/models/report-builder-dashboard-builder.model.js +4 -0
- package/models/report-builder-dashboard-builder.model.js.map +1 -0
- package/models/report-builder-library.model.d.ts +17 -0
- package/models/report-builder-library.model.js +4 -0
- package/models/report-builder-library.model.js.map +1 -0
- package/models/report-builder-report.model.d.ts +98 -0
- package/models/report-builder-report.model.js +4 -0
- package/models/report-builder-report.model.js.map +1 -0
- package/models/report-builder.model.d.ts +61 -0
- package/models/report-builder.model.js +4 -0
- package/models/report-builder.model.js.map +1 -0
- package/models/select-data-label.model.d.ts +9 -0
- package/models/select-data-label.model.js +4 -0
- package/models/select-data-label.model.js.map +1 -0
- package/models/server-response.model.d.ts +5 -0
- package/models/server-response.model.js +4 -0
- package/models/server-response.model.js.map +1 -0
- package/models/subscription.model.d.ts +23 -0
- package/models/subscription.model.js +4 -0
- package/models/subscription.model.js.map +1 -0
- package/models/support-ticket.model.d.ts +72 -0
- package/models/support-ticket.model.js +4 -0
- package/models/support-ticket.model.js.map +1 -0
- package/models/user-group.model.d.ts +19 -0
- package/models/user-group.model.js +4 -0
- package/models/user-group.model.js.map +1 -0
- package/{src/models/user-guide.model.ts → models/user-guide.model.d.ts} +4 -5
- package/models/user-guide.model.js +4 -0
- package/models/user-guide.model.js.map +1 -0
- package/models/user.model.d.ts +70 -0
- package/models/user.model.js +4 -0
- package/models/user.model.js.map +1 -0
- package/package.json +1 -1
- package/{src/public_api.ts → public_api.d.ts} +1 -1
- package/public_api.js +75 -0
- package/public_api.js.map +1 -0
- package/publications/app-status.d.ts +2 -0
- package/publications/app-status.js +17 -0
- package/publications/app-status.js.map +1 -0
- package/publications/cron-jobs.d.ts +2 -0
- package/publications/cron-jobs.js +33 -0
- package/publications/cron-jobs.js.map +1 -0
- package/publications/files.d.ts +2 -0
- package/publications/files.js +37 -0
- package/publications/files.js.map +1 -0
- package/publications/flags.d.ts +2 -0
- package/publications/flags.js +23 -0
- package/publications/flags.js.map +1 -0
- package/publications/logs.d.ts +2 -0
- package/publications/logs.js +165 -0
- package/publications/logs.js.map +1 -0
- package/publications/method-responses.d.ts +2 -0
- package/publications/method-responses.js +17 -0
- package/publications/method-responses.js.map +1 -0
- package/publications/notifications.d.ts +2 -0
- package/publications/notifications.js +17 -0
- package/publications/notifications.js.map +1 -0
- package/publications/report-builder-dashboard-builders.d.ts +2 -0
- package/publications/report-builder-dashboard-builders.js +43 -0
- package/publications/report-builder-dashboard-builders.js.map +1 -0
- package/publications/report-builder-libraries.d.ts +2 -0
- package/publications/report-builder-libraries.js +90 -0
- package/publications/report-builder-libraries.js.map +1 -0
- package/publications/report-builder-reports.d.ts +2 -0
- package/publications/report-builder-reports.js +51 -0
- package/publications/report-builder-reports.js.map +1 -0
- package/publications/super-admin.d.ts +2 -0
- package/publications/super-admin.js +17 -0
- package/publications/super-admin.js.map +1 -0
- package/publications/user-groups.d.ts +1 -0
- package/publications/user-groups.js +17 -0
- package/publications/user-groups.js.map +1 -0
- package/publications/user-guides.d.ts +1 -0
- package/publications/user-guides.js +17 -0
- package/publications/user-guides.js.map +1 -0
- package/server-app.d.ts +52 -0
- package/server-app.js +739 -0
- package/server-app.js.map +1 -0
- package/util/common.d.ts +24 -0
- package/util/common.js +511 -0
- package/util/common.js.map +1 -0
- package/util/schema-report-builder.d.ts +6 -0
- package/util/schema-report-builder.js +453 -0
- package/util/schema-report-builder.js.map +1 -0
- package/.nodemon.json +0 -5
- package/.vscode/settings.json +0 -3
- package/README.md +0 -22
- package/compileDTS.pl +0 -64
- package/gulpfile.js +0 -127
- package/mongodbensurers.js +0 -2
- package/mongostop.js +0 -3
- package/settings.development.json +0 -13
- package/src/client-server-app.ts +0 -7
- package/src/collections/app-status.collection.ts +0 -51
- package/src/collections/counter.collection.ts +0 -54
- package/src/collections/cron-job-history.collection.ts +0 -82
- package/src/collections/cron-job.collection.ts +0 -85
- package/src/collections/email-history.collection.ts +0 -66
- package/src/collections/email-verified.collection.ts +0 -61
- package/src/collections/file.collection.ts +0 -73
- package/src/collections/flag.collection.ts +0 -56
- package/src/collections/log-method-latency.collection.ts +0 -64
- package/src/collections/log-subscription.collection.ts +0 -68
- package/src/collections/log-ts.collection.ts +0 -78
- package/src/collections/log.collection.ts +0 -77
- package/src/collections/logged-in-users.collection.ts +0 -65
- package/src/collections/method-response.collection.ts +0 -66
- package/src/collections/monitor-cpu.collection.ts +0 -63
- package/src/collections/monitor-memory.collection.ts +0 -75
- package/src/collections/monitor-mongo.collection.ts +0 -69
- package/src/collections/notification.collection.ts +0 -51
- package/src/collections/report-builder-dashboard-builder.collection.ts +0 -109
- package/src/collections/report-builder-library.collection.ts +0 -89
- package/src/collections/report-builder-report.collection.ts +0 -149
- package/src/collections/user-group.collection.ts +0 -90
- package/src/collections/user-guide.collection.ts +0 -57
- package/src/collections/user.collection.ts +0 -259
- package/src/cron/cron.ts +0 -188
- package/src/fixtures/cron-jobs.ts +0 -25
- package/src/fixtures/init.ts +0 -10
- package/src/http/auth.ts +0 -732
- package/src/http/health.ts +0 -7
- package/src/http/home.ts +0 -71
- package/src/index.ts +0 -71
- package/src/managers/cron.manager.ts +0 -208
- package/src/managers/method.manager.ts +0 -607
- package/src/managers/mongo.manager.ts +0 -2282
- package/src/managers/monitor.manager.ts +0 -323
- package/src/managers/subscription.manager.ts +0 -1196
- package/src/methods/accounts.ts +0 -202
- package/src/methods/aws.ts +0 -507
- package/src/methods/collections.ts +0 -512
- package/src/methods/counters.ts +0 -75
- package/src/methods/cron-jobs.ts +0 -1454
- package/src/methods/flags.ts +0 -7
- package/src/methods/logs.ts +0 -327
- package/src/methods/monitor.ts +0 -548
- package/src/methods/pdf.ts +0 -615
- package/src/methods/report-builder.ts +0 -876
- package/src/methods/support.ts +0 -146
- package/src/models/collection-document.model.ts +0 -22
- package/src/models/cron-job-history.model.ts +0 -13
- package/src/models/cron-job.model.ts +0 -14
- package/src/models/dialog.model.ts +0 -25
- package/src/models/method.model.ts +0 -11
- package/src/models/monitor-memory.model.ts +0 -17
- package/src/models/monitor-mongo.model.ts +0 -15
- package/src/models/pagination.model.ts +0 -30
- package/src/models/permission.model.ts +0 -14
- package/src/models/report-builder-dashboard-builder.model.ts +0 -29
- package/src/models/report-builder-library.model.ts +0 -20
- package/src/models/report-builder-report.model.ts +0 -110
- package/src/models/report-builder.model.ts +0 -68
- package/src/models/select-data-label.model.ts +0 -9
- package/src/models/server-response.model.ts +0 -5
- package/src/models/subscription.model.ts +0 -64
- package/src/models/support-ticket.model.ts +0 -81
- package/src/models/user-group.model.ts +0 -23
- package/src/models/user.model.ts +0 -79
- package/src/publications/app-status.ts +0 -13
- package/src/publications/cron-jobs.ts +0 -30
- package/src/publications/files.ts +0 -34
- package/src/publications/flags.ts +0 -20
- package/src/publications/logs.ts +0 -164
- package/src/publications/method-responses.ts +0 -13
- package/src/publications/notifications.ts +0 -13
- package/src/publications/report-builder-dashboard-builders.ts +0 -39
- package/src/publications/report-builder-libraries.ts +0 -41
- package/src/publications/report-builder-reports.ts +0 -48
- package/src/publications/super-admin.ts +0 -13
- package/src/publications/user-groups.ts +0 -12
- package/src/publications/user-guides.ts +0 -12
- package/src/server-app.ts +0 -769
- package/src/util/common.ts +0 -519
- package/src/util/schema-report-builder.ts +0 -413
- package/tsconfig.json +0 -30
- package/tslint.json +0 -143
- /package/{src/private → private}/email-templates/enrollment.html +0 -0
- /package/{src/private → private}/email-templates/forgot-password.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-deleted.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket-modified.html +0 -0
- /package/{src/private → private}/email-templates/support-ticket.html +0 -0
- /package/{src/private → private}/images/ResolveIO.png +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/managers/cron.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0EAA8D;AAE9D,IAAI,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAI7C;IAOC,qBAAY,UAAU;QAFd,UAAK,GAAmB,EAAE,CAAC;QAGlC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,cAAc,EAAE,CAAC;QAEzC,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAEY,gCAAU,GAAvB;;;;gBACC,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;oBACnD,8BAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG;wBACvB,KAAI,CAA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AC;;;iCAGtE,GAAG,CAAC,eAAe,EAAnB,wBAAmB;iCAClB,GAAG,CAAC,oBAAoB,EAAxB,wBAAwB;4BAC3B,qBAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,EAAA;;4BAAvG,SAAuG,CAAC;;gCAGxG,qBAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,EAAA;;4BAA7E,SAA6E,CAAC;;;;;4BAKhF,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,KAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;;;4BAGrE,IAAI,GAAG,CAAC,MAAM,EAAE;gCACX,QAAQ,GAAmB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,SAAS,EAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;gCACjH,8BAAQ,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAC,EAAC,CAAC,CAAC;6BACjF;iCACI;gCACJ,8BAAQ,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAC,CAAC,CAAC;6BACnC;;;;;iBAEF,EAAE,cAAO,CAAC,CAAC,CAAC;SACb;IACF,CAAC;IACF,kBAAC;AAAD,CAxMA,AAwMC,IAAA;AAxMY,kCAAW","file":"cron.manager.js","sourcesContent":["import { CronJobModel } from '../models/cron-job.model';\nimport { CronJobs } from '../collections/cron-job.collection';\nimport ResolveIOMainServer from '../server-app';\nlet CronJobManager = require('../cron/cron');\nimport * as moment from 'moment';\nimport { ChangeStream, ChangeStreamDocument } from 'mongodb';\n\nexport class CronManager {\n\n\tprivate _cronManager;\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _watchCrons$: ChangeStream;\n\tprivate _jobs: CronJobModel[] = [];\n\n\tconstructor(mainServer) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._cronManager = new CronJobManager();\n\n\t\tthis.watchCrons();\n\t}\n\n\tpublic async watchCrons() {\n\t\tif (!this._watchCrons$ || this._watchCrons$.closed) {\n\t\t\tCronJobs.find().then(res => {\n\t\t\t\tthis._jobs = res;\n\n\t\t\t\tthis._jobs.forEach(job => {\n\t\t\t\t\tthis.addCronJob(job);\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\tthis.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\tif (this._jobs.some(a => a._id === <any>doc.documentKey['_id'])) {\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\t\t\t\t\t\t\tthis.updateCronJob(doc.fullDocument);\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\tthis.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.filter(a => a._id === <any>doc.documentKey['_id'])[0];\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.filter(a => a._id === <any>doc.documentKey['_id'])[0];\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', (err) => {\n\t\t\t\tthis._watchCrons$.close();\n\t\t\t})\n\t\t\t.on('end', () => {\n\t\t\t\tthis._watchCrons$.close();\n\t\t\t})\n\t\t\t.on('close', () => {\n\t\t\t\tthis._watchCrons$ = null;\n\t\t\t\tthis.watchCrons();\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._watchCrons$.close();\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 addCronJob(cron: CronJobModel) {\n\t\tif (cron.running) {\n\t\t\tCronJobs.updateOne({_id: cron._id}, {$set: {running: false}});\n\t\t}\n\t\t\n\t\tif (!this.doesCronJobExist(cron)) {\n\t\t\tif (cron.timezone) {\n\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet cronOptions = {\n\t\t\t\t\tstart: true,\n\t\t\t\t\t// onComplete: () => {\n\t\t\t\t\t// \tthis.runCronJobCompleted(cron);\n\t\t\t\t\t// },\n\t\t\t\t\t// timeZone: cron.timezone\n\t\t\t\t};\n\n\t\t\t\tif (cron.timezone) {\n\t\t\t\t\tcronOptions['timeZone'] = cron.timezone;\n\t\t\t\t}\n\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() => {\n\t\t\t\t\t\tthis.runCronJob(cron);\n\t\t\t\t\t},\n\t\t\t\t\tcronOptions\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate updateCronJob(cron: CronJobModel) {\n\t\tif (this.doesCronJobExist(cron)) {\n\t\t\tthis._cronManager.update(cron.name, cron.time_to_run);\n\t\t}\n\t}\n\n\tprivate removeCronJob(cron_name: string) {\n\t\tif (this.doesCronJobNameExist(cron_name)) {\n\t\t\tthis._cronManager.deleteJob(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.start(cron.name);\n\t\t}\n\t}\n\n\tprivate stopAllCronJobs() {\n\t\tthis._cronManager.stopAll();\n\t}\n\n\tprivate runCronJob(cron: CronJobModel) {\n\t\tlet now = new Date();\n\n\t\tif (!cron.next_run || now.getTime() >= cron.next_run.getTime()) {\n\n\t\t\tCronJobs.findOneAndUpdate({\n\t\t\t\t$and: [\n\t\t\t\t\t{_id: cron._id},\n\t\t\t\t\t{running: false},\n\t\t\t\t\t{\n\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t{next_run: {$exists: false}},\n\t\t\t\t\t\t\t{next_run: null},\n\t\t\t\t\t\t\t{next_run: {$lte: now}}\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}, {$set: {running: true}}).then(async res => {\n\t\t\t\tif (res) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (res.method_run_data) {\n\t\t\t\t\t\t\tawait this._mainServer.getMethodManager().callMethodCron(res.method_run, res.method_run_data);\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tawait this._mainServer.getMethodManager().callMethodCron(res.method_run);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (res.method_complete) {\n\t\t\t\t\t\t\tif (res.method_complete_data) {\n\t\t\t\t\t\t\t\tawait this._mainServer.getMethodManager().callMethodCron(res.method_complete, res.method_complete_data);\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 this._mainServer.getMethodManager().callMethodCron(res.method_complete);\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 (err) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Cron Error', JSON.stringify(err, null, 2));\n\t\t\t\t\t}\n\t\n\t\t\t\t\tif (res.repeat) {\n\t\t\t\t\t\tlet nextDate = (<moment.Moment>this._cronManager.getJob(res.name).nextDates()).second(0).millisecond(0).toDate();\n\t\t\t\t\t\tCronJobs.updateOne({_id: res._id}, {$set: {running: false, next_run: nextDate}});\n\t\t\t\t\t} \n\t\t\t\t\telse {\n\t\t\t\t\t\tCronJobs.deleteOne({_id: res._id});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, () => {});\n\t\t}\n\t}\n}"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MethodModel } from '../models/method.model';
|
|
2
|
+
import ResolveIOMainServer from '../server-app';
|
|
3
|
+
import { MonitorManagerFunction } from './monitor.manager';
|
|
4
|
+
import { S3 } from '@aws-sdk/client-s3';
|
|
5
|
+
export declare class AWS {
|
|
6
|
+
private _serverConfig;
|
|
7
|
+
private _s3;
|
|
8
|
+
private _s3USEast1;
|
|
9
|
+
constructor(serverConfig: any);
|
|
10
|
+
s3(): S3;
|
|
11
|
+
s3USEast1(): S3;
|
|
12
|
+
}
|
|
13
|
+
export declare class MethodManager {
|
|
14
|
+
private _mainServer;
|
|
15
|
+
_methods: MethodModel;
|
|
16
|
+
private _mailer;
|
|
17
|
+
private _aws;
|
|
18
|
+
private serverConfig;
|
|
19
|
+
private clientDir;
|
|
20
|
+
private _sendQueue;
|
|
21
|
+
private _runningQueue;
|
|
22
|
+
private _monitorManagerFunction;
|
|
23
|
+
private _debugCallMethodInternalHits;
|
|
24
|
+
private _debugCallMethodHits;
|
|
25
|
+
private _debugCallMethodCronJobHits;
|
|
26
|
+
private _debugSendQueueHits;
|
|
27
|
+
constructor(mainServer: any, serverConfig: any, clientDir: any, monitorManagerFunction: MonitorManagerFunction);
|
|
28
|
+
getMainServer(): ResolveIOMainServer;
|
|
29
|
+
methods(method: MethodModel): void;
|
|
30
|
+
callMethodCron(method: string, ...methodData: any[]): any;
|
|
31
|
+
callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]): void;
|
|
32
|
+
callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
|
|
33
|
+
private sendWS;
|
|
34
|
+
sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string, reply_to?: string): Promise<unknown>;
|
|
35
|
+
getAWS(): AWS;
|
|
36
|
+
readFile(fileName: any): Promise<unknown>;
|
|
37
|
+
readImage(fileName: any): Promise<unknown>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.MethodManager = exports.AWS = void 0;
|
|
49
|
+
var collections_1 = require("../methods/collections");
|
|
50
|
+
var logs_1 = require("../methods/logs");
|
|
51
|
+
var counters_1 = require("../methods/counters");
|
|
52
|
+
var pdf_1 = require("../methods/pdf");
|
|
53
|
+
var aws_1 = require("../methods/aws");
|
|
54
|
+
var path = require("path");
|
|
55
|
+
var fs = require("fs");
|
|
56
|
+
var nodemailer = require("nodemailer");
|
|
57
|
+
var sesTransport = require("nodemailer-ses-transport");
|
|
58
|
+
var accounts_1 = require("../methods/accounts");
|
|
59
|
+
var init_1 = require("../fixtures/init");
|
|
60
|
+
var cron_jobs_1 = require("../fixtures/cron-jobs");
|
|
61
|
+
var cron_jobs_2 = require("../methods/cron-jobs");
|
|
62
|
+
var flags_1 = require("../methods/flags");
|
|
63
|
+
var method_response_collection_1 = require("../collections/method-response.collection");
|
|
64
|
+
var common_1 = require("../util/common");
|
|
65
|
+
var log_collection_1 = require("../collections/log.collection");
|
|
66
|
+
var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
|
|
67
|
+
var moment = require("moment");
|
|
68
|
+
var report_builder_1 = require("../methods/report-builder");
|
|
69
|
+
var support_1 = require("../methods/support");
|
|
70
|
+
var monitor_1 = require("../methods/monitor");
|
|
71
|
+
var email_history_collection_1 = require("../collections/email-history.collection");
|
|
72
|
+
var mongo_manager_1 = require("./mongo.manager");
|
|
73
|
+
var client_s3_1 = require("@aws-sdk/client-s3");
|
|
74
|
+
var AWS = /** @class */ (function () {
|
|
75
|
+
function AWS(serverConfig) {
|
|
76
|
+
this._serverConfig = null;
|
|
77
|
+
this._s3 = null;
|
|
78
|
+
this._s3USEast1 = null;
|
|
79
|
+
this._serverConfig = serverConfig;
|
|
80
|
+
}
|
|
81
|
+
AWS.prototype.s3 = function () {
|
|
82
|
+
if (this._s3) {
|
|
83
|
+
return this._s3;
|
|
84
|
+
}
|
|
85
|
+
this._s3 = new client_s3_1.S3({
|
|
86
|
+
credentials: {
|
|
87
|
+
accessKeyId: process.env.AWS_ACCESS_KEY,
|
|
88
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
89
|
+
},
|
|
90
|
+
region: process.env.AWS_REGION,
|
|
91
|
+
apiVersion: '2006-03-01'
|
|
92
|
+
});
|
|
93
|
+
return this._s3;
|
|
94
|
+
};
|
|
95
|
+
AWS.prototype.s3USEast1 = function () {
|
|
96
|
+
if (process.env.AWS_REGION === 'us-east-1') {
|
|
97
|
+
return this.s3();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (this._s3USEast1) {
|
|
101
|
+
return this._s3USEast1;
|
|
102
|
+
}
|
|
103
|
+
this._s3USEast1 = new client_s3_1.S3({
|
|
104
|
+
credentials: {
|
|
105
|
+
accessKeyId: process.env.AWS_ACCESS_KEY,
|
|
106
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
107
|
+
},
|
|
108
|
+
region: 'us-east-1',
|
|
109
|
+
apiVersion: '2006-03-01'
|
|
110
|
+
});
|
|
111
|
+
return this._s3USEast1;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return AWS;
|
|
115
|
+
}());
|
|
116
|
+
exports.AWS = AWS;
|
|
117
|
+
var MethodManager = /** @class */ (function () {
|
|
118
|
+
function MethodManager(mainServer, serverConfig, clientDir, monitorManagerFunction) {
|
|
119
|
+
var _this = this;
|
|
120
|
+
this._methods = {};
|
|
121
|
+
this._sendQueue = [];
|
|
122
|
+
this._runningQueue = false;
|
|
123
|
+
this._debugCallMethodInternalHits = 0;
|
|
124
|
+
this._debugCallMethodHits = 0;
|
|
125
|
+
this._debugCallMethodCronJobHits = 0;
|
|
126
|
+
this._debugSendQueueHits = 0;
|
|
127
|
+
this._mainServer = mainServer;
|
|
128
|
+
this.serverConfig = serverConfig;
|
|
129
|
+
this.clientDir = clientDir;
|
|
130
|
+
this._monitorManagerFunction = monitorManagerFunction;
|
|
131
|
+
// Fixtures
|
|
132
|
+
(0, init_1.loadServerInit)();
|
|
133
|
+
(0, cron_jobs_1.loadServerCronJobs)();
|
|
134
|
+
// Methods
|
|
135
|
+
(0, accounts_1.loadAccountMethods)(this);
|
|
136
|
+
(0, aws_1.loadAWSMethods)(this);
|
|
137
|
+
(0, collections_1.loadCollectionMethods)(this);
|
|
138
|
+
(0, counters_1.loadCounterMethods)(this);
|
|
139
|
+
(0, logs_1.loadLogMethods)(this);
|
|
140
|
+
(0, pdf_1.loadPDFMethods)(this);
|
|
141
|
+
(0, cron_jobs_2.loadCronJobMethods)(this);
|
|
142
|
+
(0, flags_1.loadFlagMethods)(this);
|
|
143
|
+
(0, report_builder_1.loadReportBuilderMethods)(this);
|
|
144
|
+
(0, support_1.loadSupportMethods)(this);
|
|
145
|
+
(0, monitor_1.loadMonitorMethods)(this);
|
|
146
|
+
this._aws = new AWS(serverConfig);
|
|
147
|
+
if (mainServer.sesMail) {
|
|
148
|
+
this._mailer = nodemailer.createTransport(sesTransport({
|
|
149
|
+
accessKeyId: process.env.AWS_ACCESS_KEY,
|
|
150
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
151
|
+
region: process.env.AWS_SES_REGION
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this._mailer = nodemailer.createTransport({
|
|
156
|
+
host: this.serverConfig['MAIL_HOST'],
|
|
157
|
+
port: this.serverConfig['MAIL_PORT'],
|
|
158
|
+
secure: false,
|
|
159
|
+
auth: {
|
|
160
|
+
user: this.serverConfig['MAIL_USERNAME'],
|
|
161
|
+
pass: this.serverConfig['MAIL_PASSWORD']
|
|
162
|
+
},
|
|
163
|
+
tls: {
|
|
164
|
+
ciphers: 'SSLv3'
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
setInterval(function () {
|
|
169
|
+
if (_this._mainServer.getSubscriptionManager().getEnableDebug()) {
|
|
170
|
+
console.log(new Date(), 'Method Manager', 'Send Queue Length', _this._sendQueue.length);
|
|
171
|
+
console.log(new Date(), 'Method Manager', 'Send Queue Hits', _this._debugSendQueueHits);
|
|
172
|
+
console.log(new Date(), 'Method Manager', 'Call Method Internal Hits', _this._debugCallMethodInternalHits);
|
|
173
|
+
console.log(new Date(), 'Method Manager', 'Call Method Hits', _this._debugCallMethodHits);
|
|
174
|
+
console.log(new Date(), 'Method Manager', 'Call Method Cron Hits', _this._debugCallMethodCronJobHits);
|
|
175
|
+
}
|
|
176
|
+
_this._debugCallMethodInternalHits = 0;
|
|
177
|
+
_this._debugCallMethodHits = 0;
|
|
178
|
+
_this._debugCallMethodCronJobHits = 0;
|
|
179
|
+
_this._debugSendQueueHits = 0;
|
|
180
|
+
_this._debugSendQueueHits = 0;
|
|
181
|
+
}, 60000);
|
|
182
|
+
setInterval(function () {
|
|
183
|
+
if (!_this._runningQueue) {
|
|
184
|
+
if (_this._sendQueue.length) {
|
|
185
|
+
_this._runningQueue = true;
|
|
186
|
+
var _loop_1 = function (i) {
|
|
187
|
+
_this._debugSendQueueHits += 1;
|
|
188
|
+
var ws = _this._mainServer.getWS(_this._sendQueue[i].id_ws);
|
|
189
|
+
if (ws && ws.readyState === ws.OPEN) {
|
|
190
|
+
if (ws.bufferedAmount < 20480) {
|
|
191
|
+
var sendItem = _this._sendQueue.pop();
|
|
192
|
+
ws.send(JSON.stringify(sendItem.data), function (error) {
|
|
193
|
+
if (error) {
|
|
194
|
+
console.log('Error on WS: ', error);
|
|
195
|
+
_this._mainServer.unsubscribeWS(ws);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
if (sendItem.method !== 'reportBuilderGetResults' && sendItem.method !== 'reportBuilderGetDistinctValue' && sendItem.method !== 'reportBuilderBuildTree' && sendItem.method !== 'generatePDF' && sendItem.method !== 'getWOOfflineData' && sendItem.method !== 'countQuery' && sendItem.method !== 'countWithQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'uploadFileAndSave' && sendItem.method !== 'getDrivers' && sendItem.method !== 'processAirdropDistribution') {
|
|
199
|
+
log_collection_1.Logs.insertOne({
|
|
200
|
+
_id: (0, mongo_manager_1.objectIdHexString)(),
|
|
201
|
+
type: 'client-response',
|
|
202
|
+
collection: '',
|
|
203
|
+
id_document: '',
|
|
204
|
+
payload: (0, common_1.getBinarySize)(JSON.stringify([sendItem.methodData, sendItem.data])) < 200000 ? JSON.stringify([sendItem.methodData, sendItem.data], null, 2) : 'Too Big',
|
|
205
|
+
method: sendItem.method,
|
|
206
|
+
id_user: ws['id_user'] || '',
|
|
207
|
+
user: ws['user'] || '',
|
|
208
|
+
messageId: sendItem.data.messageId,
|
|
209
|
+
route: ''
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
method_response_collection_1.MethodResponses.create({
|
|
213
|
+
_id: (0, mongo_manager_1.objectIdHexString)(),
|
|
214
|
+
__v: 0,
|
|
215
|
+
id_user: ws['id_user'] || '',
|
|
216
|
+
message_id: sendItem.data.messageId,
|
|
217
|
+
response: (0, common_1.getBinarySize)(JSON.stringify(sendItem.data)) < 200000 ? sendItem.data : { error: 'Too Big' },
|
|
218
|
+
method: sendItem.method,
|
|
219
|
+
date: sendItem.date
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
_this._sendQueue.splice(i, 1);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
for (var i = _this._sendQueue.length - 1; i >= 0; i--) {
|
|
228
|
+
_loop_1(i);
|
|
229
|
+
}
|
|
230
|
+
_this._runningQueue = false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}, 25);
|
|
234
|
+
}
|
|
235
|
+
MethodManager.prototype.getMainServer = function () {
|
|
236
|
+
return this._mainServer;
|
|
237
|
+
};
|
|
238
|
+
// Add methods to private methods object
|
|
239
|
+
MethodManager.prototype.methods = function (method) {
|
|
240
|
+
this._methods = Object.assign(this._methods, method);
|
|
241
|
+
};
|
|
242
|
+
MethodManager.prototype.callMethodCron = function (method) {
|
|
243
|
+
var _a;
|
|
244
|
+
var _this = this;
|
|
245
|
+
var methodData = [];
|
|
246
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
247
|
+
methodData[_i - 1] = arguments[_i];
|
|
248
|
+
}
|
|
249
|
+
this._debugCallMethodCronJobHits += 1;
|
|
250
|
+
if (!this._methods[method]) {
|
|
251
|
+
console.log('No Method: ' + method);
|
|
252
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if ((methodData.length > 1 || methodData[0]) && !this._methods[method].skipValidation) {
|
|
256
|
+
if (!this._methods[method].check) {
|
|
257
|
+
console.error(new Date(), 'No Check Function For Method ' + method);
|
|
258
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
else if (!this._methods[method].check._schema) {
|
|
262
|
+
console.error(new Date(), 'No Check Schema For Method ' + method);
|
|
263
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
var valObj = {};
|
|
268
|
+
var valKeys = Object.keys(this._methods[method].check._schema);
|
|
269
|
+
var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
|
|
270
|
+
for (var i = 0; i < methodData.length; i++) {
|
|
271
|
+
valObj[rootKeys[i]] = methodData[i];
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
this._methods[method].check.validate(valObj);
|
|
275
|
+
}
|
|
276
|
+
catch (errors) {
|
|
277
|
+
if (errors) {
|
|
278
|
+
console.error(new Date(), 'Error in Method Check (' + method + ')', errors);
|
|
279
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
var monitor = this._monitorManagerFunction.startMonitorFunction('Cron Method', method, '', '', methodData);
|
|
286
|
+
var promise = (_a = this._methods[method].function).call.apply(_a, __spreadArray([Object.assign({}, this, MethodManager.prototype, { id_user: '', user: '', id_ws: '' })], methodData, false)).then(function (res) {
|
|
287
|
+
_this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
288
|
+
return res;
|
|
289
|
+
}, function (methodErrs) {
|
|
290
|
+
_this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
291
|
+
_this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodCron)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
292
|
+
return methodErrs;
|
|
293
|
+
});
|
|
294
|
+
return promise;
|
|
295
|
+
};
|
|
296
|
+
// Call/run method (Emit on Socket)
|
|
297
|
+
MethodManager.prototype.callMethod = function (id_methodLatency, ws, messageDate, messageId, method) {
|
|
298
|
+
var _a;
|
|
299
|
+
var _this = this;
|
|
300
|
+
var methodData = [];
|
|
301
|
+
for (var _i = 5; _i < arguments.length; _i++) {
|
|
302
|
+
methodData[_i - 5] = arguments[_i];
|
|
303
|
+
}
|
|
304
|
+
this._debugCallMethodHits += 1;
|
|
305
|
+
if (!this._methods[method]) {
|
|
306
|
+
console.log('No Method: ' + method);
|
|
307
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
|
|
308
|
+
var serverRes = {
|
|
309
|
+
messageId: messageId,
|
|
310
|
+
hasError: true,
|
|
311
|
+
data: 'Internal Error'
|
|
312
|
+
};
|
|
313
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
314
|
+
if (id_methodLatency) {
|
|
315
|
+
log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
316
|
+
}
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if ((methodData.length > 1 || methodData[0]) && !this._methods[method].skipValidation) {
|
|
320
|
+
if (!this._methods[method].check) {
|
|
321
|
+
console.error(new Date(), 'No Check Function For Method ' + method);
|
|
322
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
323
|
+
var serverRes = {
|
|
324
|
+
messageId: messageId,
|
|
325
|
+
hasError: true,
|
|
326
|
+
data: 'Internal Error'
|
|
327
|
+
};
|
|
328
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
329
|
+
if (id_methodLatency) {
|
|
330
|
+
log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
else if (!this._methods[method].check._schema) {
|
|
335
|
+
console.error(new Date(), 'No Check Schema For Method ' + method);
|
|
336
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
337
|
+
var serverRes = {
|
|
338
|
+
messageId: messageId,
|
|
339
|
+
hasError: true,
|
|
340
|
+
data: 'Internal Error'
|
|
341
|
+
};
|
|
342
|
+
if (id_methodLatency) {
|
|
343
|
+
log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
344
|
+
}
|
|
345
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
var valObj = {};
|
|
350
|
+
var valKeys = Object.keys(this._methods[method].check._schema);
|
|
351
|
+
var rootKeys = valKeys.filter(function (a) { return !a.includes('.'); });
|
|
352
|
+
for (var i = 0; i < methodData.length; i++) {
|
|
353
|
+
valObj[rootKeys[i]] = methodData[i];
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
this._methods[method].check.validate(valObj);
|
|
357
|
+
}
|
|
358
|
+
catch (errors) {
|
|
359
|
+
if (errors) {
|
|
360
|
+
console.error(new Date(), 'Error in Method Check (' + method + ')', errors);
|
|
361
|
+
if (method !== 'processAirdropDistribution') {
|
|
362
|
+
this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\n\nData Being Checked\n' + JSON.stringify(valObj, null, 2) + '\n\nErrors\n' + JSON.stringify(errors, null, 2));
|
|
363
|
+
}
|
|
364
|
+
var serverRes = {
|
|
365
|
+
messageId: messageId,
|
|
366
|
+
hasError: true,
|
|
367
|
+
data: 'Internal Error'
|
|
368
|
+
};
|
|
369
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
370
|
+
if (id_methodLatency) {
|
|
371
|
+
log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
var monitor = this._monitorManagerFunction.startMonitorFunction('Method', method, ws['user'] || '', ws['id_socket'] || '', methodData);
|
|
379
|
+
(_a = this._methods[method].function).call.apply(_a, __spreadArray([Object.assign({}, this, MethodManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] })], methodData, false)).then(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
380
|
+
var serverRes, latency;
|
|
381
|
+
return __generator(this, function (_a) {
|
|
382
|
+
switch (_a.label) {
|
|
383
|
+
case 0:
|
|
384
|
+
this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
385
|
+
serverRes = {
|
|
386
|
+
messageId: messageId,
|
|
387
|
+
hasError: false,
|
|
388
|
+
data: res
|
|
389
|
+
};
|
|
390
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
391
|
+
if (!id_methodLatency) return [3 /*break*/, 2];
|
|
392
|
+
return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.findById(id_methodLatency)];
|
|
393
|
+
case 1:
|
|
394
|
+
latency = _a.sent();
|
|
395
|
+
if (latency) {
|
|
396
|
+
log_method_latency_collection_1.LogMethodLatencies.updateOne({ _id: id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
|
|
397
|
+
}
|
|
398
|
+
_a.label = 2;
|
|
399
|
+
case 2: return [2 /*return*/];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}); }, function (err) {
|
|
403
|
+
_this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
404
|
+
var serverRes = {
|
|
405
|
+
messageId: messageId,
|
|
406
|
+
hasError: true,
|
|
407
|
+
data: err
|
|
408
|
+
};
|
|
409
|
+
_this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
410
|
+
if (id_methodLatency) {
|
|
411
|
+
log_method_latency_collection_1.LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
412
|
+
}
|
|
413
|
+
if (method !== 'processAirdropDistribution') {
|
|
414
|
+
_this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethod)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(err, null, 2));
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
// Call/run method internal (No Emit on Socket)
|
|
419
|
+
MethodManager.prototype.callMethodInternal = function (method) {
|
|
420
|
+
var _a;
|
|
421
|
+
var _this = this;
|
|
422
|
+
var methodData = [];
|
|
423
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
424
|
+
methodData[_i - 1] = arguments[_i];
|
|
425
|
+
}
|
|
426
|
+
this._debugCallMethodInternalHits += 1;
|
|
427
|
+
if (!this._methods[method]) {
|
|
428
|
+
console.log('No Method: ' + method);
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !this._methods[method].skipValidation) {
|
|
432
|
+
if (!this._methods[method].check) {
|
|
433
|
+
console.error(new Date(), 'No Check Function For Method ' + method);
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
else if (!this._methods[method].check._schema) {
|
|
437
|
+
console.error(new Date(), 'No Check Schema For Method ' + method);
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (method !== 'insertSubscriptionLog' && method !== 'getDataURIfromURL' && method !== 'processAirdropDistribution') {
|
|
442
|
+
log_collection_1.Logs.insertOne({
|
|
443
|
+
_id: (0, mongo_manager_1.objectIdHexString)(),
|
|
444
|
+
type: 'callMethodInternal',
|
|
445
|
+
collection: '',
|
|
446
|
+
id_document: '',
|
|
447
|
+
payload: (0, common_1.getBinarySize)(JSON.stringify([methodData])) < 200000 ? JSON.stringify([methodData], null, 2) : 'Too Big',
|
|
448
|
+
method: method,
|
|
449
|
+
id_user: this['id_user'] || '',
|
|
450
|
+
user: this['user'] || '',
|
|
451
|
+
messageId: 0,
|
|
452
|
+
route: ''
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
var functionMethodData = typeof (methodData[methodData.length - 1]) === 'function' ? methodData.slice(0, -1) : methodData;
|
|
456
|
+
var monitor = this._monitorManagerFunction.startMonitorFunction('Internal Method', method, this['user'] || '', '', functionMethodData);
|
|
457
|
+
var promise = (_a = this._methods[method].function).call.apply(_a, __spreadArray([Object.assign({}, this, MethodManager.prototype)], functionMethodData, false)).then(function (res) {
|
|
458
|
+
_this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
459
|
+
return res;
|
|
460
|
+
}, function (methodErrs) {
|
|
461
|
+
_this._monitorManagerFunction.finishMonitorFunction(monitor);
|
|
462
|
+
_this.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + _this.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodInternal)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
463
|
+
return methodErrs;
|
|
464
|
+
});
|
|
465
|
+
if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
|
|
466
|
+
promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
|
|
467
|
+
}
|
|
468
|
+
return promise;
|
|
469
|
+
};
|
|
470
|
+
MethodManager.prototype.sendWS = function (ws, messageDate, method, methodData, data) {
|
|
471
|
+
this._sendQueue.splice(0, 0, {
|
|
472
|
+
id_ws: ws['id_socket'],
|
|
473
|
+
method: method,
|
|
474
|
+
methodData: methodData,
|
|
475
|
+
data: data,
|
|
476
|
+
date: messageDate
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
MethodManager.prototype.sendEmail = function (sendTo, subject, text, html, attachments, send_from, reply_to) {
|
|
480
|
+
var _this = this;
|
|
481
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
482
|
+
var _this = this;
|
|
483
|
+
return __generator(this, function (_a) {
|
|
484
|
+
if ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\@resolveio\.com/))) {
|
|
485
|
+
sendTo = 'dev@resolveio.com';
|
|
486
|
+
}
|
|
487
|
+
if (sendTo) {
|
|
488
|
+
if (this.serverConfig['ROOT_URL'] !== 'http://localhost:4200') {
|
|
489
|
+
this._mailer.sendMail({
|
|
490
|
+
replyTo: reply_to !== null && reply_to !== undefined ? reply_to : (this.serverConfig['MAIL_REPLY_TO'] || undefined),
|
|
491
|
+
from: send_from ? send_from : this.serverConfig.MAIL_FROM,
|
|
492
|
+
to: sendTo,
|
|
493
|
+
subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) ? '(DEV SERVER) - ' : '') + subject,
|
|
494
|
+
text: text,
|
|
495
|
+
html: html,
|
|
496
|
+
attachments: attachments
|
|
497
|
+
}, function (err, info) {
|
|
498
|
+
if (err) {
|
|
499
|
+
console.log(err);
|
|
500
|
+
email_history_collection_1.EmailHistories.create({
|
|
501
|
+
_id: (0, mongo_manager_1.objectIdHexString)(),
|
|
502
|
+
__v: 0,
|
|
503
|
+
date: new Date(),
|
|
504
|
+
id_user: _this['id_user'] || '',
|
|
505
|
+
user: _this['user'] || '',
|
|
506
|
+
email: sendTo,
|
|
507
|
+
success: false,
|
|
508
|
+
verified: false
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
email_history_collection_1.EmailHistories.create({
|
|
513
|
+
_id: (0, mongo_manager_1.objectIdHexString)(),
|
|
514
|
+
__v: 0,
|
|
515
|
+
date: new Date(),
|
|
516
|
+
id_user: _this['id_user'] || '',
|
|
517
|
+
user: _this['user'] || '',
|
|
518
|
+
email: sendTo,
|
|
519
|
+
success: true,
|
|
520
|
+
verified: false
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
console.log('Send email', sendTo, subject, text, html, attachments, send_from);
|
|
527
|
+
}
|
|
528
|
+
resolve(true);
|
|
529
|
+
}
|
|
530
|
+
return [2 /*return*/];
|
|
531
|
+
});
|
|
532
|
+
}); });
|
|
533
|
+
};
|
|
534
|
+
MethodManager.prototype.getAWS = function () {
|
|
535
|
+
return this._aws;
|
|
536
|
+
};
|
|
537
|
+
MethodManager.prototype.readFile = function (fileName) {
|
|
538
|
+
var _this = this;
|
|
539
|
+
return new Promise(function (resolve, reject) {
|
|
540
|
+
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
541
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', function (err, res) {
|
|
542
|
+
if (err) {
|
|
543
|
+
reject(err);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
resolve(res);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
|
|
552
|
+
fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'utf-8', function (err, res) {
|
|
553
|
+
if (err) {
|
|
554
|
+
reject(err);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
resolve(res);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
MethodManager.prototype.readImage = function (fileName) {
|
|
565
|
+
var _this = this;
|
|
566
|
+
return new Promise(function (resolve, reject) {
|
|
567
|
+
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
568
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', function (err, res) {
|
|
569
|
+
if (err) {
|
|
570
|
+
reject(err);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
resolve(res);
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
if (fs.existsSync(path.join(_this.clientDir, ('./private/' + fileName)))) {
|
|
579
|
+
fs.readFile(path.join(_this.clientDir, ('./private/' + fileName)), 'base64', function (err, res) {
|
|
580
|
+
if (err) {
|
|
581
|
+
reject(err);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
resolve(res);
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
return MethodManager;
|
|
592
|
+
}());
|
|
593
|
+
exports.MethodManager = MethodManager;
|
|
594
|
+
|
|
595
|
+
//# sourceMappingURL=method.manager.js.map
|