@resolveio/server-lib 3.2.11 → 3.2.12
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.d.ts +7 -0
- package/collections/active-subscription.collection.js +68 -0
- package/collections/app-status.collection.d.ts +7 -0
- package/collections/app-status.collection.js +43 -0
- package/collections/app-version.collection.d.ts +7 -0
- package/collections/app-version.collection.js +56 -0
- package/collections/billing-logged-in-users.collection.d.ts +7 -0
- package/collections/billing-logged-in-users.collection.js +73 -0
- package/collections/counter.collection.d.ts +9 -0
- package/collections/counter.collection.js +73 -0
- package/collections/cron-job-history.collection.d.ts +7 -0
- package/collections/cron-job-history.collection.js +86 -0
- package/collections/cron-job.collection.d.ts +7 -0
- package/collections/cron-job.collection.js +89 -0
- package/collections/file.collection.d.ts +9 -0
- package/collections/file.collection.js +73 -0
- package/collections/flag.collection.d.ts +7 -0
- package/collections/flag.collection.js +47 -0
- package/collections/log.collection.d.ts +7 -0
- package/collections/log.collection.js +65 -0
- package/collections/logged-in-users.collection.d.ts +7 -0
- package/collections/logged-in-users.collection.js +70 -0
- package/collections/method-call.collection.d.ts +6 -0
- package/collections/method-call.collection.js +44 -0
- package/collections/method-response.collection.d.ts +6 -0
- package/collections/method-response.collection.js +48 -0
- package/collections/notification.collection.d.ts +7 -0
- package/collections/notification.collection.js +43 -0
- package/collections/queue-flag.collection.d.ts +7 -0
- package/collections/queue-flag.collection.js +41 -0
- package/collections/queue-method.collection.d.ts +7 -0
- package/collections/queue-method.collection.js +119 -0
- package/collections/queue-response.collection.d.ts +7 -0
- package/collections/queue-response.collection.js +74 -0
- package/collections/support-ticket.collection.d.ts +7 -0
- package/collections/support-ticket.collection.js +200 -0
- package/collections/user.collection.d.ts +9 -0
- package/collections/user.collection.js +153 -0
- package/cron/cron.d.ts +5 -0
- package/cron/cron.js +160 -0
- package/fixtures/cron-jobs.d.ts +1 -0
- package/fixtures/cron-jobs.js +90 -0
- package/fixtures/init.d.ts +1 -0
- package/fixtures/init.js +67 -0
- package/http/auth.d.ts +2 -0
- package/http/auth.js +468 -0
- package/http/health.d.ts +1 -0
- package/http/health.js +8 -0
- package/index.d.ts +16 -0
- package/index.js +125 -0
- package/managers/cron.manager.d.ts +16 -0
- package/managers/cron.manager.js +202 -0
- package/managers/database.manager.d.ts +6 -0
- package/managers/database.manager.js +12 -0
- package/managers/method.manager.d.ts +28 -0
- package/managers/method.manager.js +584 -0
- package/managers/queue-method.manager.d.ts +13 -0
- package/managers/queue-method.manager.js +240 -0
- package/managers/subscription.manager.d.ts +28 -0
- package/managers/subscription.manager.js +808 -0
- package/managers/support.manager.d.ts +22 -0
- package/managers/support.manager.js +320 -0
- package/methods/accounts.d.ts +2 -0
- package/methods/accounts.js +253 -0
- package/methods/aws.d.ts +2 -0
- package/methods/aws.js +387 -0
- package/methods/cloudconvert.d.ts +2 -0
- package/methods/cloudconvert.js +37 -0
- package/methods/collections.d.ts +2 -0
- package/methods/collections.js +750 -0
- package/methods/counters.d.ts +2 -0
- package/methods/counters.js +107 -0
- package/methods/cron-jobs.d.ts +2 -0
- package/methods/cron-jobs.js +132 -0
- package/methods/flags.d.ts +2 -0
- package/methods/flags.js +6 -0
- package/methods/logs.d.ts +2 -0
- package/methods/logs.js +29 -0
- package/methods/pdf.d.ts +2 -0
- package/methods/pdf.js +303 -0
- package/models/active-subscription.model.d.ts +13 -0
- package/models/active-subscription.model.js +2 -0
- package/models/app-status.model.d.ts +4 -0
- package/models/app-status.model.js +2 -0
- package/models/app-version.model.d.ts +4 -0
- package/models/app-version.model.js +2 -0
- package/models/billing-logged-in-users.model.d.ts +7 -0
- package/models/billing-logged-in-users.model.js +2 -0
- package/models/collection-document.model.d.ts +6 -0
- package/models/collection-document.model.js +2 -0
- package/models/counter.model.d.ts +5 -0
- package/models/counter.model.js +2 -0
- package/models/cron-job-history.model.d.ts +12 -0
- package/models/cron-job-history.model.js +2 -0
- package/models/cron-job.model.d.ts +13 -0
- package/models/cron-job.model.js +2 -0
- package/models/dialog.model.d.ts +23 -0
- package/models/dialog.model.js +2 -0
- package/models/file.model.d.ts +9 -0
- package/models/file.model.js +2 -0
- package/models/flag.model.d.ts +5 -0
- package/models/flag.model.js +2 -0
- package/models/log.model.d.ts +11 -0
- package/models/log.model.js +2 -0
- package/models/logged-in-users.model.d.ts +9 -0
- package/models/logged-in-users.model.js +2 -0
- package/models/method-call.model.d.ts +7 -0
- package/models/method-call.model.js +2 -0
- package/models/method-response.model.d.ts +8 -0
- package/models/method-response.model.js +2 -0
- package/models/method.model.d.ts +10 -0
- package/models/method.model.js +2 -0
- package/models/notification.model.d.ts +4 -0
- package/models/notification.model.js +2 -0
- package/models/pagination.model.d.ts +11 -0
- package/models/pagination.model.js +20 -0
- package/models/permission.model.d.ts +12 -0
- package/models/permission.model.js +2 -0
- package/models/queue-method.model.d.ts +10 -0
- package/models/queue-method.model.js +2 -0
- package/models/queue-response.model.d.ts +10 -0
- package/models/queue-response.model.js +2 -0
- package/models/select-data-label.model.d.ts +9 -0
- package/models/select-data-label.model.js +2 -0
- package/models/server-response.model.d.ts +5 -0
- package/models/server-response.model.js +2 -0
- package/models/subscription.model.d.ts +30 -0
- package/models/subscription.model.js +2 -0
- package/models/support-method.model.d.ts +9 -0
- package/models/support-method.model.js +2 -0
- package/models/support-ticket.model.d.ts +61 -0
- package/models/support-ticket.model.js +2 -0
- package/models/user.model.d.ts +14 -0
- package/models/user.model.js +2 -0
- package/package.json +1 -1
- package/private/email-templates/enrollment.html +12 -0
- package/private/email-templates/forgot-password.html +12 -0
- package/private/email-templates/support-ticket-deleted.html +40 -0
- package/private/email-templates/support-ticket-modified.html +71 -0
- package/private/email-templates/support-ticket.html +71 -0
- package/private/images/ResolveIO.png +0 -0
- package/publications/app-status.d.ts +2 -0
- package/publications/app-status.js +14 -0
- package/publications/app-version.d.ts +2 -0
- package/publications/app-version.js +14 -0
- package/publications/billing-logged-in-users.d.ts +1 -0
- package/publications/billing-logged-in-users.js +63 -0
- package/publications/cron-jobs.d.ts +2 -0
- package/publications/cron-jobs.js +14 -0
- package/publications/files.d.ts +2 -0
- package/publications/files.js +71 -0
- package/publications/flags.d.ts +2 -0
- package/publications/flags.js +23 -0
- package/publications/logs.d.ts +2 -0
- package/publications/logs.js +26 -0
- package/publications/method-calls.d.ts +2 -0
- package/publications/method-calls.js +14 -0
- package/publications/method-responses.d.ts +2 -0
- package/publications/method-responses.js +14 -0
- package/publications/notifications.d.ts +2 -0
- package/publications/notifications.js +14 -0
- package/publications/super-admin.d.ts +2 -0
- package/publications/super-admin.js +21 -0
- package/publications/support-tickets.d.ts +1 -0
- package/publications/support-tickets.js +200 -0
- package/server-app.d.ts +35 -0
- package/server-app.js +638 -0
- package/support-methods/aws.d.ts +2 -0
- package/support-methods/aws.js +276 -0
- package/support-methods/collections.d.ts +2 -0
- package/support-methods/collections.js +471 -0
- package/support-methods/counters.d.ts +2 -0
- package/support-methods/counters.js +189 -0
- package/support-methods/support.d.ts +2 -0
- package/support-methods/support.js +236 -0
- package/util/common.d.ts +14 -0
- package/util/common.js +341 -0
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
$or: [
|
|
148
|
+
{ next_run: { $exists: false } },
|
|
149
|
+
{ next_run: null },
|
|
150
|
+
{ next_run: { $lte: now } }
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}, { $set: { running: true } }).exec(function (err, res) { return __awaiter(_this, void 0, void 0, function () {
|
|
155
|
+
var nextDate;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0:
|
|
159
|
+
if (!res) return [3 /*break*/, 9];
|
|
160
|
+
if (!cron.method_run_data) return [3 /*break*/, 2];
|
|
161
|
+
return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_run, cron.method_run_data)];
|
|
162
|
+
case 1:
|
|
163
|
+
_a.sent();
|
|
164
|
+
return [3 /*break*/, 4];
|
|
165
|
+
case 2: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_run)];
|
|
166
|
+
case 3:
|
|
167
|
+
_a.sent();
|
|
168
|
+
_a.label = 4;
|
|
169
|
+
case 4:
|
|
170
|
+
if (!cron.method_complete) return [3 /*break*/, 8];
|
|
171
|
+
if (!cron.method_complete_data) return [3 /*break*/, 6];
|
|
172
|
+
return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_complete, cron.method_complete_data)];
|
|
173
|
+
case 5:
|
|
174
|
+
_a.sent();
|
|
175
|
+
return [3 /*break*/, 8];
|
|
176
|
+
case 6: return [4 /*yield*/, this._mainServer.getMethodManager().callMethodCron(cron.method_complete)];
|
|
177
|
+
case 7:
|
|
178
|
+
_a.sent();
|
|
179
|
+
_a.label = 8;
|
|
180
|
+
case 8:
|
|
181
|
+
if (cron.repeat) {
|
|
182
|
+
nextDate = (this._cronManager.getJob(cron.name).nextDates().toDate()).setSeconds(0, 0);
|
|
183
|
+
cron_job_collection_1.CronJobs.updateOne({
|
|
184
|
+
$and: [
|
|
185
|
+
{ _id: cron._id },
|
|
186
|
+
{ running: true }
|
|
187
|
+
]
|
|
188
|
+
}, { $set: { running: false, next_run: nextDate } }).exec();
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
cron_job_collection_1.CronJobs.deleteOne({ _id: cron._id }).exec();
|
|
192
|
+
}
|
|
193
|
+
_a.label = 9;
|
|
194
|
+
case 9: return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); });
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
return CronManager;
|
|
201
|
+
}());
|
|
202
|
+
exports.CronManager = CronManager;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var DatabaseManager = /** @class */ (function () {
|
|
4
|
+
function DatabaseManager(mainServer) {
|
|
5
|
+
this._queue = [];
|
|
6
|
+
this._server = mainServer;
|
|
7
|
+
}
|
|
8
|
+
DatabaseManager.prototype.addDatabaseQueue = function () {
|
|
9
|
+
};
|
|
10
|
+
return DatabaseManager;
|
|
11
|
+
}());
|
|
12
|
+
exports.DatabaseManager = DatabaseManager;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MethodModel } from '../models/method.model';
|
|
2
|
+
import * as aws from 'aws-sdk';
|
|
3
|
+
import { QueueMethodModel } from '../models/queue-method.model';
|
|
4
|
+
import ResolveIOMainServer from '../server-app';
|
|
5
|
+
export declare class MethodManager {
|
|
6
|
+
private _mainServer;
|
|
7
|
+
_methods: MethodModel;
|
|
8
|
+
private _mailer;
|
|
9
|
+
private _imap;
|
|
10
|
+
private _aws;
|
|
11
|
+
private serverConfig;
|
|
12
|
+
private clientDir;
|
|
13
|
+
private _sendQueue;
|
|
14
|
+
private _runningQueue;
|
|
15
|
+
constructor(mainServer: any, serverConfig: any, clientDir: any);
|
|
16
|
+
getMainServer(): ResolveIOMainServer;
|
|
17
|
+
methods(method: MethodModel): void;
|
|
18
|
+
callMethodCron(method: string, ...methodData: any[]): void;
|
|
19
|
+
callMethodQueue(update: QueueMethodModel): Promise<unknown>;
|
|
20
|
+
callMethod(ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]): void;
|
|
21
|
+
callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
|
|
22
|
+
callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
|
|
23
|
+
private sendWS;
|
|
24
|
+
sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string): void;
|
|
25
|
+
getAWS(): aws.S3;
|
|
26
|
+
readFile(fileName: any): Promise<unknown>;
|
|
27
|
+
readImage(fileName: any): Promise<unknown>;
|
|
28
|
+
}
|