@resolveio/server-lib 9.0.32 → 9.0.34
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/client-server-app.js +7 -48
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +8 -11
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +8 -11
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +8 -11
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +9 -12
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +8 -11
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +8 -11
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +9 -12
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +8 -11
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +8 -11
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +11 -14
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +13 -16
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +16 -19
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +9 -12
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +10 -13
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +10 -13
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +13 -16
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +13 -16
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +15 -18
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +12 -15
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +12 -15
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +8 -11
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.js +9 -12
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.js +9 -12
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.js +9 -12
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +10 -13
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +11 -14
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +11 -14
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +11 -14
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +8 -11
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +12 -15
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +25 -25
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +30 -80
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +9 -59
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +344 -460
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -5
- package/http/health.js.map +1 -1
- package/http/home.js +7 -11
- package/http/home.js.map +1 -1
- package/index.js +36 -98
- package/index.js.map +1 -1
- package/managers/cron.manager.js +78 -157
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +323 -303
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +14 -14
- package/managers/mongo.manager.js +794 -865
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +171 -254
- package/managers/monitor.manager.js.map +1 -1
- package/managers/queue-method.manager.js +69 -166
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +515 -708
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +111 -183
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +156 -262
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +100 -180
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +114 -530
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +29 -79
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +819 -884
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -5
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +258 -313
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +289 -348
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +341 -340
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +565 -657
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +67 -185
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -2
- package/models/app-version.model.js +1 -2
- package/models/billing-logged-in-users.model.js +1 -2
- package/models/collection-document.model.js +1 -2
- package/models/counter.model.js +1 -2
- package/models/cron-job-history.model.js +1 -2
- package/models/cron-job.model.js +1 -2
- package/models/dialog.model.js +1 -2
- package/models/email-history.model.js +1 -2
- package/models/email-verified.model.js +1 -2
- package/models/file.model.js +1 -2
- package/models/flag.model.js +1 -2
- package/models/log-method-latency.model.js +1 -2
- package/models/log-subscription.model.js +1 -2
- package/models/log.model.js +1 -2
- package/models/logged-in-users.model.js +1 -2
- package/models/method-call.model.js +1 -2
- package/models/method-response.model.js +1 -2
- package/models/method.model.js +1 -2
- package/models/monitor-cpu.model.js +1 -2
- package/models/monitor-https-inbound.model.js +1 -2
- package/models/monitor-https-outbound.model.js +1 -2
- package/models/monitor-memory.model.js +1 -2
- package/models/monitor-mongo.model.js +1 -2
- package/models/notification.model.js +1 -2
- package/models/pagination.model.js +2 -5
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -2
- package/models/queue-method.model.js +1 -2
- package/models/queue-response.model.js +1 -2
- package/models/report-builder-dashboard-builder.model.js +1 -2
- package/models/report-builder-library.model.js +1 -2
- package/models/report-builder-report.model.js +1 -2
- package/models/report-builder.model.js +1 -2
- package/models/select-data-label.model.js +1 -2
- package/models/server-response.model.js +1 -2
- package/models/subscription.model.js +1 -2
- package/models/support-ticket.model.js +1 -2
- package/models/user-group.model.js +1 -2
- package/models/user-guide.model.js +1 -2
- package/models/user.model.js +1 -2
- package/package.json +1 -1
- package/public_api.js +70 -82
- package/public_api.js.map +1 -1
- package/publications/app-status.js +4 -8
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +4 -8
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +9 -13
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +11 -15
- package/publications/files.js.map +1 -1
- package/publications/flags.js +7 -11
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +31 -35
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +4 -8
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +4 -8
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +4 -8
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +8 -12
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +16 -66
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +17 -21
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +3 -7
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +4 -8
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +4 -8
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +393 -534
- package/server-app.js.map +1 -1
- package/util/common.js +55 -92
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +76 -134
- package/util/schema-report-builder.js.map +1 -1
package/methods/aws.js
CHANGED
|
@@ -1,53 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.loadAWSMethods = void 0;
|
|
40
|
-
var file_collection_1 = require("../collections/file.collection");
|
|
41
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
42
|
-
var index_1 = require("../index");
|
|
43
|
-
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
44
|
-
var request = require('request').defaults({ encoding: null });
|
|
45
|
-
var pdfCnt = 1000000;
|
|
46
|
-
function loadAWSMethods(methodManager) {
|
|
1
|
+
import { Files } from '../collections/file.collection';
|
|
2
|
+
import SimpleSchema from 'simpl-schema';
|
|
3
|
+
import { ResolveIOServer } from '../index';
|
|
4
|
+
import { objectIdHexString } from '../managers/mongo.manager';
|
|
5
|
+
let request = require('request').defaults({ encoding: null });
|
|
6
|
+
let pdfCnt = 1000000;
|
|
7
|
+
export function loadAWSMethods(methodManager) {
|
|
47
8
|
methodManager.methods({
|
|
48
9
|
uploadFileAndSave: {
|
|
49
10
|
skipQueue: true,
|
|
50
|
-
check: new
|
|
11
|
+
check: new SimpleSchema({
|
|
51
12
|
fileName: {
|
|
52
13
|
type: String
|
|
53
14
|
},
|
|
@@ -68,54 +29,48 @@ function loadAWSMethods(methodManager) {
|
|
|
68
29
|
}
|
|
69
30
|
}),
|
|
70
31
|
function: function (fileName, fileData, fileSize, fileOrder, fileType, compress) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
file_collection_1.Files.create(file_1).then(function (resFile) {
|
|
90
|
-
_this.callMethodInternal('compressBase64AndUploadPDF', file_1._id, fileName, key_1, fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), function (errCompress, resCompress) {
|
|
91
|
-
resolve(resFile);
|
|
92
|
-
});
|
|
93
|
-
}, function (errFile) { return reject(errFile); });
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
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' };
|
|
97
|
-
that.getAWS().upload(newParams, function (err, res) {
|
|
98
|
-
if (err) {
|
|
99
|
-
reject(err);
|
|
100
|
-
}
|
|
101
|
-
else if (res) {
|
|
102
|
-
file_collection_1.Files.create({
|
|
103
|
-
_id: mongo_manager_1.objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key_1, order: fileOrder, type: fileType
|
|
104
|
-
}).then(function (resFile) {
|
|
105
|
-
resolve(resFile);
|
|
106
|
-
}, function (errFile) { return reject(errFile); });
|
|
107
|
-
}
|
|
32
|
+
let that = this;
|
|
33
|
+
return new Promise(async (resolve, reject) => {
|
|
34
|
+
if (fileName) {
|
|
35
|
+
let key = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
36
|
+
if (fileData.split(',')[0].split(':')[1].split(';')[0] === 'application/pdf' && compress) {
|
|
37
|
+
let file = {
|
|
38
|
+
_id: objectIdHexString(),
|
|
39
|
+
__v: 0,
|
|
40
|
+
name: fileName,
|
|
41
|
+
size: fileSize,
|
|
42
|
+
key: key,
|
|
43
|
+
order: fileOrder,
|
|
44
|
+
type: fileType
|
|
45
|
+
};
|
|
46
|
+
Files.create(file).then(resFile => {
|
|
47
|
+
this.callMethodInternal('compressBase64AndUploadPDF', file._id, fileName, key, fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), (errCompress, resCompress) => {
|
|
48
|
+
resolve(resFile);
|
|
108
49
|
});
|
|
109
|
-
}
|
|
50
|
+
}, errFile => reject(errFile));
|
|
110
51
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
52
|
+
else {
|
|
53
|
+
let newParams = { Bucket: that.serverConfig.AWSBUCKET, Key: key, 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' };
|
|
54
|
+
that.getAWS().upload(newParams, (err, res) => {
|
|
55
|
+
if (err) {
|
|
56
|
+
reject(err);
|
|
57
|
+
}
|
|
58
|
+
else if (res) {
|
|
59
|
+
Files.create({
|
|
60
|
+
_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType
|
|
61
|
+
}).then(resFile => {
|
|
62
|
+
resolve(resFile);
|
|
63
|
+
}, errFile => reject(errFile));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
114
69
|
}
|
|
115
70
|
},
|
|
116
71
|
uploadNonPDFFileAndSave: {
|
|
117
72
|
skipQueue: true,
|
|
118
|
-
check: new
|
|
73
|
+
check: new SimpleSchema({
|
|
119
74
|
fileName: {
|
|
120
75
|
type: String
|
|
121
76
|
},
|
|
@@ -133,21 +88,20 @@ function loadAWSMethods(methodManager) {
|
|
|
133
88
|
}
|
|
134
89
|
}),
|
|
135
90
|
function: function (fileName, fileData, fileSize, fileOrder, fileType) {
|
|
136
|
-
|
|
137
|
-
return new Promise(function (resolve, reject) {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
138
92
|
if (fileName) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
93
|
+
let key = 'uploads/' + Date.now() + '-' + fileName;
|
|
94
|
+
let newParams = { Bucket: this.serverConfig.AWSBUCKET, Key: key, Body: Buffer.from(fileData), ACL: 'private', ContentType: 'application/gzip', ContentDisposition: 'inline' };
|
|
95
|
+
this.getAWS().upload(newParams, (err, res) => {
|
|
142
96
|
if (err) {
|
|
143
97
|
reject(err);
|
|
144
98
|
}
|
|
145
99
|
else if (res) {
|
|
146
|
-
|
|
147
|
-
_id:
|
|
148
|
-
}).then(
|
|
100
|
+
Files.create({
|
|
101
|
+
_id: objectIdHexString(), __v: 0, name: fileName, size: fileSize, key: key, order: fileOrder, type: fileType
|
|
102
|
+
}).then(resFile => {
|
|
149
103
|
resolve(resFile);
|
|
150
|
-
},
|
|
104
|
+
}, errFile => reject(errFile));
|
|
151
105
|
}
|
|
152
106
|
});
|
|
153
107
|
}
|
|
@@ -156,7 +110,7 @@ function loadAWSMethods(methodManager) {
|
|
|
156
110
|
},
|
|
157
111
|
deleteFiles: {
|
|
158
112
|
skipQueue: true,
|
|
159
|
-
check: new
|
|
113
|
+
check: new SimpleSchema({
|
|
160
114
|
keys: {
|
|
161
115
|
type: Array
|
|
162
116
|
},
|
|
@@ -165,104 +119,76 @@ function loadAWSMethods(methodManager) {
|
|
|
165
119
|
}
|
|
166
120
|
}),
|
|
167
121
|
function: function (keys) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
else {
|
|
186
|
-
deleteCnt--;
|
|
187
|
-
if (!deleteCnt) {
|
|
188
|
-
resolve(res);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
return [2 /*return*/];
|
|
194
|
-
}
|
|
122
|
+
return new Promise(async (resolve, reject) => {
|
|
123
|
+
let files = await Files.find({ key: { $in: keys } });
|
|
124
|
+
let deleteCnt = files.length;
|
|
125
|
+
files.forEach(file => {
|
|
126
|
+
Files.deleteOne({ _id: file._id });
|
|
127
|
+
let delParams = { Bucket: this.serverConfig.AWSBUCKET, Key: file.key };
|
|
128
|
+
this.getAWS().deleteObject(delParams, (err, res) => {
|
|
129
|
+
if (err) {
|
|
130
|
+
reject(err);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
deleteCnt--;
|
|
134
|
+
if (!deleteCnt) {
|
|
135
|
+
resolve(res);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
195
139
|
});
|
|
196
|
-
});
|
|
140
|
+
});
|
|
197
141
|
}
|
|
198
142
|
},
|
|
199
143
|
deleteFile: {
|
|
200
144
|
skipQueue: true,
|
|
201
|
-
check: new
|
|
145
|
+
check: new SimpleSchema({
|
|
202
146
|
key: {
|
|
203
147
|
type: String
|
|
204
148
|
}
|
|
205
149
|
}),
|
|
206
150
|
function: function (key) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (file) {
|
|
216
|
-
file_collection_1.Files.deleteOne({ _id: file._id });
|
|
217
|
-
}
|
|
218
|
-
delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: key };
|
|
219
|
-
this.getAWS().deleteObject(delParams, function (err, res) {
|
|
220
|
-
resolve(res);
|
|
221
|
-
});
|
|
222
|
-
return [2 /*return*/];
|
|
223
|
-
}
|
|
151
|
+
return new Promise(async (resolve, reject) => {
|
|
152
|
+
let file = await Files.findOne({ key: key });
|
|
153
|
+
if (file) {
|
|
154
|
+
Files.deleteOne({ _id: file._id });
|
|
155
|
+
}
|
|
156
|
+
let delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: key };
|
|
157
|
+
this.getAWS().deleteObject(delParams, (err, res) => {
|
|
158
|
+
resolve(res);
|
|
224
159
|
});
|
|
225
|
-
});
|
|
160
|
+
});
|
|
226
161
|
}
|
|
227
162
|
},
|
|
228
163
|
deleteFileWithId: {
|
|
229
164
|
skipQueue: true,
|
|
230
|
-
check: new
|
|
165
|
+
check: new SimpleSchema({
|
|
231
166
|
id_file: {
|
|
232
167
|
type: String
|
|
233
168
|
}
|
|
234
169
|
}),
|
|
235
170
|
function: function (id_file) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
this.getAWS().deleteObject(delParams, function (err, res) {
|
|
249
|
-
if (err) {
|
|
250
|
-
reject(err);
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
resolve(res);
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
file_collection_1.Files.deleteOne({ _id: file._id });
|
|
257
|
-
return [2 /*return*/];
|
|
171
|
+
return new Promise(async (resolve, reject) => {
|
|
172
|
+
let file = await Files.findOne({ _id: id_file });
|
|
173
|
+
if (!file) {
|
|
174
|
+
reject('Could not find file');
|
|
175
|
+
}
|
|
176
|
+
let delParams = { Bucket: this.serverConfig['AWSBUCKET'], Key: file.key };
|
|
177
|
+
this.getAWS().deleteObject(delParams, (err, res) => {
|
|
178
|
+
if (err) {
|
|
179
|
+
reject(err);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
resolve(res);
|
|
258
183
|
}
|
|
259
184
|
});
|
|
260
|
-
|
|
185
|
+
Files.deleteOne({ _id: file._id });
|
|
186
|
+
});
|
|
261
187
|
}
|
|
262
188
|
},
|
|
263
189
|
getSignedUrlsAndFilesWithId: {
|
|
264
190
|
skipQueue: true,
|
|
265
|
-
check: new
|
|
191
|
+
check: new SimpleSchema({
|
|
266
192
|
ids: {
|
|
267
193
|
type: Array
|
|
268
194
|
},
|
|
@@ -274,32 +200,21 @@ function loadAWSMethods(methodManager) {
|
|
|
274
200
|
}
|
|
275
201
|
}),
|
|
276
202
|
function: function (ids, expires) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
res = [];
|
|
285
|
-
fileArray = [];
|
|
286
|
-
return [4 /*yield*/, file_collection_1.Files.find({ _id: { $in: ids } })];
|
|
287
|
-
case 1:
|
|
288
|
-
files = _a.sent();
|
|
289
|
-
files.forEach(function (file) {
|
|
290
|
-
var params = { Bucket: _this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
|
|
291
|
-
res.push(_this.getAWS().getSignedUrl('getObject', params));
|
|
292
|
-
});
|
|
293
|
-
resolve({ res: res, fileArray: files.map(function (a) { return a.name; }) });
|
|
294
|
-
return [2 /*return*/];
|
|
295
|
-
}
|
|
203
|
+
return new Promise(async (resolve, reject) => {
|
|
204
|
+
let res = [];
|
|
205
|
+
let fileArray = [];
|
|
206
|
+
let files = await Files.find({ _id: { $in: ids } });
|
|
207
|
+
files.forEach(file => {
|
|
208
|
+
let params = { Bucket: this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
|
|
209
|
+
res.push(this.getAWS().getSignedUrl('getObject', params));
|
|
296
210
|
});
|
|
297
|
-
|
|
211
|
+
resolve({ res: res, fileArray: files.map(a => a.name) });
|
|
212
|
+
});
|
|
298
213
|
}
|
|
299
214
|
},
|
|
300
215
|
getSignedUrlWithId: {
|
|
301
216
|
skipQueue: true,
|
|
302
|
-
check: new
|
|
217
|
+
check: new SimpleSchema({
|
|
303
218
|
id_file: {
|
|
304
219
|
type: String
|
|
305
220
|
},
|
|
@@ -308,32 +223,23 @@ function loadAWSMethods(methodManager) {
|
|
|
308
223
|
}
|
|
309
224
|
}),
|
|
310
225
|
function: function (id_file, expires) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
this.getAWS().getSignedUrl('getObject', params, function (err, res) {
|
|
321
|
-
if (err) {
|
|
322
|
-
reject(err);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
resolve(res);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
return [2 /*return*/];
|
|
226
|
+
return new Promise(async (resolve, reject) => {
|
|
227
|
+
let file = await Files.findOne({ _id: id_file });
|
|
228
|
+
let params = { Bucket: this.serverConfig.AWSBUCKET, Key: file.key, Expires: expires };
|
|
229
|
+
this.getAWS().getSignedUrl('getObject', params, (err, res) => {
|
|
230
|
+
if (err) {
|
|
231
|
+
reject(err);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
resolve(res);
|
|
329
235
|
}
|
|
330
236
|
});
|
|
331
|
-
});
|
|
237
|
+
});
|
|
332
238
|
}
|
|
333
239
|
},
|
|
334
240
|
getSignedUrl: {
|
|
335
241
|
skipQueue: true,
|
|
336
|
-
check: new
|
|
242
|
+
check: new SimpleSchema({
|
|
337
243
|
key: {
|
|
338
244
|
type: String
|
|
339
245
|
},
|
|
@@ -342,10 +248,9 @@ function loadAWSMethods(methodManager) {
|
|
|
342
248
|
}
|
|
343
249
|
}),
|
|
344
250
|
function: function (key, expires) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
_this.getAWS().getSignedUrl('getObject', params, function (err, res) {
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
let params = { Bucket: this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
|
|
253
|
+
this.getAWS().getSignedUrl('getObject', params, (err, res) => {
|
|
349
254
|
if (err) {
|
|
350
255
|
reject(err);
|
|
351
256
|
}
|
|
@@ -358,7 +263,7 @@ function loadAWSMethods(methodManager) {
|
|
|
358
263
|
},
|
|
359
264
|
getSignedUrls: {
|
|
360
265
|
skipQueue: true,
|
|
361
|
-
check: new
|
|
266
|
+
check: new SimpleSchema({
|
|
362
267
|
keys: {
|
|
363
268
|
type: Array
|
|
364
269
|
},
|
|
@@ -370,12 +275,11 @@ function loadAWSMethods(methodManager) {
|
|
|
370
275
|
}
|
|
371
276
|
}),
|
|
372
277
|
function: function (keys, expires) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
res.push(_this.getAWS().getSignedUrl('getObject', params));
|
|
278
|
+
return new Promise((resolve, reject) => {
|
|
279
|
+
let res = [];
|
|
280
|
+
keys.forEach(key => {
|
|
281
|
+
let params = { Bucket: this.serverConfig.AWSBUCKET, Key: key, Expires: expires };
|
|
282
|
+
res.push(this.getAWS().getSignedUrl('getObject', params));
|
|
379
283
|
});
|
|
380
284
|
resolve(res);
|
|
381
285
|
});
|
|
@@ -383,16 +287,16 @@ function loadAWSMethods(methodManager) {
|
|
|
383
287
|
},
|
|
384
288
|
getDataURIfromURL: {
|
|
385
289
|
skipQueue: true,
|
|
386
|
-
check: new
|
|
290
|
+
check: new SimpleSchema({
|
|
387
291
|
url: {
|
|
388
292
|
type: String
|
|
389
293
|
}
|
|
390
294
|
}),
|
|
391
295
|
function: function (url) {
|
|
392
|
-
return new Promise(
|
|
296
|
+
return new Promise((resolve, reject) => {
|
|
393
297
|
request.get(url, function (error, response, body) {
|
|
394
298
|
if (!error && response.statusCode === 200) {
|
|
395
|
-
|
|
299
|
+
let data = 'data:' + response.headers['content-type'] + ';base64,' + new Buffer(body).toString('base64');
|
|
396
300
|
resolve(data);
|
|
397
301
|
}
|
|
398
302
|
else {
|
|
@@ -404,7 +308,7 @@ function loadAWSMethods(methodManager) {
|
|
|
404
308
|
},
|
|
405
309
|
emailFile: {
|
|
406
310
|
skipQueue: true,
|
|
407
|
-
check: new
|
|
311
|
+
check: new SimpleSchema({
|
|
408
312
|
id_file: {
|
|
409
313
|
type: String
|
|
410
314
|
},
|
|
@@ -416,46 +320,36 @@ function loadAWSMethods(methodManager) {
|
|
|
416
320
|
}
|
|
417
321
|
}),
|
|
418
322
|
function: function (id_file, email, additional_message) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
that.sendEmail(email, index_1.ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage + resPDF, '');
|
|
444
|
-
}
|
|
445
|
-
resolve(true);
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
reject('Could not get file URL');
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
return [2 /*return*/];
|
|
323
|
+
let that = this;
|
|
324
|
+
return new Promise(async (resolve, reject) => {
|
|
325
|
+
let file = await Files.findById(id_file);
|
|
326
|
+
if (!file) {
|
|
327
|
+
reject('Could not find file');
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
that.callMethodInternal.call(that, 'getSignedUrl', file.key, 259200, (errPDF, resPDF) => {
|
|
331
|
+
if (resPDF) {
|
|
332
|
+
if (file.size < 5000000) {
|
|
333
|
+
let emailMessage = 'Attached is the file requested for email.\n' + (additional_message !== '' ? '\nAdditional Mesasge:\n' + additional_message + '\n' : '');
|
|
334
|
+
that.sendEmail(email, ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage, '', [{
|
|
335
|
+
filename: file.name,
|
|
336
|
+
path: resPDF
|
|
337
|
+
}]);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
let emailMessage = 'Please click the link to the requested file.\n' + (additional_message !== '' ? '\nAdditional Mesasge:\n' + additional_message + '\n' : '');
|
|
341
|
+
that.sendEmail(email, ResolveIOServer.getClientName() + ' File - ' + file.name, emailMessage + resPDF, '');
|
|
342
|
+
}
|
|
343
|
+
resolve(true);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
reject('Could not get file URL');
|
|
452
347
|
}
|
|
453
348
|
});
|
|
454
|
-
});
|
|
349
|
+
});
|
|
455
350
|
}
|
|
456
351
|
}
|
|
457
352
|
});
|
|
458
353
|
}
|
|
459
|
-
exports.loadAWSMethods = loadAWSMethods;
|
|
460
354
|
|
|
461
355
|
//# sourceMappingURL=aws.js.map
|