@resolveio/server-lib 9.0.34 → 9.0.35
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 +48 -7
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +11 -8
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +11 -8
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +11 -8
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +12 -9
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +11 -8
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +11 -8
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +12 -9
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +11 -8
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +11 -8
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +14 -11
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +16 -13
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +19 -16
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +12 -9
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +13 -10
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +13 -10
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +16 -13
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +16 -13
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +18 -15
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +15 -12
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +15 -12
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +11 -8
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.js +12 -9
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.js +12 -9
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.js +12 -9
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +13 -10
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +14 -11
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +14 -11
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +14 -11
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +11 -8
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +15 -12
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +25 -25
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +80 -30
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +59 -9
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +460 -344
- package/http/auth.js.map +1 -1
- package/http/health.js +5 -1
- package/http/health.js.map +1 -1
- package/http/home.js +11 -7
- package/http/home.js.map +1 -1
- package/index.js +98 -36
- package/index.js.map +1 -1
- package/managers/cron.manager.js +157 -78
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +302 -314
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1001 -739
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +254 -171
- package/managers/monitor.manager.js.map +1 -1
- package/managers/queue-method.manager.js +166 -69
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +714 -515
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +183 -111
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +262 -156
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +180 -100
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +110 -103
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +79 -29
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +884 -819
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +5 -1
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +313 -258
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +348 -289
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +340 -341
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +657 -565
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +185 -67
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +2 -1
- package/models/app-version.model.js +2 -1
- package/models/billing-logged-in-users.model.js +2 -1
- package/models/collection-document.model.js +2 -1
- package/models/counter.model.js +2 -1
- package/models/cron-job-history.model.js +2 -1
- package/models/cron-job.model.js +2 -1
- package/models/dialog.model.js +2 -1
- package/models/email-history.model.js +2 -1
- package/models/email-verified.model.js +2 -1
- package/models/file.model.js +2 -1
- package/models/flag.model.js +2 -1
- package/models/log-method-latency.model.js +2 -1
- package/models/log-subscription.model.js +2 -1
- package/models/log.model.js +2 -1
- package/models/logged-in-users.model.js +2 -1
- package/models/method-call.model.js +2 -1
- package/models/method-response.model.js +2 -1
- package/models/method.model.js +2 -1
- package/models/monitor-cpu.model.js +2 -1
- package/models/monitor-https-inbound.model.js +2 -1
- package/models/monitor-https-outbound.model.js +2 -1
- package/models/monitor-memory.model.js +2 -1
- package/models/monitor-mongo.model.js +2 -1
- package/models/notification.model.js +2 -1
- package/models/pagination.model.js +5 -2
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +2 -1
- package/models/queue-method.model.js +2 -1
- package/models/queue-response.model.js +2 -1
- package/models/report-builder-dashboard-builder.model.js +2 -1
- package/models/report-builder-library.model.js +2 -1
- package/models/report-builder-report.model.js +2 -1
- package/models/report-builder.model.js +2 -1
- package/models/select-data-label.model.js +2 -1
- package/models/server-response.model.js +2 -1
- package/models/subscription.model.js +2 -1
- package/models/support-ticket.model.js +2 -1
- package/models/user-group.model.js +2 -1
- package/models/user-guide.model.js +2 -1
- package/models/user.model.js +2 -1
- package/package.json +1 -1
- package/public_api.js +82 -70
- package/public_api.js.map +1 -1
- package/publications/app-status.js +8 -4
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +8 -4
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +13 -9
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +15 -11
- package/publications/files.js.map +1 -1
- package/publications/flags.js +11 -7
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +35 -31
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +8 -4
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +8 -4
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +8 -4
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +12 -8
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +66 -16
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +21 -17
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +7 -3
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +8 -4
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +8 -4
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +534 -393
- package/server-app.js.map +1 -1
- package/util/common.js +92 -55
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +134 -76
- package/util/schema-report-builder.js.map +1 -1
package/cron/cron.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
var CronJobPackage = require('cron').CronJob;
|
|
2
2
|
function CrontabManager(key, tab, task, options) {
|
|
3
3
|
this.jobs = {};
|
|
4
4
|
if (key && tab && task) {
|
|
@@ -17,16 +17,16 @@ CrontabManager.prototype.add = function (key, tab, task, options) {
|
|
|
17
17
|
try {
|
|
18
18
|
if (this.jobs[key]) {
|
|
19
19
|
this.deleteJob(key);
|
|
20
|
-
console.warn(
|
|
20
|
+
console.warn(key + " already existed and was deleted from the manager...");
|
|
21
21
|
}
|
|
22
22
|
this.jobs[key] = new CronJobPackage(options);
|
|
23
23
|
}
|
|
24
24
|
catch (fooBaredByUser) {
|
|
25
|
-
console.error(
|
|
25
|
+
console.error("crontab: " + tab + " possibly not valid, job " + key + " not started..." + fooBaredByUser.message);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
console.warn(
|
|
29
|
+
console.warn("couldn't add: " + key + " improper arguments");
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
CrontabManager.prototype.update = function () {
|
|
@@ -43,7 +43,7 @@ CrontabManager.prototype.update = function () {
|
|
|
43
43
|
updateTask.call(this, arguments[0], arguments[2]);
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
console.error(
|
|
46
|
+
console.error("incorrect number of arguents passed to update.. won't update.. " + arguments[0]);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
CrontabManager.prototype.deleteJob = function (key) {
|
|
@@ -52,38 +52,38 @@ CrontabManager.prototype.deleteJob = function (key) {
|
|
|
52
52
|
delete this.jobs[key];
|
|
53
53
|
}
|
|
54
54
|
catch (err) {
|
|
55
|
-
console.error(
|
|
55
|
+
console.error("error in trying to stop job: " + key + ": " + err);
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
CrontabManager.prototype.start = function (key) {
|
|
59
59
|
try {
|
|
60
60
|
if (this.jobs[key].running) {
|
|
61
|
-
console.warn(
|
|
61
|
+
console.warn(key + " job already running");
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
64
|
this.jobs[key].start();
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
68
|
-
console.error(
|
|
68
|
+
console.error("couldn't start job: " + key + ": " + err);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
CrontabManager.prototype.stop = function (key) {
|
|
72
72
|
try {
|
|
73
73
|
if (!this.jobs[key].running) {
|
|
74
|
-
console.warn(
|
|
74
|
+
console.warn(key + " job already stopped");
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
this.jobs[key].stop();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
catch (err) {
|
|
81
|
-
console.error(
|
|
81
|
+
console.error("couldn't stop job: " + key + ": " + err);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
CrontabManager.prototype.stopAll = function () {
|
|
85
85
|
// tslint:disable-next-line:forin
|
|
86
|
-
for (
|
|
86
|
+
for (var jobKey in this.jobs) {
|
|
87
87
|
try {
|
|
88
88
|
this.jobs[jobKey].stop();
|
|
89
89
|
}
|
|
@@ -92,19 +92,19 @@ CrontabManager.prototype.stopAll = function () {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
CrontabManager.prototype.toString = function () {
|
|
95
|
-
|
|
95
|
+
var manString = '{\n';
|
|
96
96
|
// tslint:disable-next-line:forin
|
|
97
|
-
for (
|
|
98
|
-
manString +=
|
|
97
|
+
for (var jobKey in this.jobs) {
|
|
98
|
+
manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + ": " + this.jobs[jobKey]._callbacks[0] + ": " + (this.jobs[jobKey].running ? 'Running' : 'Stopped');
|
|
99
99
|
}
|
|
100
100
|
manString += '\n}';
|
|
101
101
|
return manString;
|
|
102
102
|
};
|
|
103
103
|
CrontabManager.prototype.listCrons = function () {
|
|
104
|
-
|
|
104
|
+
var manString = '{\n';
|
|
105
105
|
// tslint:disable-next-line:forin
|
|
106
|
-
for (
|
|
107
|
-
manString +=
|
|
106
|
+
for (var jobKey in this.jobs) {
|
|
107
|
+
manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + " status: " + (this.jobs[jobKey].running ? 'Running' : 'Stopped') + " \n";
|
|
108
108
|
}
|
|
109
109
|
manString += '\n}';
|
|
110
110
|
return manString;
|
|
@@ -116,13 +116,13 @@ CrontabManager.prototype.exists = function (tabKey) {
|
|
|
116
116
|
return false;
|
|
117
117
|
};
|
|
118
118
|
function combineOptions(tab, task, options) {
|
|
119
|
-
|
|
119
|
+
var newOpts = {};
|
|
120
120
|
newOpts['cronTime'] = tab;
|
|
121
121
|
newOpts['onTick'] = task;
|
|
122
122
|
if (options instanceof Object) {
|
|
123
123
|
// might overwrite... please be careful.
|
|
124
124
|
// tslint:disable-next-line:forin
|
|
125
|
-
for (
|
|
125
|
+
for (var optionKey in options) {
|
|
126
126
|
newOpts[optionKey] = options[optionKey];
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -130,31 +130,31 @@ function combineOptions(tab, task, options) {
|
|
|
130
130
|
}
|
|
131
131
|
function updateTab(key, cronstring) {
|
|
132
132
|
try {
|
|
133
|
-
|
|
133
|
+
var running = this.jobs[key].running;
|
|
134
134
|
this.jobs[key].stop();
|
|
135
135
|
if (typeof cronstring === 'string' || cronstring instanceof Date) {
|
|
136
136
|
this.jobs[key] = new CronJobPackage(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);
|
|
137
137
|
}
|
|
138
138
|
else {
|
|
139
|
-
throw new Error(
|
|
139
|
+
throw new Error("The cron definition passed was not a string or a Date object! " + key + " was stopped and not updated");
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
catch (tabErr) {
|
|
143
|
-
console.error(
|
|
143
|
+
console.error("error updating tab: " + key + " - " + tabErr.message);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
function updateTask(key, task) {
|
|
147
147
|
try {
|
|
148
|
-
|
|
148
|
+
var running = this.jobs[key].running;
|
|
149
149
|
this.jobs[key].stop();
|
|
150
150
|
if (!(task instanceof Function)) {
|
|
151
|
-
console.error(
|
|
151
|
+
console.error("can't update with something that is not a function: " + typeof (task));
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
this.jobs[key] = new CronJobPackage(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);
|
|
155
155
|
}
|
|
156
156
|
catch (tabErr) {
|
|
157
|
-
console.error(
|
|
157
|
+
console.error("error updating task: " + key + " - " + tabErr.message);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
module.exports = CrontabManager;
|
package/cron/cron.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cron/cron.ts"],"names":[],"mappings":"AAAA,IAAI,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;AAE7C,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO;IAC9C,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACf,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE;QACvB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;KAClC;AAEF,CAAC;AAED,cAAc,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,GAAG;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,cAAc,CAAC,SAAS,CAAC,OAAO,GAAG;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,cAAc,CAAC,SAAS,CAAC,GAAG,GAAG,UAAS,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO;IAC9D,IAAI,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,IAAI,CAAC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,IAAI,YAAY,QAAQ,EAAE;QAC5G,OAAO,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,C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AE;QACd,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;KAChE;AACF,CAAC;AAED,SAAS,UAAU,CAAC,GAAG,EAAE,IAAI;IAC5B,IAAI;QACH,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAEtB,IAAI,CAAC,CAAC,IAAI,YAAY,QAAQ,CAAC,EAAE;YAChC,OAAO,CAAC,KAAK,CAAC,uDAAuD,OAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACrF,OAAO;SACP;QAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAI,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;KAGpI;IACD,OAAO,MAAM,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,wBAAwB,GAAG,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;KAClE;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC","file":"cron.js","sourcesContent":["let CronJobPackage = require('cron').CronJob;\n\nfunction CrontabManager(key, tab, task, options) {\n\tthis.jobs = {};\n\tif (key && tab && task) {\n\t\tthis.add(key, tab, task, options);\n\t}\n\n}\n\nCrontabManager.prototype.getJob = function(key) {\n\treturn this.jobs[key];\n};\n\nCrontabManager.prototype.getJobs = function() {\n\treturn Object.keys(this.jobs);\n};\n\nCrontabManager.prototype.add = function(key, tab, task, options) {\n\tif ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {\n\t\toptions = combineOptions(tab, task, options);\n\t\ttry {\n\t\t\tif (this.jobs[key]) {\n\t\t\t\tthis.deleteJob(key);\n\t\t\t\tconsole.warn(`${key} already existed and was deleted from the manager...`);\n\t\t\t}\n\t\t\t\n\t\t\tthis.jobs[key] = new CronJobPackage(options);\n\t\t} \n\t\tcatch (fooBaredByUser) {\n\t\t\tconsole.error(`crontab: ${tab} possibly not valid, job ${key} not started...${fooBaredByUser.message}`);\n\t\t}\n\t}\n\telse {\n\t\tconsole.warn(`couldn't add: ${key} improper arguments`);\n\t}\n};\n\nCrontabManager.prototype.update = function() {\n\tif (arguments.length === 2) {\n\t\tif (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {\n\t\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\t}\n\t\telse if (arguments[1] instanceof Function) {\n\t\t\tupdateTask.call(this, arguments[0], arguments[1]);\n\t\t}\n\t} \n\telse if (arguments.length === 3) {\n\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\tupdateTask.call(this, arguments[0], arguments[2]);\n\t}\n\telse {\n\t\tconsole.error(`incorrect number of arguents passed to update.. won't update.. ${arguments[0]}`);\n\t}\n};\n\nCrontabManager.prototype.deleteJob = function(key) {\n\ttry {\n\t\tthis.jobs[key].stop();\n\t\tdelete this.jobs[key];\n\t}\n\tcatch (err) { \n\t\tconsole.error(`error in trying to stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.start = function(key) {\n\ttry {\n\t\tif (this.jobs[key].running) {\n\t\t\tconsole.warn(`${key} job already running`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].start();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't start job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stop = function(key) {\n\ttry {\n\t\tif (! this.jobs[key].running ) {\n\t\t\tconsole.warn(`${key} job already stopped`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].stop();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stopAll = function() {\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\ttry {\n\t\t\tthis.jobs[jobKey].stop();\n\t\t}\n\t\tcatch (err) {\n\n\t\t}\n\t}\n};\n\nCrontabManager.prototype.toString = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source}: ${this.jobs[jobKey]._callbacks[0]}: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'}`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.listCrons = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source} status: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'} \\n`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.exists = function(tabKey) {\n\tif (this.jobs[tabKey]) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\nfunction combineOptions(tab, task, options) {\n\tlet newOpts = {};\n\tnewOpts['cronTime'] = tab; \n\tnewOpts['onTick'] = task;\n\n\tif (options instanceof Object) {\n\t\t// might overwrite... please be careful.\n\t\t// tslint:disable-next-line:forin\n\t\tfor (let optionKey in options) {\n\t\t\tnewOpts[optionKey] = options[optionKey];\n\t\t}\n\t}\n\treturn newOpts;\n}\n\nfunction updateTab(key, cronstring) {\n\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (typeof cronstring === 'string' || cronstring instanceof Date) {\n\t\t\tthis.jobs[key] = new CronJobPackage(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);\n\t\t}\n\t\telse {\n\t\t\tthrow new Error(`The cron definition passed was not a string or a Date object! ${key} was stopped and not updated`);\n\t\t}\n\t}\n\tcatch (tabErr) {\n\t\tconsole.error(`error updating tab: ${key} - ${tabErr.message}`);\n\t}\n}\n\nfunction updateTask(key, task) {\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (!(task instanceof Function)) {\n\t\t\tconsole.error(`can't update with something that is not a function: ${typeof(task)}`);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.jobs[key] = new CronJobPackage(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);\n\n\n\t} \n\tcatch (tabErr) {\n\t\tconsole.error(`error updating task: ${key} - ${tabErr.message}`);\n\t}\n}\n\nmodule.exports = CrontabManager;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cron/cron.ts"],"names":[],"mappings":"AAAA,IAAI,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;AAE7C,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO;IAC9C,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACf,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,EAAE;QACvB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;KAClC;AAEF,CAAC;AAED,cAAc,CAAC,SAAS,CAAC,MAAM,GAAG,UAAS,GAAG;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,cAAc,CAAC,SAAS,CAAC,OAAO,GAAG;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,cAAc,CAAC,SAAS,CAAC,GAAG,GAAG,UAAS,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO;IA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C,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;SACxI;aACI;YACJ,MAAM,IAAI,KAAK,CAAC,mEAAiE,GAAG,iCAA8B,CAAC,CAAC;SACpH;KACD;IACD,OAAO,MAAM,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,yBAAuB,GAAG,WAAM,MAAM,CAAC,OAAS,CAAC,CAAC;KAChE;AACF,CAAC;AAED,SAAS,UAAU,CAAC,GAAG,EAAE,IAAI;IAC5B,IAAI;QACH,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAEtB,IAAI,CAAC,CAAC,IAAI,YAAY,QAAQ,CAAC,EAAE;YAChC,OAAO,CAAC,KAAK,CAAC,yDAAuD,OAAM,CAAC,IAAI,CAAG,CAAC,CAAC;YACrF,OAAO;SACP;QAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAI,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;KAGpI;IACD,OAAO,MAAM,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,0BAAwB,GAAG,YAAO,MAAM,CAAC,OAAS,CAAC,CAAC;KAClE;AACF,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC","file":"cron.js","sourcesContent":["let CronJobPackage = require('cron').CronJob;\n\nfunction CrontabManager(key, tab, task, options) {\n\tthis.jobs = {};\n\tif (key && tab && task) {\n\t\tthis.add(key, tab, task, options);\n\t}\n\n}\n\nCrontabManager.prototype.getJob = function(key) {\n\treturn this.jobs[key];\n};\n\nCrontabManager.prototype.getJobs = function() {\n\treturn Object.keys(this.jobs);\n};\n\nCrontabManager.prototype.add = function(key, tab, task, options) {\n\tif ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {\n\t\toptions = combineOptions(tab, task, options);\n\t\ttry {\n\t\t\tif (this.jobs[key]) {\n\t\t\t\tthis.deleteJob(key);\n\t\t\t\tconsole.warn(`${key} already existed and was deleted from the manager...`);\n\t\t\t}\n\t\t\t\n\t\t\tthis.jobs[key] = new CronJobPackage(options);\n\t\t} \n\t\tcatch (fooBaredByUser) {\n\t\t\tconsole.error(`crontab: ${tab} possibly not valid, job ${key} not started...${fooBaredByUser.message}`);\n\t\t}\n\t}\n\telse {\n\t\tconsole.warn(`couldn't add: ${key} improper arguments`);\n\t}\n};\n\nCrontabManager.prototype.update = function() {\n\tif (arguments.length === 2) {\n\t\tif (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {\n\t\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\t}\n\t\telse if (arguments[1] instanceof Function) {\n\t\t\tupdateTask.call(this, arguments[0], arguments[1]);\n\t\t}\n\t} \n\telse if (arguments.length === 3) {\n\t\tupdateTab.call(this, arguments[0], arguments[1]);\n\t\tupdateTask.call(this, arguments[0], arguments[2]);\n\t}\n\telse {\n\t\tconsole.error(`incorrect number of arguents passed to update.. won't update.. ${arguments[0]}`);\n\t}\n};\n\nCrontabManager.prototype.deleteJob = function(key) {\n\ttry {\n\t\tthis.jobs[key].stop();\n\t\tdelete this.jobs[key];\n\t}\n\tcatch (err) { \n\t\tconsole.error(`error in trying to stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.start = function(key) {\n\ttry {\n\t\tif (this.jobs[key].running) {\n\t\t\tconsole.warn(`${key} job already running`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].start();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't start job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stop = function(key) {\n\ttry {\n\t\tif (! this.jobs[key].running ) {\n\t\t\tconsole.warn(`${key} job already stopped`);\n\t\t}\n\t\telse {\n\t\t\tthis.jobs[key].stop();\n\t\t}\n\t}\n\tcatch (err) {\n\t\tconsole.error(`couldn't stop job: ${key}: ${err}`);\n\t}\n};\n\nCrontabManager.prototype.stopAll = function() {\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\ttry {\n\t\t\tthis.jobs[jobKey].stop();\n\t\t}\n\t\tcatch (err) {\n\n\t\t}\n\t}\n};\n\nCrontabManager.prototype.toString = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source}: ${this.jobs[jobKey]._callbacks[0]}: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'}`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.listCrons = function() {\n\tlet manString = '{\\n';\n\t// tslint:disable-next-line:forin\n\tfor (let jobKey in this.jobs) {\n\t\tmanString += `'${jobKey}': ${this.jobs[jobKey].cronTime.source} status: ${this.jobs[jobKey].running ? 'Running' : 'Stopped'} \\n`;\n\t}\n\tmanString += '\\n}';\n\treturn manString;\n};\n\nCrontabManager.prototype.exists = function(tabKey) {\n\tif (this.jobs[tabKey]) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\nfunction combineOptions(tab, task, options) {\n\tlet newOpts = {};\n\tnewOpts['cronTime'] = tab; \n\tnewOpts['onTick'] = task;\n\n\tif (options instanceof Object) {\n\t\t// might overwrite... please be careful.\n\t\t// tslint:disable-next-line:forin\n\t\tfor (let optionKey in options) {\n\t\t\tnewOpts[optionKey] = options[optionKey];\n\t\t}\n\t}\n\treturn newOpts;\n}\n\nfunction updateTab(key, cronstring) {\n\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (typeof cronstring === 'string' || cronstring instanceof Date) {\n\t\t\tthis.jobs[key] = new CronJobPackage(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);\n\t\t}\n\t\telse {\n\t\t\tthrow new Error(`The cron definition passed was not a string or a Date object! ${key} was stopped and not updated`);\n\t\t}\n\t}\n\tcatch (tabErr) {\n\t\tconsole.error(`error updating tab: ${key} - ${tabErr.message}`);\n\t}\n}\n\nfunction updateTask(key, task) {\n\ttry {\n\t\tlet running = this.jobs[key].running;\n\t\tthis.jobs[key].stop();\n\n\t\tif (!(task instanceof Function)) {\n\t\t\tconsole.error(`can't update with something that is not a function: ${typeof(task)}`);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.jobs[key] = new CronJobPackage(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);\n\n\n\t} \n\tcatch (tabErr) {\n\t\tconsole.error(`error updating task: ${key} - ${tabErr.message}`);\n\t}\n}\n\nmodule.exports = CrontabManager;\n"]}
|
package/fixtures/cron-jobs.js
CHANGED
|
@@ -1,36 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
17
36
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadServerCronJobs = void 0;
|
|
40
|
+
var cron_job_collection_1 = require("../collections/cron-job.collection");
|
|
41
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
42
|
+
function loadServerCronJobs() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var cronJobs;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({})];
|
|
48
|
+
case 1:
|
|
49
|
+
cronJobs = _a.sent();
|
|
50
|
+
if (!cronJobs.filter(function (a) { return a.name === 'Method Queue'; }).length) {
|
|
51
|
+
cron_job_collection_1.CronJobs.create({
|
|
52
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
53
|
+
__v: 0,
|
|
54
|
+
name: 'Method Queue',
|
|
55
|
+
repeat: true,
|
|
56
|
+
time_to_run: '*/5 * * * * *',
|
|
57
|
+
method_run: 'methodQueue',
|
|
58
|
+
method_run_data: null,
|
|
59
|
+
next_run: new Date(),
|
|
60
|
+
running: false
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (!cronJobs.some(function (a) { return a.name === 'Email Merged Docs Cleanup'; })) {
|
|
64
|
+
cron_job_collection_1.CronJobs.create({
|
|
65
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
66
|
+
__v: 0,
|
|
67
|
+
name: 'Email Merged Docs Cleanup',
|
|
68
|
+
repeat: true,
|
|
69
|
+
time_to_run: '0 0 * * *',
|
|
70
|
+
method_run: 'cronEmailMergedDocsCleanUp',
|
|
71
|
+
method_run_data: null,
|
|
72
|
+
next_run: new Date(),
|
|
73
|
+
running: false
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
cronJobs.filter(function (a) { return a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime(); }).forEach(function (cronJob) {
|
|
77
|
+
cron_job_collection_1.CronJobs.updateOne({ _id: cronJob._id }, { $set: { running: false } });
|
|
78
|
+
});
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
}
|
|
29
81
|
});
|
|
30
|
-
}
|
|
31
|
-
cronJobs.filter(a => a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime()).forEach(cronJob => {
|
|
32
|
-
CronJobs.updateOne({ _id: cronJob._id }, { $set: { running: false } });
|
|
33
82
|
});
|
|
34
83
|
}
|
|
84
|
+
exports.loadServerCronJobs = loadServerCronJobs;
|
|
35
85
|
|
|
36
86
|
//# sourceMappingURL=cron-jobs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fixtures/cron-jobs.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/fixtures/cron-jobs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAA8D;AAC9D,2DAA8D;AAE9D,SAAsB,kBAAkB;;;;;wBAExB,qBAAM,8BAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBAEtC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,cAAc,EAAzB,CAAyB,CAAC,CAAC,MAAM,EAAE;wBAC5D,8BAAQ,CAAC,MAAM,CACd;4BACC,GAAG,EAAE,iCAAiB,EAAE;4BACxB,GAAG,EAAE,CAAC;4BACN,IAAI,EAAE,cAAc;4BACpB,MAAM,EAAG,IAAI;4BACb,WAAW,EAAG,eAAe;4BAC7B,UAAU,EAAG,aAAa;4BAC1B,eAAe,EAAG,IAAI;4BACtB,QAAQ,EAAG,IAAI,IAAI,EAAE;4BACrB,OAAO,EAAG,KAAK;yBACf,CACD,CAAC;qBACF;oBAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,2BAA2B,EAAtC,CAAsC,CAAC,EAAE;wBAChE,8BAAQ,CAAC,MAAM,CAAC;4BACf,GAAG,EAAE,iCAAiB,EAAE;4BACxB,GAAG,EAAE,CAAC;4BACN,IAAI,EAAG,2BAA2B;4BAClC,MAAM,EAAG,IAAI;4BACb,WAAW,EAAG,WAAW;4BACzB,UAAU,EAAG,4BAA4B;4BACzC,eAAe,EAAG,IAAI;4BACtB,QAAQ,EAAG,IAAI,IAAI,EAAE;4BACrB,OAAO,EAAG,KAAK;yBACf,CAAC,CAAC;qBACH;oBAED,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAxE,CAAwE,CAAC,CAAC,OAAO,CAAC,UAAA,OAAO;wBAC7G,8BAAQ,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,EAAC,CAAC,CAAC;oBAClE,CAAC,CAAC,CAAC;;;;;CACH;AArCD,gDAqCC","file":"cron-jobs.js","sourcesContent":["import { CronJobs } from '../collections/cron-job.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport async function loadServerCronJobs() {\n\n\tlet cronJobs = await CronJobs.find({});\n\n\tif (!cronJobs.filter(a => a.name === 'Method Queue').length) {\n\t\tCronJobs.create(\n\t\t\t{\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tname: 'Method Queue',\n\t\t\t\trepeat : true, \n\t\t\t\ttime_to_run : '*/5 * * * * *', \n\t\t\t\tmethod_run : 'methodQueue', \n\t\t\t\tmethod_run_data : null, \n\t\t\t\tnext_run : new Date(), \n\t\t\t\trunning : false\n\t\t\t}\n\t\t);\n\t}\n\n\tif (!cronJobs.some(a => a.name === 'Email Merged Docs Cleanup')) {\n\t\tCronJobs.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\t__v: 0,\n\t\t\tname : 'Email Merged Docs Cleanup', \n\t\t\trepeat : true, \n\t\t\ttime_to_run : '0 0 * * *', \n\t\t\tmethod_run : 'cronEmailMergedDocsCleanUp', \n\t\t\tmethod_run_data : null, \n\t\t\tnext_run : new Date(), \n\t\t\trunning : false\n\t\t});\n\t}\n\n\tcronJobs.filter(a => a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime()).forEach(cronJob => {\n\t\tCronJobs.updateOne({_id: cronJob._id}, {$set: {running: false}});\n\t});\n} "]}
|
package/fixtures/init.js
CHANGED
|
@@ -1,13 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
10
36
|
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadServerInit = void 0;
|
|
40
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
41
|
+
var app_version_collection_1 = require("../collections/app-version.collection");
|
|
42
|
+
function loadServerInit() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var appVersion;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0: return [4 /*yield*/, app_version_collection_1.AppVersions.findOne()];
|
|
48
|
+
case 1:
|
|
49
|
+
appVersion = _a.sent();
|
|
50
|
+
if (!appVersion) {
|
|
51
|
+
app_version_collection_1.AppVersions.create({
|
|
52
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
53
|
+
version: 1
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return [2 /*return*/];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
11
60
|
}
|
|
61
|
+
exports.loadServerInit = loadServerInit;
|
|
12
62
|
|
|
13
63
|
//# sourceMappingURL=init.js.map
|
package/fixtures/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fixtures/init.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/fixtures/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA8D;AAC9D,gFAAoE;AAEpE,SAAsB,cAAc;;;;;wBAClB,qBAAM,oCAAW,CAAC,OAAO,EAAE,EAAA;;oBAAxC,UAAU,GAAG,SAA2B;oBAE5C,IAAI,CAAC,UAAU,EAAE;wBAChB,oCAAW,CAAC,MAAM,CAAC;4BAClB,GAAG,EAAE,iCAAiB,EAAE;4BACxB,OAAO,EAAE,CAAC;yBACV,CAAC,CAAC;qBACH;;;;;CACD;AATD,wCASC","file":"init.js","sourcesContent":["import { objectIdHexString } from '../managers/mongo.manager';\nimport { AppVersions } from '../collections/app-version.collection';\n\nexport async function loadServerInit() {\n\tlet appVersion = await AppVersions.findOne();\n\n\tif (!appVersion) {\n\t\tAppVersions.create({\n\t\t\t_id: objectIdHexString(),\n\t\t\tversion: 1\n\t\t});\n\t}\n}"]}
|