@resolveio/server-lib 3.2.10 → 3.2.11
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/package.json +26 -26
- package/collections/active-subscription.collection.d.ts +0 -7
- package/collections/active-subscription.collection.js +0 -68
- package/collections/app-status.collection.d.ts +0 -7
- package/collections/app-status.collection.js +0 -43
- package/collections/app-version.collection.d.ts +0 -7
- package/collections/app-version.collection.js +0 -56
- package/collections/billing-logged-in-users.collection.d.ts +0 -7
- package/collections/billing-logged-in-users.collection.js +0 -73
- package/collections/counter.collection.d.ts +0 -9
- package/collections/counter.collection.js +0 -73
- package/collections/cron-job-history.collection.d.ts +0 -7
- package/collections/cron-job-history.collection.js +0 -86
- package/collections/cron-job.collection.d.ts +0 -7
- package/collections/cron-job.collection.js +0 -89
- package/collections/file.collection.d.ts +0 -9
- package/collections/file.collection.js +0 -73
- package/collections/flag.collection.d.ts +0 -7
- package/collections/flag.collection.js +0 -47
- package/collections/log.collection.d.ts +0 -7
- package/collections/log.collection.js +0 -65
- package/collections/logged-in-users.collection.d.ts +0 -7
- package/collections/logged-in-users.collection.js +0 -70
- package/collections/method-call.collection.d.ts +0 -6
- package/collections/method-call.collection.js +0 -44
- package/collections/method-response.collection.d.ts +0 -6
- package/collections/method-response.collection.js +0 -48
- package/collections/notification.collection.d.ts +0 -7
- package/collections/notification.collection.js +0 -43
- package/collections/queue-flag.collection.d.ts +0 -7
- package/collections/queue-flag.collection.js +0 -41
- package/collections/queue-method.collection.d.ts +0 -7
- package/collections/queue-method.collection.js +0 -119
- package/collections/queue-response.collection.d.ts +0 -7
- package/collections/queue-response.collection.js +0 -74
- package/collections/support-ticket.collection.d.ts +0 -7
- package/collections/support-ticket.collection.js +0 -200
- package/collections/user.collection.d.ts +0 -9
- package/collections/user.collection.js +0 -153
- package/cron/cron.d.ts +0 -5
- package/cron/cron.js +0 -160
- package/fixtures/cron-jobs.d.ts +0 -1
- package/fixtures/cron-jobs.js +0 -90
- package/fixtures/init.d.ts +0 -1
- package/fixtures/init.js +0 -67
- package/http/auth.d.ts +0 -2
- package/http/auth.js +0 -468
- package/http/health.d.ts +0 -1
- package/http/health.js +0 -8
- package/index.d.ts +0 -16
- package/index.js +0 -125
- package/managers/cron.manager.d.ts +0 -16
- package/managers/cron.manager.js +0 -202
- package/managers/database.manager.d.ts +0 -6
- package/managers/database.manager.js +0 -12
- package/managers/method.manager.d.ts +0 -28
- package/managers/method.manager.js +0 -584
- package/managers/queue-method.manager.d.ts +0 -13
- package/managers/queue-method.manager.js +0 -240
- package/managers/subscription.manager.d.ts +0 -28
- package/managers/subscription.manager.js +0 -803
- package/managers/support.manager.d.ts +0 -22
- package/managers/support.manager.js +0 -320
- package/methods/accounts.d.ts +0 -2
- package/methods/accounts.js +0 -253
- package/methods/aws.d.ts +0 -2
- package/methods/aws.js +0 -387
- package/methods/cloudconvert.d.ts +0 -2
- package/methods/cloudconvert.js +0 -37
- package/methods/collections.d.ts +0 -2
- package/methods/collections.js +0 -750
- package/methods/counters.d.ts +0 -2
- package/methods/counters.js +0 -107
- package/methods/cron-jobs.d.ts +0 -2
- package/methods/cron-jobs.js +0 -132
- package/methods/flags.d.ts +0 -2
- package/methods/flags.js +0 -6
- package/methods/logs.d.ts +0 -2
- package/methods/logs.js +0 -29
- package/methods/pdf.d.ts +0 -2
- package/methods/pdf.js +0 -303
- package/models/active-subscription.model.d.ts +0 -13
- package/models/active-subscription.model.js +0 -2
- package/models/app-status.model.d.ts +0 -4
- package/models/app-status.model.js +0 -2
- package/models/app-version.model.d.ts +0 -4
- package/models/app-version.model.js +0 -2
- package/models/billing-logged-in-users.model.d.ts +0 -7
- package/models/billing-logged-in-users.model.js +0 -2
- package/models/collection-document.model.d.ts +0 -6
- package/models/collection-document.model.js +0 -2
- package/models/counter.model.d.ts +0 -5
- package/models/counter.model.js +0 -2
- package/models/cron-job-history.model.d.ts +0 -12
- package/models/cron-job-history.model.js +0 -2
- package/models/cron-job.model.d.ts +0 -13
- package/models/cron-job.model.js +0 -2
- package/models/dialog.model.d.ts +0 -23
- package/models/dialog.model.js +0 -2
- package/models/file.model.d.ts +0 -9
- package/models/file.model.js +0 -2
- package/models/flag.model.d.ts +0 -5
- package/models/flag.model.js +0 -2
- package/models/log.model.d.ts +0 -11
- package/models/log.model.js +0 -2
- package/models/logged-in-users.model.d.ts +0 -9
- package/models/logged-in-users.model.js +0 -2
- package/models/method-call.model.d.ts +0 -7
- package/models/method-call.model.js +0 -2
- package/models/method-response.model.d.ts +0 -8
- package/models/method-response.model.js +0 -2
- package/models/method.model.d.ts +0 -10
- package/models/method.model.js +0 -2
- package/models/notification.model.d.ts +0 -4
- package/models/notification.model.js +0 -2
- package/models/pagination.model.d.ts +0 -11
- package/models/pagination.model.js +0 -20
- package/models/permission.model.d.ts +0 -12
- package/models/permission.model.js +0 -2
- package/models/queue-method.model.d.ts +0 -10
- package/models/queue-method.model.js +0 -2
- package/models/queue-response.model.d.ts +0 -10
- package/models/queue-response.model.js +0 -2
- package/models/select-data-label.model.d.ts +0 -9
- package/models/select-data-label.model.js +0 -2
- package/models/server-response.model.d.ts +0 -5
- package/models/server-response.model.js +0 -2
- package/models/subscription.model.d.ts +0 -30
- package/models/subscription.model.js +0 -2
- package/models/support-method.model.d.ts +0 -9
- package/models/support-method.model.js +0 -2
- package/models/support-ticket.model.d.ts +0 -61
- package/models/support-ticket.model.js +0 -2
- package/models/user.model.d.ts +0 -14
- package/models/user.model.js +0 -2
- package/private/email-templates/enrollment.html +0 -12
- package/private/email-templates/forgot-password.html +0 -12
- package/private/email-templates/support-ticket-deleted.html +0 -40
- package/private/email-templates/support-ticket-modified.html +0 -71
- package/private/email-templates/support-ticket.html +0 -71
- package/private/images/ResolveIO.png +0 -0
- package/publications/app-status.d.ts +0 -2
- package/publications/app-status.js +0 -14
- package/publications/app-version.d.ts +0 -2
- package/publications/app-version.js +0 -14
- package/publications/billing-logged-in-users.d.ts +0 -1
- package/publications/billing-logged-in-users.js +0 -63
- package/publications/cron-jobs.d.ts +0 -2
- package/publications/cron-jobs.js +0 -14
- package/publications/files.d.ts +0 -2
- package/publications/files.js +0 -71
- package/publications/flags.d.ts +0 -2
- package/publications/flags.js +0 -23
- package/publications/logs.d.ts +0 -2
- package/publications/logs.js +0 -26
- package/publications/method-calls.d.ts +0 -2
- package/publications/method-calls.js +0 -14
- package/publications/method-responses.d.ts +0 -2
- package/publications/method-responses.js +0 -14
- package/publications/notifications.d.ts +0 -2
- package/publications/notifications.js +0 -14
- package/publications/super-admin.d.ts +0 -2
- package/publications/super-admin.js +0 -21
- package/publications/support-tickets.d.ts +0 -1
- package/publications/support-tickets.js +0 -200
- package/server-app.d.ts +0 -35
- package/server-app.js +0 -636
- package/support-methods/aws.d.ts +0 -2
- package/support-methods/aws.js +0 -276
- package/support-methods/collections.d.ts +0 -2
- package/support-methods/collections.js +0 -471
- package/support-methods/counters.d.ts +0 -2
- package/support-methods/counters.js +0 -189
- package/support-methods/support.d.ts +0 -2
- package/support-methods/support.js +0 -236
- package/util/common.d.ts +0 -14
- package/util/common.js +0 -341
package/methods/aws.js
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
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 index_1 = require("../index");
|
|
42
|
-
var request = require('request').defaults({ encoding: null });
|
|
43
|
-
var pdfCnt = 1000000;
|
|
44
|
-
function loadAWSMethods(methodManager) {
|
|
45
|
-
methodManager.methods({
|
|
46
|
-
uploadFileAndSave: {
|
|
47
|
-
skipQueue: true,
|
|
48
|
-
check: new simpl_schema_1.default({
|
|
49
|
-
fileName: {
|
|
50
|
-
type: String
|
|
51
|
-
},
|
|
52
|
-
fileData: {
|
|
53
|
-
type: String
|
|
54
|
-
},
|
|
55
|
-
fileSize: {
|
|
56
|
-
type: Number
|
|
57
|
-
},
|
|
58
|
-
fileOrder: {
|
|
59
|
-
type: Number
|
|
60
|
-
},
|
|
61
|
-
fileType: {
|
|
62
|
-
type: String
|
|
63
|
-
}
|
|
64
|
-
}),
|
|
65
|
-
function: function (fileName, fileData, fileSize, fileOrder, fileType) {
|
|
66
|
-
var that = this;
|
|
67
|
-
return new Promise(function (resolve, reject) {
|
|
68
|
-
if (fileName) {
|
|
69
|
-
var key_1 = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
70
|
-
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' };
|
|
71
|
-
that.getAWS().upload(newParams, function (err, res) {
|
|
72
|
-
if (err) {
|
|
73
|
-
reject(err);
|
|
74
|
-
}
|
|
75
|
-
else if (res) {
|
|
76
|
-
file_collection_1.Files.create({
|
|
77
|
-
_id: mongoose_1.Types.ObjectId().toHexString(), name: fileName, size: fileSize, key: key_1, order: fileOrder, type: fileType
|
|
78
|
-
}).then(function (resFile) {
|
|
79
|
-
resolve(resFile);
|
|
80
|
-
}, function (errFile) { return reject(errFile); });
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
deleteFiles: {
|
|
88
|
-
check: new simpl_schema_1.default({
|
|
89
|
-
keys: {
|
|
90
|
-
type: Array
|
|
91
|
-
},
|
|
92
|
-
'keys.$': {
|
|
93
|
-
type: String
|
|
94
|
-
}
|
|
95
|
-
}),
|
|
96
|
-
function: function (keys) {
|
|
97
|
-
var _this = this;
|
|
98
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
99
|
-
var files, deleteCnt;
|
|
100
|
-
var _this = this;
|
|
101
|
-
return __generator(this, function (_a) {
|
|
102
|
-
switch (_a.label) {
|
|
103
|
-
case 0: return [4 /*yield*/, file_collection_1.Files.find({ key: { $in: keys } })];
|
|
104
|
-
case 1:
|
|
105
|
-
files = _a.sent();
|
|
106
|
-
deleteCnt = files.length;
|
|
107
|
-
files.forEach(function (file) {
|
|
108
|
-
file_collection_1.Files.deleteOne({ _id: file._id }).exec();
|
|
109
|
-
var delParams = { Bucket: _this.serverConfig.AWSBUCKET, Key: file.key };
|
|
110
|
-
_this.getAWS().deleteObject(delParams, function (err, res) {
|
|
111
|
-
if (err) {
|
|
112
|
-
reject(err);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
deleteCnt--;
|
|
116
|
-
if (!deleteCnt) {
|
|
117
|
-
resolve(res);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
return [2 /*return*/];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}); });
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
deleteFile: {
|
|
129
|
-
check: new simpl_schema_1.default({
|
|
130
|
-
key: {
|
|
131
|
-
type: String
|
|
132
|
-
}
|
|
133
|
-
}),
|
|
134
|
-
function: function (key) {
|
|
135
|
-
var _this = this;
|
|
136
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
137
|
-
var file, delParams;
|
|
138
|
-
return __generator(this, function (_a) {
|
|
139
|
-
switch (_a.label) {
|
|
140
|
-
case 0: return [4 /*yield*/, file_collection_1.Files.findOne({ key: key })];
|
|
141
|
-
case 1:
|
|
142
|
-
file = _a.sent();
|
|
143
|
-
if (!file) {
|
|
144
|
-
reject('Could not find file');
|
|
145
|
-
}
|
|
146
|
-
file_collection_1.Files.deleteOne({ _id: file._id }).exec();
|
|
147
|
-
delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: key };
|
|
148
|
-
this.getAWS().deleteObject(delParams, function (err, res) {
|
|
149
|
-
if (err) {
|
|
150
|
-
reject(err);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
resolve(res);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
return [2 /*return*/];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}); });
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
deleteFileWithId: {
|
|
163
|
-
check: new simpl_schema_1.default({
|
|
164
|
-
id_file: {
|
|
165
|
-
type: String
|
|
166
|
-
}
|
|
167
|
-
}),
|
|
168
|
-
function: function (id_file) {
|
|
169
|
-
var _this = this;
|
|
170
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
171
|
-
var file, delParams;
|
|
172
|
-
return __generator(this, function (_a) {
|
|
173
|
-
switch (_a.label) {
|
|
174
|
-
case 0: return [4 /*yield*/, file_collection_1.Files.findOne({ _id: id_file })];
|
|
175
|
-
case 1:
|
|
176
|
-
file = _a.sent();
|
|
177
|
-
if (!file) {
|
|
178
|
-
reject('Could not find file');
|
|
179
|
-
}
|
|
180
|
-
delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: file.key };
|
|
181
|
-
this.getAWS().deleteObject(delParams, function (err, res) {
|
|
182
|
-
if (err) {
|
|
183
|
-
reject(err);
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
resolve(res);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
file_collection_1.Files.deleteOne({ _id: file._id }).exec();
|
|
190
|
-
return [2 /*return*/];
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}); });
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
getSignedUrlsAndFilesWithId: {
|
|
197
|
-
skipQueue: true,
|
|
198
|
-
check: new simpl_schema_1.default({
|
|
199
|
-
ids: {
|
|
200
|
-
type: Array
|
|
201
|
-
},
|
|
202
|
-
'ids.$': {
|
|
203
|
-
type: String
|
|
204
|
-
},
|
|
205
|
-
expires: {
|
|
206
|
-
type: Number
|
|
207
|
-
}
|
|
208
|
-
}),
|
|
209
|
-
function: function (ids, expires) {
|
|
210
|
-
var _this = this;
|
|
211
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
212
|
-
var res, fileArray, files;
|
|
213
|
-
var _this = this;
|
|
214
|
-
return __generator(this, function (_a) {
|
|
215
|
-
switch (_a.label) {
|
|
216
|
-
case 0:
|
|
217
|
-
res = [];
|
|
218
|
-
fileArray = [];
|
|
219
|
-
return [4 /*yield*/, file_collection_1.Files.find({ _id: { $in: ids } })];
|
|
220
|
-
case 1:
|
|
221
|
-
files = _a.sent();
|
|
222
|
-
files.forEach(function (file) {
|
|
223
|
-
var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
|
|
224
|
-
res.push(_this.getAWS().getSignedUrl('getObject', params));
|
|
225
|
-
});
|
|
226
|
-
resolve({ res: res, fileArray: files.map(function (a) { return a.name; }) });
|
|
227
|
-
return [2 /*return*/];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}); });
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
getSignedUrlWithId: {
|
|
234
|
-
skipQueue: true,
|
|
235
|
-
check: new simpl_schema_1.default({
|
|
236
|
-
id_file: {
|
|
237
|
-
type: String
|
|
238
|
-
},
|
|
239
|
-
expires: {
|
|
240
|
-
type: Number
|
|
241
|
-
}
|
|
242
|
-
}),
|
|
243
|
-
function: function (id_file, expires) {
|
|
244
|
-
var _this = this;
|
|
245
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
246
|
-
var file, params;
|
|
247
|
-
return __generator(this, function (_a) {
|
|
248
|
-
switch (_a.label) {
|
|
249
|
-
case 0: return [4 /*yield*/, file_collection_1.Files.findOne({ _id: id_file })];
|
|
250
|
-
case 1:
|
|
251
|
-
file = _a.sent();
|
|
252
|
-
params = { Bucket: this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
|
|
253
|
-
this.getAWS().getSignedUrl('getObject', params, function (err, res) {
|
|
254
|
-
if (err) {
|
|
255
|
-
reject(err);
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
resolve(res);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
return [2 /*return*/];
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}); });
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
getSignedUrl: {
|
|
268
|
-
skipQueue: true,
|
|
269
|
-
check: new simpl_schema_1.default({
|
|
270
|
-
key: {
|
|
271
|
-
type: String
|
|
272
|
-
},
|
|
273
|
-
expires: {
|
|
274
|
-
type: Number
|
|
275
|
-
}
|
|
276
|
-
}),
|
|
277
|
-
function: function (key, expires) {
|
|
278
|
-
var _this = this;
|
|
279
|
-
return new Promise(function (resolve, reject) {
|
|
280
|
-
var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
|
|
281
|
-
_this.getAWS().getSignedUrl('getObject', params, function (err, res) {
|
|
282
|
-
if (err) {
|
|
283
|
-
reject(err);
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
resolve(res);
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
getSignedUrls: {
|
|
293
|
-
skipQueue: true,
|
|
294
|
-
check: new simpl_schema_1.default({
|
|
295
|
-
keys: {
|
|
296
|
-
type: Array
|
|
297
|
-
},
|
|
298
|
-
'keys.$': {
|
|
299
|
-
type: String
|
|
300
|
-
},
|
|
301
|
-
expires: {
|
|
302
|
-
type: Number
|
|
303
|
-
}
|
|
304
|
-
}),
|
|
305
|
-
function: function (keys, expires) {
|
|
306
|
-
var _this = this;
|
|
307
|
-
return new Promise(function (resolve, reject) {
|
|
308
|
-
var res = [];
|
|
309
|
-
keys.forEach(function (key) {
|
|
310
|
-
var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
|
|
311
|
-
res.push(_this.getAWS().getSignedUrl('getObject', params));
|
|
312
|
-
});
|
|
313
|
-
resolve(res);
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
getDataURIfromURL: {
|
|
318
|
-
skipQueue: true,
|
|
319
|
-
check: new simpl_schema_1.default({
|
|
320
|
-
url: {
|
|
321
|
-
type: String
|
|
322
|
-
}
|
|
323
|
-
}),
|
|
324
|
-
function: function (url) {
|
|
325
|
-
return new Promise(function (resolve, reject) {
|
|
326
|
-
request.get(url, function (error, response, body) {
|
|
327
|
-
if (!error && response.statusCode === 200) {
|
|
328
|
-
var data = 'data:' + response.headers['content-type'] + ';base64,' + new Buffer(body).toString('base64');
|
|
329
|
-
resolve(data);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
reject(error);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
emailFile: {
|
|
339
|
-
skipQueue: true,
|
|
340
|
-
check: new simpl_schema_1.default({
|
|
341
|
-
id_file: {
|
|
342
|
-
type: String
|
|
343
|
-
},
|
|
344
|
-
email: {
|
|
345
|
-
type: String
|
|
346
|
-
}
|
|
347
|
-
}),
|
|
348
|
-
function: function (id_file, email) {
|
|
349
|
-
var _this = this;
|
|
350
|
-
var that = this;
|
|
351
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
352
|
-
var file;
|
|
353
|
-
return __generator(this, function (_a) {
|
|
354
|
-
switch (_a.label) {
|
|
355
|
-
case 0: return [4 /*yield*/, file_collection_1.Files.findById(id_file)];
|
|
356
|
-
case 1:
|
|
357
|
-
file = _a.sent();
|
|
358
|
-
if (!file) {
|
|
359
|
-
reject('Could not find file');
|
|
360
|
-
return [2 /*return*/];
|
|
361
|
-
}
|
|
362
|
-
that.callMethodInternal.call(that, 'getSignedUrl', file.key, 259200, function (errPDF, resPDF) {
|
|
363
|
-
if (resPDF) {
|
|
364
|
-
if (file.size < 5000000) {
|
|
365
|
-
that.sendEmail(email, index_1.ResolveIOServer.getClientName() + ' File - ' + file.name, 'Attached is the file requested for email.', '', [{
|
|
366
|
-
filename: file.name,
|
|
367
|
-
path: resPDF
|
|
368
|
-
}]);
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
that.sendEmail(email, index_1.ResolveIOServer.getClientName() + ' File - ' + file.name, 'Please click the link to the requested file. ' + resPDF, '');
|
|
372
|
-
}
|
|
373
|
-
resolve(true);
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
reject('Could not get file URL');
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
return [2 /*return*/];
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
}); });
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
exports.loadAWSMethods = loadAWSMethods;
|
package/methods/cloudconvert.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var request = require("request");
|
|
4
|
-
function loadCloudConvertMethods(methodManager) {
|
|
5
|
-
methodManager.methods({
|
|
6
|
-
getCCProcessURL: {
|
|
7
|
-
skipQueue: true,
|
|
8
|
-
function: function () {
|
|
9
|
-
var _this = this;
|
|
10
|
-
return new Promise(function (resolve, reject) {
|
|
11
|
-
request({
|
|
12
|
-
method: 'POST',
|
|
13
|
-
url: 'https://api.cloudconvert.com/process',
|
|
14
|
-
headers: {
|
|
15
|
-
'Content-Type': 'application/json; charset=UTF-8'
|
|
16
|
-
},
|
|
17
|
-
json: {
|
|
18
|
-
'apikey': _this.serverConfig['CLOUDCONVERT'],
|
|
19
|
-
'mode': 'combine',
|
|
20
|
-
'inputformat': 'pdf',
|
|
21
|
-
'outputformat': 'pdf'
|
|
22
|
-
}
|
|
23
|
-
}, (function (error, response, body) {
|
|
24
|
-
if (!error) {
|
|
25
|
-
resolve(body);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.log('Error happened: ' + error);
|
|
29
|
-
reject(error);
|
|
30
|
-
}
|
|
31
|
-
}));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
exports.loadCloudConvertMethods = loadCloudConvertMethods;
|
package/methods/collections.d.ts
DELETED