@resolveio/server-lib 1.0.0-rc27 → 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.
Files changed (159) 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 -125
  24. package/managers/cron.manager.js +1 -193
  25. package/managers/method.manager.js +1 -544
  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 -641
  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 -17
  103. package/managers/cron.manager.d.ts +0 -17
  104. package/managers/method.manager.d.ts +0 -28
  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/notification.model.d.ts +0 -5
  133. package/models/notification.model.js +0 -2
  134. package/models/pagination.model.d.ts +0 -12
  135. package/models/permission.model.d.ts +0 -13
  136. package/models/queue-method.model.d.ts +0 -10
  137. package/models/queue-response.model.d.ts +0 -11
  138. package/models/select-data-label.model.d.ts +0 -10
  139. package/models/server-response.model.d.ts +0 -6
  140. package/models/subscription.model.d.ts +0 -31
  141. package/models/support-method.model.d.ts +0 -10
  142. package/models/support-ticket.model.d.ts +0 -40
  143. package/models/user.model.d.ts +0 -15
  144. package/publications/app-status.d.ts +0 -3
  145. package/publications/app-version.d.ts +0 -3
  146. package/publications/cron-jobs.d.ts +0 -3
  147. package/publications/files.d.ts +0 -3
  148. package/publications/flags.d.ts +0 -3
  149. package/publications/logs.d.ts +0 -3
  150. package/publications/method-calls.d.ts +0 -3
  151. package/publications/method-responses.d.ts +0 -3
  152. package/publications/super-admin.d.ts +0 -3
  153. package/publications/support-tickets.d.ts +0 -2
  154. package/server-app.d.ts +0 -34
  155. package/support-methods/aws.d.ts +0 -3
  156. package/support-methods/collections.d.ts +0 -3
  157. package/support-methods/counters.d.ts +0 -3
  158. package/support-methods/support.d.ts +0 -3
  159. package/util/common.d.ts +0 -15
@@ -1,193 +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 CronJobManager = require('../cron/cron');
40
- var CronManager = /** @class */ (function () {
41
- function CronManager(mainServer) {
42
- this._mainServer = mainServer;
43
- this._cronManager = new CronJobManager();
44
- this.loadCronJobs();
45
- }
46
- CronManager.prototype.loadCronJobs = function () {
47
- return __awaiter(this, void 0, void 0, function () {
48
- var jobs;
49
- var _this = this;
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({}).exec()];
53
- case 1:
54
- jobs = _a.sent();
55
- jobs.forEach(function (job) {
56
- _this.addCronJob(job);
57
- });
58
- return [2 /*return*/];
59
- }
60
- });
61
- });
62
- };
63
- CronManager.prototype.doesCronJobExist = function (cron) {
64
- return this._cronManager.exists(cron.name);
65
- };
66
- CronManager.prototype.doesCronJobNameExist = function (cron_name) {
67
- return this._cronManager.exists(cron_name);
68
- };
69
- CronManager.prototype.addCronJob = function (cron) {
70
- var _this = this;
71
- if (!this.doesCronJobExist(cron)) {
72
- if (cron.timezone) {
73
- }
74
- else {
75
- var cronOptions = {
76
- start: true,
77
- };
78
- if (cron.timezone) {
79
- cronOptions['timeZone'] = cron.timezone;
80
- }
81
- this._cronManager.add(cron.name, cron.time_to_run, function () {
82
- _this.runCronJob(cron);
83
- }, cronOptions);
84
- }
85
- }
86
- };
87
- CronManager.prototype.updateCronJob = function (cron) {
88
- if (this.doesCronJobExist(cron)) {
89
- this._cronManager.update(cron.name, cron.time_to_run);
90
- }
91
- };
92
- CronManager.prototype.removeCronJob = function (cron_name) {
93
- if (this.doesCronJobNameExist(cron_name)) {
94
- this._cronManager.deleteJob(cron_name);
95
- }
96
- };
97
- CronManager.prototype.startCronJob = function (cron) {
98
- if (this.doesCronJobExist(cron)) {
99
- this._cronManager.start(cron.name);
100
- }
101
- };
102
- CronManager.prototype.stopCronJob = function (cron) {
103
- if (this.doesCronJobExist(cron)) {
104
- this._cronManager.start(cron.name);
105
- }
106
- };
107
- CronManager.prototype.stopAllCronJobs = function () {
108
- this._cronManager.stopAll();
109
- };
110
- CronManager.prototype.checkCronJobsForUpdates = function () {
111
- return __awaiter(this, void 0, void 0, function () {
112
- var jobs;
113
- var _this = this;
114
- return __generator(this, function (_a) {
115
- switch (_a.label) {
116
- case 0: return [4 /*yield*/, cron_job_collection_1.CronJobs.find({}).exec()];
117
- case 1:
118
- jobs = _a.sent();
119
- // Remove deleted cron jobs
120
- this._cronManager.getJobs().forEach(function (cronJob) {
121
- if (jobs.map(function (a) { return a.name; }).indexOf(cronJob) === -1) {
122
- _this.removeCronJob(cronJob);
123
- }
124
- });
125
- // Add new cron jobs
126
- jobs.forEach(function (cronJob) {
127
- _this.addCronJob(cronJob);
128
- });
129
- // Update cronjobs
130
- jobs.forEach(function (cronJob) {
131
- _this.updateCronJob(cronJob);
132
- });
133
- return [2 /*return*/];
134
- }
135
- });
136
- });
137
- };
138
- CronManager.prototype.runCronJob = function (cron) {
139
- var _this = this;
140
- var now = new Date();
141
- if (!cron.next_run || now.getTime() >= cron.next_run.getTime()) {
142
- cron_job_collection_1.CronJobs.findOneAndUpdate({
143
- $and: [
144
- { _id: cron._id },
145
- { running: false }
146
- ]
147
- }, { $set: { running: true } }).exec(function (err, res) { return __awaiter(_this, void 0, void 0, function () {
148
- return __generator(this, function (_a) {
149
- switch (_a.label) {
150
- case 0:
151
- if (!res) return [3 /*break*/, 9];
152
- if (!cron.method_run_data) return [3 /*break*/, 2];
153
- return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_run, cron.method_run_data)];
154
- case 1:
155
- _a.sent();
156
- return [3 /*break*/, 4];
157
- case 2: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_run)];
158
- case 3:
159
- _a.sent();
160
- _a.label = 4;
161
- case 4:
162
- if (!cron.method_complete) return [3 /*break*/, 8];
163
- if (!cron.method_complete_data) return [3 /*break*/, 6];
164
- return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_complete, cron.method_complete_data)];
165
- case 5:
166
- _a.sent();
167
- return [3 /*break*/, 8];
168
- case 6: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_complete)];
169
- case 7:
170
- _a.sent();
171
- _a.label = 8;
172
- case 8:
173
- if (cron.repeat) {
174
- cron_job_collection_1.CronJobs.updateOne({
175
- $and: [
176
- { _id: cron._id },
177
- { running: true }
178
- ]
179
- }, { $set: { running: false, next_run: this._cronManager.getJob(cron.name).nextDates().toDate() } }).exec();
180
- }
181
- else {
182
- cron_job_collection_1.CronJobs.deleteOne({ _id: cron._id }).exec();
183
- }
184
- _a.label = 9;
185
- case 9: return [2 /*return*/];
186
- }
187
- });
188
- }); });
189
- }
190
- };
191
- return CronManager;
192
- }());
193
- exports.CronManager = CronManager;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(a,i,c,s){return new(c||(c=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 c(function(e){e(n.value)}).then(t,o)}r((s=s.apply(a,i||[])).next())})},__generator=this&&this.__generator||function(t,o){var r,a,i,e,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(;c;)try{if(r=1,a&&(i=2&n[0]?a.return:n[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,n[1])).done)return i;switch(a=0,i&&(n=[2&n[0],i.value]),n[0]){case 0:case 1:i=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,a=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(i=0<(i=c.trys).length&&i[i.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]<i[3])){c.label=n[1];break}if(6===n[0]&&c.label<i[1]){c.label=i[1],i=n;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(n);break}i[2]&&c.ops.pop(),c.trys.pop();continue}n=o.call(t,c)}catch(e){n=[6,e],a=0}finally{r=i=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"),CronJobManager=require("../cron/cron"),CronManager=function(){function e(e){this._mainServer=e,this._cronManager=new CronJobManager,this.loadCronJobs()}return e.prototype.loadCronJobs=function(){return __awaiter(this,void 0,void 0,function(){var n=this;return __generator(this,function(e){switch(e.label){case 0:return[4,cron_job_collection_1.CronJobs.find({}).exec()];case 1:return e.sent().forEach(function(e){n.addCronJob(e)}),[2]}})})},e.prototype.doesCronJobExist=function(e){return this._cronManager.exists(e.name)},e.prototype.doesCronJobNameExist=function(e){return this._cronManager.exists(e)},e.prototype.addCronJob=function(e){var n=this;if(!this.doesCronJobExist(e))if(e.timezone);else{var t={start:!0};e.timezone&&(t.timeZone=e.timezone),this._cronManager.add(e.name,e.time_to_run,function(){n.runCronJob(e)},t)}},e.prototype.updateCronJob=function(e){this.doesCronJobExist(e)&&this._cronManager.update(e.name,e.time_to_run)},e.prototype.removeCronJob=function(e){this.doesCronJobNameExist(e)&&this._cronManager.deleteJob(e)},e.prototype.startCronJob=function(e){this.doesCronJobExist(e)&&this._cronManager.start(e.name)},e.prototype.stopCronJob=function(e){this.doesCronJobExist(e)&&this._cronManager.start(e.name)},e.prototype.stopAllCronJobs=function(){this._cronManager.stopAll()},e.prototype.checkCronJobsForUpdates=function(){return __awaiter(this,void 0,void 0,function(){var n,t=this;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(),this._cronManager.getJobs().forEach(function(e){-1===n.map(function(e){return e.name}).indexOf(e)&&t.removeCronJob(e)}),n.forEach(function(e){t.addCronJob(e)}),n.forEach(function(e){t.updateCronJob(e)}),[2]}})})},e.prototype.runCronJob=function(t){var o=this,e=new Date;(!t.next_run||e.getTime()>=t.next_run.getTime())&&cron_job_collection_1.CronJobs.findOneAndUpdate({$and:[{_id:t._id},{running:!1}]},{$set:{running:!0}}).exec(function(e,n){return __awaiter(o,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return n?t.method_run_data?[4,this._mainServer.getMethodManager().callMethodCron(t.method_run,t.method_run_data)]:[3,2]:[3,9];case 1:return e.sent(),[3,4];case 2:return[4,this._mainServer.getMethodManager().callMethodCron(t.method_run)];case 3:e.sent(),e.label=4;case 4:return t.method_complete?t.method_complete_data?[4,this._mainServer.getMethodManager().callMethodCron(t.method_complete,t.method_complete_data)]:[3,6]:[3,8];case 5:return e.sent(),[3,8];case 6:return[4,this._mainServer.getMethodManager().callMethodCron(t.method_complete)];case 7:e.sent(),e.label=8;case 8:t.repeat?cron_job_collection_1.CronJobs.updateOne({$and:[{_id:t._id},{running:!0}]},{$set:{running:!1,next_run:this._cronManager.getJob(t.name).nextDates().toDate()}}).exec():cron_job_collection_1.CronJobs.deleteOne({_id:t._id}).exec(),e.label=9;case 9:return[2]}})})})},e}();exports.CronManager=CronManager;