@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,276 @@
|
|
|
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 file_collection_1 = require("../collections/file.collection");
|
|
39
|
+
var mongoose_1 = require("mongoose");
|
|
40
|
+
var simpl_schema_1 = require("simpl-schema");
|
|
41
|
+
var pdfCnt = 1000000;
|
|
42
|
+
function loadAWSMethods(supportManager) {
|
|
43
|
+
supportManager.supportMethods({
|
|
44
|
+
uploadFileAndSave: {
|
|
45
|
+
check: new simpl_schema_1.default({
|
|
46
|
+
fileName: {
|
|
47
|
+
type: String
|
|
48
|
+
},
|
|
49
|
+
fileData: {
|
|
50
|
+
type: String
|
|
51
|
+
},
|
|
52
|
+
fileSize: {
|
|
53
|
+
type: Number
|
|
54
|
+
},
|
|
55
|
+
fileOrder: {
|
|
56
|
+
type: Number
|
|
57
|
+
},
|
|
58
|
+
fileType: {
|
|
59
|
+
type: String
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
function: function (fileName, fileData, fileSize, fileOrder, fileType) {
|
|
63
|
+
var that = this;
|
|
64
|
+
return new Promise(function (resolve, reject) {
|
|
65
|
+
if (fileName) {
|
|
66
|
+
var key_1 = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
67
|
+
var newParams = { Bucket: that.serverConfig.AWSBUCKET, Key: key_1, Body: Buffer.from(fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), 'base64'), ACL: 'private', ContentType: fileData.split(',')[0].split(':')[1].split(';')[0], ContentDisposition: 'inline' };
|
|
68
|
+
that.getAWS().upload(newParams, function (err, res) {
|
|
69
|
+
if (err) {
|
|
70
|
+
reject(err);
|
|
71
|
+
}
|
|
72
|
+
else if (res) {
|
|
73
|
+
file_collection_1.SupportFiles.create({
|
|
74
|
+
_id: mongoose_1.Types.ObjectId().toHexString(), name: fileName, size: fileSize, key: key_1, order: fileOrder, type: fileType
|
|
75
|
+
}).then(function (resFile) {
|
|
76
|
+
resolve(resFile);
|
|
77
|
+
}, function (errFile) { return reject(errFile); });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
deleteFiles: {
|
|
85
|
+
check: new simpl_schema_1.default({
|
|
86
|
+
keys: {
|
|
87
|
+
type: Array
|
|
88
|
+
},
|
|
89
|
+
'keys.$': {
|
|
90
|
+
type: String
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
function: function (keys) {
|
|
94
|
+
var _this = this;
|
|
95
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
+
var files, deleteCnt;
|
|
97
|
+
var _this = this;
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0: return [4 /*yield*/, file_collection_1.SupportFiles.find({ key: { $in: keys } })];
|
|
101
|
+
case 1:
|
|
102
|
+
files = _a.sent();
|
|
103
|
+
deleteCnt = files.length;
|
|
104
|
+
files.forEach(function (file) {
|
|
105
|
+
file_collection_1.SupportFiles.deleteOne({ _id: file._id }).exec();
|
|
106
|
+
var delParams = { Bucket: _this.serverConfig.AWSBUCKET, Key: file.key };
|
|
107
|
+
_this.getAWS().deleteObject(delParams, function (err, res) {
|
|
108
|
+
if (err) {
|
|
109
|
+
reject(err);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
deleteCnt--;
|
|
113
|
+
if (!deleteCnt) {
|
|
114
|
+
resolve(res);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return [2 /*return*/];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}); });
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
deleteFile: {
|
|
126
|
+
check: new simpl_schema_1.default({
|
|
127
|
+
key: {
|
|
128
|
+
type: String
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
function: function (key) {
|
|
132
|
+
var _this = this;
|
|
133
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
134
|
+
var file, delParams;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0: return [4 /*yield*/, file_collection_1.SupportFiles.findOne({ key: key })];
|
|
138
|
+
case 1:
|
|
139
|
+
file = _a.sent();
|
|
140
|
+
if (!file) {
|
|
141
|
+
reject('Could not find file');
|
|
142
|
+
}
|
|
143
|
+
file_collection_1.SupportFiles.deleteOne({ _id: file._id }).exec();
|
|
144
|
+
delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: key };
|
|
145
|
+
this.getAWS().deleteObject(delParams, function (err, res) {
|
|
146
|
+
if (err) {
|
|
147
|
+
reject(err);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
resolve(res);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return [2 /*return*/];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}); });
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
deleteFileWithId: {
|
|
160
|
+
check: new simpl_schema_1.default({
|
|
161
|
+
id_file: {
|
|
162
|
+
type: String
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
function: function (id_file) {
|
|
166
|
+
var _this = this;
|
|
167
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
168
|
+
var file, delParams;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0: return [4 /*yield*/, file_collection_1.SupportFiles.findOne({ _id: id_file })];
|
|
172
|
+
case 1:
|
|
173
|
+
file = _a.sent();
|
|
174
|
+
if (!file) {
|
|
175
|
+
reject('Could not find file');
|
|
176
|
+
}
|
|
177
|
+
delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: file.key };
|
|
178
|
+
this.getAWS().deleteObject(delParams, function (err, res) {
|
|
179
|
+
if (err) {
|
|
180
|
+
reject(err);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
resolve(res);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
file_collection_1.SupportFiles.deleteOne({ _id: file._id }).exec();
|
|
187
|
+
return [2 /*return*/];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}); });
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
getSignedUrlWithId: {
|
|
194
|
+
check: new simpl_schema_1.default({
|
|
195
|
+
id_file: {
|
|
196
|
+
type: String
|
|
197
|
+
},
|
|
198
|
+
expires: {
|
|
199
|
+
type: Number
|
|
200
|
+
}
|
|
201
|
+
}),
|
|
202
|
+
function: function (id_file, expires) {
|
|
203
|
+
var _this = this;
|
|
204
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
+
var file, params;
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
switch (_a.label) {
|
|
208
|
+
case 0: return [4 /*yield*/, file_collection_1.SupportFiles.findOne({ _id: id_file })];
|
|
209
|
+
case 1:
|
|
210
|
+
file = _a.sent();
|
|
211
|
+
params = { Bucket: this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
|
|
212
|
+
this.getAWS().getSignedUrl('getObject', params, function (err, res) {
|
|
213
|
+
if (err) {
|
|
214
|
+
reject(err);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
resolve(res);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}); });
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
getSignedUrl: {
|
|
227
|
+
check: new simpl_schema_1.default({
|
|
228
|
+
key: {
|
|
229
|
+
type: String
|
|
230
|
+
},
|
|
231
|
+
expires: {
|
|
232
|
+
type: Number
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
235
|
+
function: function (key, expires) {
|
|
236
|
+
var _this = this;
|
|
237
|
+
return new Promise(function (resolve, reject) {
|
|
238
|
+
var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
|
|
239
|
+
_this.getAWS().getSignedUrl('getObject', params, function (err, res) {
|
|
240
|
+
if (err) {
|
|
241
|
+
reject(err);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
resolve(res);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
getSignedUrls: {
|
|
251
|
+
check: new simpl_schema_1.default({
|
|
252
|
+
keys: {
|
|
253
|
+
type: Array
|
|
254
|
+
},
|
|
255
|
+
'keys.$': {
|
|
256
|
+
type: String
|
|
257
|
+
},
|
|
258
|
+
expires: {
|
|
259
|
+
type: Number
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
function: function (keys, expires) {
|
|
263
|
+
var _this = this;
|
|
264
|
+
return new Promise(function (resolve, reject) {
|
|
265
|
+
var res = [];
|
|
266
|
+
keys.forEach(function (key) {
|
|
267
|
+
var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
|
|
268
|
+
res.push(_this.getAWS().getSignedUrl('getObject', params));
|
|
269
|
+
});
|
|
270
|
+
resolve(res);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
exports.loadAWSMethods = loadAWSMethods;
|