@resolveio/server-lib 1.0.0-rc19 → 1.0.0-rc2

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.
Files changed (157) hide show
  1. package/collections/active-subscription.collection.js +1 -68
  2. package/collections/app-status.collection.js +1 -43
  3. package/collections/app-version.collection.js +1 -56
  4. package/collections/counter.collection.js +1 -73
  5. package/collections/cron-job-history.collection.js +1 -86
  6. package/collections/cron-job.collection.js +1 -89
  7. package/collections/file.collection.js +1 -73
  8. package/collections/flag.collection.js +1 -47
  9. package/collections/log.collection.js +1 -64
  10. package/collections/logged-in-users.collection.js +1 -70
  11. package/collections/method-call.collection.js +1 -44
  12. package/collections/method-response.collection.js +1 -48
  13. package/collections/queue-flag.collection.js +1 -41
  14. package/collections/queue-method.collection.js +1 -116
  15. package/collections/queue-response.collection.js +1 -78
  16. package/collections/support-ticket.collection.js +1 -146
  17. package/collections/user.collection.js +1 -108
  18. package/cron/cron.js +1 -160
  19. package/fixtures/cron-jobs.js +1 -72
  20. package/fixtures/init.js +1 -73
  21. package/http/auth.js +1 -472
  22. package/http/health.js +1 -8
  23. package/index.js +1 -123
  24. package/managers/cron.manager.js +1 -193
  25. package/managers/method.manager.js +1 -513
  26. package/managers/queue-method.manager.js +1 -239
  27. package/managers/subscription.manager.js +1 -700
  28. package/managers/support.manager.js +1 -208
  29. package/methods/accounts.js +1 -253
  30. package/methods/aws.js +1 -323
  31. package/methods/cloudconvert.js +1 -37
  32. package/methods/collections.js +1 -738
  33. package/methods/counters.js +1 -404
  34. package/methods/cron-jobs.js +1 -63
  35. package/methods/flags.js +1 -6
  36. package/methods/logs.js +1 -29
  37. package/methods/pdf.js +1 -303
  38. package/models/active-subscription.model.js +1 -2
  39. package/models/app-status.model.js +1 -2
  40. package/models/app-version.model.js +1 -2
  41. package/models/collection-document.model.js +1 -2
  42. package/models/counter.model.js +1 -2
  43. package/models/cron-job-history.model.js +1 -2
  44. package/models/cron-job.model.js +1 -2
  45. package/models/dialog.model.js +1 -2
  46. package/models/file.model.js +1 -2
  47. package/models/flag.model.js +1 -2
  48. package/models/log.model.js +1 -2
  49. package/models/logged-in-users.model.js +1 -2
  50. package/models/method-call.model.js +1 -2
  51. package/models/method-response.model.js +1 -2
  52. package/models/method.model.js +1 -2
  53. package/models/pagination.model.js +1 -20
  54. package/models/permission.model.js +1 -2
  55. package/models/queue-method.model.js +1 -2
  56. package/models/queue-response.model.js +1 -2
  57. package/models/select-data-label.model.js +1 -2
  58. package/models/server-response.model.js +1 -2
  59. package/models/subscription.model.js +1 -2
  60. package/models/support-method.model.js +1 -2
  61. package/models/support-ticket.model.js +1 -2
  62. package/models/user.model.js +1 -2
  63. package/package.json +2 -5
  64. package/publications/app-status.js +1 -14
  65. package/publications/app-version.js +1 -14
  66. package/publications/cron-jobs.js +1 -14
  67. package/publications/files.js +1 -71
  68. package/publications/flags.js +1 -23
  69. package/publications/logs.js +1 -26
  70. package/publications/method-calls.js +1 -14
  71. package/publications/method-responses.js +1 -14
  72. package/publications/super-admin.js +1 -21
  73. package/publications/support-tickets.js +1 -118
  74. package/server-app.js +1 -640
  75. package/support-methods/aws.js +1 -276
  76. package/support-methods/collections.js +1 -471
  77. package/support-methods/counters.js +1 -189
  78. package/support-methods/support.js +1 -19
  79. package/util/common.js +1 -334
  80. package/collections/active-subscription.collection.d.ts +0 -8
  81. package/collections/app-status.collection.d.ts +0 -8
  82. package/collections/app-version.collection.d.ts +0 -8
  83. package/collections/counter.collection.d.ts +0 -10
  84. package/collections/cron-job-history.collection.d.ts +0 -8
  85. package/collections/cron-job.collection.d.ts +0 -8
  86. package/collections/file.collection.d.ts +0 -10
  87. package/collections/flag.collection.d.ts +0 -8
  88. package/collections/log.collection.d.ts +0 -8
  89. package/collections/logged-in-users.collection.d.ts +0 -8
  90. package/collections/method-call.collection.d.ts +0 -7
  91. package/collections/method-response.collection.d.ts +0 -7
  92. package/collections/queue-flag.collection.d.ts +0 -8
  93. package/collections/queue-method.collection.d.ts +0 -8
  94. package/collections/queue-response.collection.d.ts +0 -8
  95. package/collections/support-ticket.collection.d.ts +0 -8
  96. package/collections/user.collection.d.ts +0 -9
  97. package/cron/cron.d.ts +0 -6
  98. package/fixtures/cron-jobs.d.ts +0 -2
  99. package/fixtures/init.d.ts +0 -2
  100. package/http/auth.d.ts +0 -3
  101. package/http/health.d.ts +0 -2
  102. package/index.d.ts +0 -15
  103. package/managers/cron.manager.d.ts +0 -17
  104. package/managers/method.manager.d.ts +0 -27
  105. package/managers/queue-method.manager.d.ts +0 -14
  106. package/managers/subscription.manager.d.ts +0 -27
  107. package/managers/support.manager.d.ts +0 -18
  108. package/methods/accounts.d.ts +0 -3
  109. package/methods/aws.d.ts +0 -3
  110. package/methods/cloudconvert.d.ts +0 -3
  111. package/methods/collections.d.ts +0 -3
  112. package/methods/counters.d.ts +0 -3
  113. package/methods/cron-jobs.d.ts +0 -3
  114. package/methods/flags.d.ts +0 -3
  115. package/methods/logs.d.ts +0 -3
  116. package/methods/pdf.d.ts +0 -3
  117. package/models/active-subscription.model.d.ts +0 -14
  118. package/models/app-status.model.d.ts +0 -5
  119. package/models/app-version.model.d.ts +0 -5
  120. package/models/collection-document.model.d.ts +0 -7
  121. package/models/counter.model.d.ts +0 -6
  122. package/models/cron-job-history.model.d.ts +0 -13
  123. package/models/cron-job.model.d.ts +0 -14
  124. package/models/dialog.model.d.ts +0 -24
  125. package/models/file.model.d.ts +0 -10
  126. package/models/flag.model.d.ts +0 -6
  127. package/models/log.model.d.ts +0 -12
  128. package/models/logged-in-users.model.d.ts +0 -10
  129. package/models/method-call.model.d.ts +0 -8
  130. package/models/method-response.model.d.ts +0 -9
  131. package/models/method.model.d.ts +0 -11
  132. package/models/pagination.model.d.ts +0 -12
  133. package/models/permission.model.d.ts +0 -13
  134. package/models/queue-method.model.d.ts +0 -10
  135. package/models/queue-response.model.d.ts +0 -11
  136. package/models/select-data-label.model.d.ts +0 -10
  137. package/models/server-response.model.d.ts +0 -6
  138. package/models/subscription.model.d.ts +0 -31
  139. package/models/support-method.model.d.ts +0 -10
  140. package/models/support-ticket.model.d.ts +0 -40
  141. package/models/user.model.d.ts +0 -15
  142. package/publications/app-status.d.ts +0 -3
  143. package/publications/app-version.d.ts +0 -3
  144. package/publications/cron-jobs.d.ts +0 -3
  145. package/publications/files.d.ts +0 -3
  146. package/publications/flags.d.ts +0 -3
  147. package/publications/logs.d.ts +0 -3
  148. package/publications/method-calls.d.ts +0 -3
  149. package/publications/method-responses.d.ts +0 -3
  150. package/publications/super-admin.d.ts +0 -3
  151. package/publications/support-tickets.d.ts +0 -2
  152. package/server-app.d.ts +0 -33
  153. package/support-methods/aws.d.ts +0 -3
  154. package/support-methods/collections.d.ts +0 -3
  155. package/support-methods/counters.d.ts +0 -3
  156. package/support-methods/support.d.ts +0 -3
  157. package/util/common.d.ts +0 -15
package/cron/cron.js CHANGED
@@ -1,160 +1 @@
1
- var CronJob = require('cron').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;
@@ -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;