@resolveio/server-lib 1.0.0-rc28 → 1.0.0-rc3
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/collections/active-subscription.collection.js +1 -68
- package/collections/app-status.collection.js +1 -43
- package/collections/app-version.collection.js +1 -56
- package/collections/counter.collection.js +1 -73
- package/collections/cron-job-history.collection.js +1 -86
- package/collections/cron-job.collection.js +1 -89
- package/collections/file.collection.js +1 -73
- package/collections/flag.collection.js +1 -47
- package/collections/log.collection.js +1 -64
- package/collections/logged-in-users.collection.js +1 -70
- package/collections/method-call.collection.js +1 -44
- package/collections/method-response.collection.js +1 -48
- package/collections/queue-flag.collection.js +1 -41
- package/collections/queue-method.collection.js +1 -116
- package/collections/queue-response.collection.js +1 -78
- package/collections/support-ticket.collection.js +1 -146
- package/collections/user.collection.js +1 -108
- package/cron/cron.js +1 -160
- package/fixtures/cron-jobs.js +1 -72
- package/fixtures/init.js +1 -73
- package/http/auth.js +1 -472
- package/http/health.js +1 -8
- package/index.js +1 -125
- package/managers/cron.manager.js +1 -193
- package/managers/method.manager.js +1 -544
- package/managers/queue-method.manager.js +1 -239
- package/managers/subscription.manager.js +1 -700
- package/managers/support.manager.js +1 -208
- package/methods/accounts.js +1 -253
- package/methods/aws.js +1 -345
- package/methods/cloudconvert.js +1 -37
- package/methods/collections.js +1 -738
- package/methods/counters.js +1 -404
- package/methods/cron-jobs.js +1 -63
- package/methods/flags.js +1 -6
- package/methods/logs.js +1 -29
- package/methods/pdf.js +1 -303
- package/models/active-subscription.model.js +1 -2
- package/models/app-status.model.js +1 -2
- package/models/app-version.model.js +1 -2
- package/models/collection-document.model.js +1 -2
- package/models/counter.model.js +1 -2
- package/models/cron-job-history.model.js +1 -2
- package/models/cron-job.model.js +1 -2
- package/models/dialog.model.js +1 -2
- package/models/file.model.js +1 -2
- package/models/flag.model.js +1 -2
- package/models/log.model.js +1 -2
- package/models/logged-in-users.model.js +1 -2
- package/models/method-call.model.js +1 -2
- package/models/method-response.model.js +1 -2
- package/models/method.model.js +1 -2
- package/models/pagination.model.js +1 -20
- package/models/permission.model.js +1 -2
- package/models/queue-method.model.js +1 -2
- package/models/queue-response.model.js +1 -2
- package/models/select-data-label.model.js +1 -2
- package/models/server-response.model.js +1 -2
- package/models/subscription.model.js +1 -2
- package/models/support-method.model.js +1 -2
- package/models/support-ticket.model.js +1 -2
- package/models/user.model.js +1 -2
- package/package.json +2 -5
- package/publications/app-status.js +1 -14
- package/publications/app-version.js +1 -14
- package/publications/cron-jobs.js +1 -14
- package/publications/files.js +1 -71
- package/publications/flags.js +1 -23
- package/publications/logs.js +1 -26
- package/publications/method-calls.js +1 -14
- package/publications/method-responses.js +1 -14
- package/publications/super-admin.js +1 -21
- package/publications/support-tickets.js +1 -118
- package/server-app.js +1 -641
- package/support-methods/aws.js +1 -276
- package/support-methods/collections.js +1 -471
- package/support-methods/counters.js +1 -189
- package/support-methods/support.js +1 -19
- package/util/common.js +1 -334
- package/collections/active-subscription.collection.d.ts +0 -8
- package/collections/app-status.collection.d.ts +0 -8
- package/collections/app-version.collection.d.ts +0 -8
- package/collections/counter.collection.d.ts +0 -10
- package/collections/cron-job-history.collection.d.ts +0 -8
- package/collections/cron-job.collection.d.ts +0 -8
- package/collections/file.collection.d.ts +0 -10
- package/collections/flag.collection.d.ts +0 -8
- package/collections/log.collection.d.ts +0 -8
- package/collections/logged-in-users.collection.d.ts +0 -8
- package/collections/method-call.collection.d.ts +0 -7
- package/collections/method-response.collection.d.ts +0 -7
- package/collections/queue-flag.collection.d.ts +0 -8
- package/collections/queue-method.collection.d.ts +0 -8
- package/collections/queue-response.collection.d.ts +0 -8
- package/collections/support-ticket.collection.d.ts +0 -8
- package/collections/user.collection.d.ts +0 -9
- package/cron/cron.d.ts +0 -6
- package/fixtures/cron-jobs.d.ts +0 -2
- package/fixtures/init.d.ts +0 -2
- package/http/auth.d.ts +0 -3
- package/http/health.d.ts +0 -2
- package/index.d.ts +0 -17
- package/managers/cron.manager.d.ts +0 -17
- package/managers/method.manager.d.ts +0 -28
- package/managers/queue-method.manager.d.ts +0 -14
- package/managers/subscription.manager.d.ts +0 -27
- package/managers/support.manager.d.ts +0 -18
- package/methods/accounts.d.ts +0 -3
- package/methods/aws.d.ts +0 -3
- package/methods/cloudconvert.d.ts +0 -3
- package/methods/collections.d.ts +0 -3
- package/methods/counters.d.ts +0 -3
- package/methods/cron-jobs.d.ts +0 -3
- package/methods/flags.d.ts +0 -3
- package/methods/logs.d.ts +0 -3
- package/methods/pdf.d.ts +0 -3
- package/models/active-subscription.model.d.ts +0 -14
- package/models/app-status.model.d.ts +0 -5
- package/models/app-version.model.d.ts +0 -5
- package/models/collection-document.model.d.ts +0 -7
- package/models/counter.model.d.ts +0 -6
- package/models/cron-job-history.model.d.ts +0 -13
- package/models/cron-job.model.d.ts +0 -14
- package/models/dialog.model.d.ts +0 -24
- package/models/file.model.d.ts +0 -10
- package/models/flag.model.d.ts +0 -6
- package/models/log.model.d.ts +0 -12
- package/models/logged-in-users.model.d.ts +0 -10
- package/models/method-call.model.d.ts +0 -8
- package/models/method-response.model.d.ts +0 -9
- package/models/method.model.d.ts +0 -11
- package/models/notification.model.d.ts +0 -5
- package/models/notification.model.js +0 -2
- package/models/pagination.model.d.ts +0 -12
- package/models/permission.model.d.ts +0 -13
- package/models/queue-method.model.d.ts +0 -10
- package/models/queue-response.model.d.ts +0 -11
- package/models/select-data-label.model.d.ts +0 -10
- package/models/server-response.model.d.ts +0 -6
- package/models/subscription.model.d.ts +0 -31
- package/models/support-method.model.d.ts +0 -10
- package/models/support-ticket.model.d.ts +0 -40
- package/models/user.model.d.ts +0 -15
- package/publications/app-status.d.ts +0 -3
- package/publications/app-version.d.ts +0 -3
- package/publications/cron-jobs.d.ts +0 -3
- package/publications/files.d.ts +0 -3
- package/publications/flags.d.ts +0 -3
- package/publications/logs.d.ts +0 -3
- package/publications/method-calls.d.ts +0 -3
- package/publications/method-responses.d.ts +0 -3
- package/publications/super-admin.d.ts +0 -3
- package/publications/support-tickets.d.ts +0 -2
- package/server-app.d.ts +0 -34
- package/support-methods/aws.d.ts +0 -3
- package/support-methods/collections.d.ts +0 -3
- package/support-methods/counters.d.ts +0 -3
- package/support-methods/support.d.ts +0 -3
- package/util/common.d.ts +0 -15
package/cron/cron.js
CHANGED
|
@@ -1,160 +1 @@
|
|
|
1
|
-
var CronJob =
|
|
2
|
-
function CrontabManager(key, tab, task, options) {
|
|
3
|
-
this.jobs = {};
|
|
4
|
-
if (key && tab && task) {
|
|
5
|
-
this.add(key, tab, task, options);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
CrontabManager.prototype.getJob = function (key) {
|
|
9
|
-
return this.jobs[key];
|
|
10
|
-
};
|
|
11
|
-
CrontabManager.prototype.getJobs = function () {
|
|
12
|
-
return Object.keys(this.jobs);
|
|
13
|
-
};
|
|
14
|
-
CrontabManager.prototype.add = function (key, tab, task, options) {
|
|
15
|
-
if ((typeof tab === 'string' || tab instanceof Date) && typeof key === 'string' && task instanceof Function) {
|
|
16
|
-
options = combineOptions(tab, task, options);
|
|
17
|
-
try {
|
|
18
|
-
if (this.jobs[key]) {
|
|
19
|
-
this.deleteJob(key);
|
|
20
|
-
console.warn(key + " already existed and was deleted from the manager...");
|
|
21
|
-
}
|
|
22
|
-
this.jobs[key] = new CronJob(options);
|
|
23
|
-
}
|
|
24
|
-
catch (fooBaredByUser) {
|
|
25
|
-
console.error("crontab: " + tab + " possibly not valid, job " + key + " not started..." + fooBaredByUser.message);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
console.warn("couldn't add: " + key + " improper arguments");
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
CrontabManager.prototype.update = function () {
|
|
33
|
-
if (arguments.length === 2) {
|
|
34
|
-
if (typeof arguments[1] === 'string' || arguments[1] instanceof Date) {
|
|
35
|
-
updateTab.call(this, arguments[0], arguments[1]);
|
|
36
|
-
}
|
|
37
|
-
else if (arguments[1] instanceof Function) {
|
|
38
|
-
updateTask.call(this, arguments[0], arguments[1]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (arguments.length === 3) {
|
|
42
|
-
updateTab.call(this, arguments[0], arguments[1]);
|
|
43
|
-
updateTask.call(this, arguments[0], arguments[2]);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.error("incorrect number of arguents passed to update.. won't update.. " + arguments[0]);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
CrontabManager.prototype.deleteJob = function (key) {
|
|
50
|
-
try {
|
|
51
|
-
this.jobs[key].stop();
|
|
52
|
-
delete this.jobs[key];
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
console.error("error in trying to stop job: " + key + ": " + err);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
CrontabManager.prototype.start = function (key) {
|
|
59
|
-
try {
|
|
60
|
-
if (this.jobs[key].running) {
|
|
61
|
-
console.warn(key + " job already running");
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
this.jobs[key].start();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
console.error("couldn't start job: " + key + ": " + err);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
CrontabManager.prototype.stop = function (key) {
|
|
72
|
-
try {
|
|
73
|
-
if (!this.jobs[key].running) {
|
|
74
|
-
console.warn(key + " job already stopped");
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
this.jobs[key].stop();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
console.error("couldn't stop job: " + key + ": " + err);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
CrontabManager.prototype.stopAll = function () {
|
|
85
|
-
// tslint:disable-next-line:forin
|
|
86
|
-
for (var jobKey in this.jobs) {
|
|
87
|
-
try {
|
|
88
|
-
this.jobs[jobKey].stop();
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
CrontabManager.prototype.toString = function () {
|
|
95
|
-
var manString = '{\n';
|
|
96
|
-
// tslint:disable-next-line:forin
|
|
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
|
-
}
|
|
100
|
-
manString += '\n}';
|
|
101
|
-
return manString;
|
|
102
|
-
};
|
|
103
|
-
CrontabManager.prototype.listCrons = function () {
|
|
104
|
-
var manString = '{\n';
|
|
105
|
-
// tslint:disable-next-line:forin
|
|
106
|
-
for (var jobKey in this.jobs) {
|
|
107
|
-
manString += "'" + jobKey + "': " + this.jobs[jobKey].cronTime.source + " status: " + (this.jobs[jobKey].running ? 'Running' : 'Stopped') + " \n";
|
|
108
|
-
}
|
|
109
|
-
manString += '\n}';
|
|
110
|
-
return manString;
|
|
111
|
-
};
|
|
112
|
-
CrontabManager.prototype.exists = function (tabKey) {
|
|
113
|
-
if (this.jobs[tabKey]) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
};
|
|
118
|
-
function combineOptions(tab, task, options) {
|
|
119
|
-
var newOpts = {};
|
|
120
|
-
newOpts['cronTime'] = tab;
|
|
121
|
-
newOpts['onTick'] = task;
|
|
122
|
-
if (options instanceof Object) {
|
|
123
|
-
// might overwrite... please be careful.
|
|
124
|
-
// tslint:disable-next-line:forin
|
|
125
|
-
for (var optionKey in options) {
|
|
126
|
-
newOpts[optionKey] = options[optionKey];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return newOpts;
|
|
130
|
-
}
|
|
131
|
-
function updateTab(key, cronstring) {
|
|
132
|
-
try {
|
|
133
|
-
var running = this.jobs[key].running;
|
|
134
|
-
this.jobs[key].stop();
|
|
135
|
-
if (typeof cronstring === 'string' || cronstring instanceof Date) {
|
|
136
|
-
this.jobs[key] = new CronJob(cronstring, this.jobs[key]._callbacks[0], this.jobs[key].onComplete, running, this.jobs[key].zone);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
throw new Error("The cron definition passed was not a string or a Date object! " + key + " was stopped and not updated");
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch (tabErr) {
|
|
143
|
-
console.error("error updating tab: " + key + " - " + tabErr.message);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function updateTask(key, task) {
|
|
147
|
-
try {
|
|
148
|
-
var running = this.jobs[key].running;
|
|
149
|
-
this.jobs[key].stop();
|
|
150
|
-
if (!(task instanceof Function)) {
|
|
151
|
-
console.error("can't update with something that is not a function: " + typeof (task));
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
this.jobs[key] = new CronJob(this.jobs[key].cronTime.source, task, this.jobs[key].onComplete, running, this.jobs[key].zone);
|
|
155
|
-
}
|
|
156
|
-
catch (tabErr) {
|
|
157
|
-
console.error("error updating task: " + key + " - " + tabErr.message);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
module.exports = CrontabManager;
|
|
1
|
+
var CronJob=require("cron").CronJob;function CrontabManager(o,t,n,r){this.jobs={},o&&t&&n&&this.add(o,t,n,r)}function combineOptions(o,t,n){var r={};if(r.cronTime=o,r.onTick=t,n instanceof Object)for(var e in n)r[e]=n[e];return r}function updateTab(t,o){try{var n=this.jobs[t].running;if(this.jobs[t].stop(),!("string"==typeof o||o instanceof Date))throw new Error("The cron definition passed was not a string or a Date object! "+t+" was stopped and not updated");this.jobs[t]=new CronJob(o,this.jobs[t]._callbacks[0],this.jobs[t].onComplete,n,this.jobs[t].zone)}catch(o){console.error("error updating tab: "+t+" - "+o.message)}}function updateTask(t,o){try{var n=this.jobs[t].running;if(this.jobs[t].stop(),!(o instanceof Function))return void console.error("can't update with something that is not a function: "+typeof o);this.jobs[t]=new CronJob(this.jobs[t].cronTime.source,o,this.jobs[t].onComplete,n,this.jobs[t].zone)}catch(o){console.error("error updating task: "+t+" - "+o.message)}}CrontabManager.prototype.getJob=function(o){return this.jobs[o]},CrontabManager.prototype.getJobs=function(){return Object.keys(this.jobs)},CrontabManager.prototype.add=function(t,n,o,r){if(("string"==typeof n||n instanceof Date)&&"string"==typeof t&&o instanceof Function){r=combineOptions(n,o,r);try{this.jobs[t]&&(this.deleteJob(t),console.warn(t+" already existed and was deleted from the manager...")),this.jobs[t]=new CronJob(r)}catch(o){console.error("crontab: "+n+" possibly not valid, job "+t+" not started..."+o.message)}}else console.warn("couldn't add: "+t+" improper arguments")},CrontabManager.prototype.update=function(){2===arguments.length?"string"==typeof arguments[1]||arguments[1]instanceof Date?updateTab.call(this,arguments[0],arguments[1]):arguments[1]instanceof Function&&updateTask.call(this,arguments[0],arguments[1]):3===arguments.length?(updateTab.call(this,arguments[0],arguments[1]),updateTask.call(this,arguments[0],arguments[2])):console.error("incorrect number of arguents passed to update.. won't update.. "+arguments[0])},CrontabManager.prototype.deleteJob=function(t){try{this.jobs[t].stop(),delete this.jobs[t]}catch(o){console.error("error in trying to stop job: "+t+": "+o)}},CrontabManager.prototype.start=function(t){try{this.jobs[t].running?console.warn(t+" job already running"):this.jobs[t].start()}catch(o){console.error("couldn't start job: "+t+": "+o)}},CrontabManager.prototype.stop=function(t){try{this.jobs[t].running?this.jobs[t].stop():console.warn(t+" job already stopped")}catch(o){console.error("couldn't stop job: "+t+": "+o)}},CrontabManager.prototype.stopAll=function(){for(var o in this.jobs)try{this.jobs[o].stop()}catch(o){}},CrontabManager.prototype.toString=function(){var o="{\n";for(var t in this.jobs)o+="'"+t+"': "+this.jobs[t].cronTime.source+": "+this.jobs[t]._callbacks[0]+": "+(this.jobs[t].running?"Running":"Stopped");return o+="\n}"},CrontabManager.prototype.listCrons=function(){var o="{\n";for(var t in this.jobs)o+="'"+t+"': "+this.jobs[t].cronTime.source+" status: "+(this.jobs[t].running?"Running":"Stopped")+" \n";return o+="\n}"},CrontabManager.prototype.exists=function(o){return!!this.jobs[o]},module.exports=CrontabManager;
|
package/fixtures/cron-jobs.js
CHANGED
|
@@ -1,72 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
var cron_job_collection_1 = require("../collections/cron-job.collection");
|
|
39
|
-
var mongoose_1 = require("mongoose");
|
|
40
|
-
function loadServerCronJobs() {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
var cronJobs;
|
|
43
|
-
return __generator(this, function (_a) {
|
|
44
|
-
switch (_a.label) {
|
|
45
|
-
case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({}).exec()];
|
|
46
|
-
case 1:
|
|
47
|
-
cronJobs = _a.sent();
|
|
48
|
-
if (!!cronJobs.filter(function (a) { return a.name === 'Method Queue'; }).length) return [3 /*break*/, 3];
|
|
49
|
-
return [4 /*yield*/, cron_job_collection_1.CronJobs.create({
|
|
50
|
-
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
51
|
-
__v: 0,
|
|
52
|
-
name: 'Method Queue',
|
|
53
|
-
reoccuring: true,
|
|
54
|
-
time_to_run: '*/5 * * * * *',
|
|
55
|
-
method_name: 'emailUpdatedChemicalRequests',
|
|
56
|
-
last_run: new Date,
|
|
57
|
-
next_run: new Date,
|
|
58
|
-
running: false
|
|
59
|
-
})];
|
|
60
|
-
case 2:
|
|
61
|
-
_a.sent();
|
|
62
|
-
_a.label = 3;
|
|
63
|
-
case 3:
|
|
64
|
-
cronJobs.filter(function (a) { return a.running && a.next_run && a.next_run.getTime() < (new Date()).getTime(); }).forEach(function (cronJob) {
|
|
65
|
-
cron_job_collection_1.CronJobs.updateOne({ _id: cronJob._id }, { $set: { running: false } }).exec();
|
|
66
|
-
});
|
|
67
|
-
return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.loadServerCronJobs = loadServerCronJobs;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(i,a,c,u){return new(c||(c=Promise))(function(e,n){function t(e){try{o(u.next(e))}catch(e){n(e)}}function r(e){try{o(u.throw(e))}catch(e){n(e)}}function o(n){n.done?e(n.value):new c(function(e){e(n.value)}).then(t,r)}o((u=u.apply(i,a||[])).next())})},__generator=this&&this.__generator||function(t,r){var o,i,a,e,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return e={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(n){return function(e){return function(n){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(a=2&n[0]?i.return:n[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){c.label=n[1];break}if(6===n[0]&&c.label<a[1]){c.label=a[1],a=n;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(n);break}a[2]&&c.ops.pop(),c.trys.pop();continue}n=r.call(t,c)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,e])}}};Object.defineProperty(exports,"__esModule",{value:!0});var cron_job_collection_1=require("../collections/cron-job.collection"),mongoose_1=require("mongoose");function loadServerCronJobs(){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(e){switch(e.label){case 0:return[4,cron_job_collection_1.CronJobs.find({}).exec()];case 1:return(n=e.sent()).filter(function(e){return"Method Queue"===e.name}).length?[3,3]:[4,cron_job_collection_1.CronJobs.create({_id:mongoose_1.Types.ObjectId().toHexString(),__v:0,name:"Method Queue",reoccuring:!0,time_to_run:"*/5 * * * * *",method_name:"emailUpdatedChemicalRequests",last_run:new Date,next_run:new Date,running:!1})];case 2:e.sent(),e.label=3;case 3:return n.filter(function(e){return e.running&&e.next_run&&e.next_run.getTime()<(new Date).getTime()}).forEach(function(e){cron_job_collection_1.CronJobs.updateOne({_id:e._id},{$set:{running:!1}}).exec()}),[2]}})})}exports.loadServerCronJobs=loadServerCronJobs;
|
package/fixtures/init.js
CHANGED
|
@@ -1,73 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
var app_version_collection_1 = require("../collections/app-version.collection");
|
|
39
|
-
var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
|
|
40
|
-
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
41
|
-
var mongoose_1 = require("mongoose");
|
|
42
|
-
function loadServerInit() {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var appVersion, loggedInUsers, activeSubs;
|
|
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: mongoose_1.Types.ObjectId().toHexString(),
|
|
53
|
-
version: 1
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.find({})];
|
|
57
|
-
case 2:
|
|
58
|
-
loggedInUsers = _a.sent();
|
|
59
|
-
loggedInUsers.forEach(function (loggedInUser) {
|
|
60
|
-
logged_in_users_collection_1.LoggedInUsers.deleteOne({ _id: loggedInUser._id }).exec();
|
|
61
|
-
});
|
|
62
|
-
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.find({})];
|
|
63
|
-
case 3:
|
|
64
|
-
activeSubs = _a.sent();
|
|
65
|
-
activeSubs.forEach(function (sub) {
|
|
66
|
-
active_subscription_collection_1.ActiveSubscriptions.deleteOne({ _id: sub._id }).exec();
|
|
67
|
-
});
|
|
68
|
-
return [2 /*return*/];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
exports.loadServerInit = loadServerInit;
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(i,c,l,s){return new(l||(l=Promise))(function(e,n){function t(e){try{r(s.next(e))}catch(e){n(e)}}function o(e){try{r(s.throw(e))}catch(e){n(e)}}function r(n){n.done?e(n.value):new l(function(e){e(n.value)}).then(t,o)}r((s=s.apply(i,c||[])).next())})},__generator=this&&this.__generator||function(t,o){var r,i,c,e,l={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return e={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(n){return function(e){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;l;)try{if(r=1,i&&(c=2&n[0]?i.return:n[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,n[1])).done)return c;switch(i=0,c&&(n=[2&n[0],c.value]),n[0]){case 0:case 1:c=n;break;case 4:return l.label++,{value:n[1],done:!1};case 5:l.label++,i=n[1],n=[0];continue;case 7:n=l.ops.pop(),l.trys.pop();continue;default:if(!(c=0<(c=l.trys).length&&c[c.length-1])&&(6===n[0]||2===n[0])){l=0;continue}if(3===n[0]&&(!c||n[1]>c[0]&&n[1]<c[3])){l.label=n[1];break}if(6===n[0]&&l.label<c[1]){l.label=c[1],c=n;break}if(c&&l.label<c[2]){l.label=c[2],l.ops.push(n);break}c[2]&&l.ops.pop(),l.trys.pop();continue}n=o.call(t,l)}catch(e){n=[6,e],i=0}finally{r=c=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,e])}}};Object.defineProperty(exports,"__esModule",{value:!0});var app_version_collection_1=require("../collections/app-version.collection"),logged_in_users_collection_1=require("../collections/logged-in-users.collection"),active_subscription_collection_1=require("../collections/active-subscription.collection"),mongoose_1=require("mongoose");function loadServerInit(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,app_version_collection_1.AppVersions.findOne()];case 1:return e.sent()||app_version_collection_1.AppVersions.create({_id:mongoose_1.Types.ObjectId().toHexString(),version:1}),[4,logged_in_users_collection_1.LoggedInUsers.find({})];case 2:return e.sent().forEach(function(e){logged_in_users_collection_1.LoggedInUsers.deleteOne({_id:e._id}).exec()}),[4,active_subscription_collection_1.ActiveSubscriptions.find({})];case 3:return e.sent().forEach(function(e){active_subscription_collection_1.ActiveSubscriptions.deleteOne({_id:e._id}).exec()}),[2]}})})}exports.loadServerInit=loadServerInit;
|