@resolveio/server-lib 9.0.34 → 9.0.35
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 +48 -7
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +11 -8
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +11 -8
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +11 -8
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +12 -9
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +11 -8
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +11 -8
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +12 -9
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +11 -8
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +11 -8
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +14 -11
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +16 -13
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +19 -16
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +12 -9
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +13 -10
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +13 -10
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +16 -13
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +16 -13
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +18 -15
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +15 -12
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +15 -12
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +11 -8
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.js +12 -9
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.js +12 -9
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.js +12 -9
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +13 -10
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +14 -11
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +14 -11
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +14 -11
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +11 -8
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +15 -12
- 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 +80 -30
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +59 -9
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +460 -344
- package/http/auth.js.map +1 -1
- package/http/health.js +5 -1
- package/http/health.js.map +1 -1
- package/http/home.js +11 -7
- package/http/home.js.map +1 -1
- package/index.js +98 -36
- package/index.js.map +1 -1
- package/managers/cron.manager.js +157 -78
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +302 -314
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1001 -739
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +254 -171
- package/managers/monitor.manager.js.map +1 -1
- package/managers/queue-method.manager.js +166 -69
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +714 -515
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +183 -111
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +262 -156
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +180 -100
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +110 -103
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +79 -29
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +884 -819
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +5 -1
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +313 -258
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +348 -289
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +340 -341
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +657 -565
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +185 -67
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +2 -1
- package/models/app-version.model.js +2 -1
- package/models/billing-logged-in-users.model.js +2 -1
- package/models/collection-document.model.js +2 -1
- package/models/counter.model.js +2 -1
- package/models/cron-job-history.model.js +2 -1
- package/models/cron-job.model.js +2 -1
- package/models/dialog.model.js +2 -1
- package/models/email-history.model.js +2 -1
- package/models/email-verified.model.js +2 -1
- package/models/file.model.js +2 -1
- package/models/flag.model.js +2 -1
- package/models/log-method-latency.model.js +2 -1
- package/models/log-subscription.model.js +2 -1
- package/models/log.model.js +2 -1
- package/models/logged-in-users.model.js +2 -1
- package/models/method-call.model.js +2 -1
- package/models/method-response.model.js +2 -1
- package/models/method.model.js +2 -1
- package/models/monitor-cpu.model.js +2 -1
- package/models/monitor-https-inbound.model.js +2 -1
- package/models/monitor-https-outbound.model.js +2 -1
- package/models/monitor-memory.model.js +2 -1
- package/models/monitor-mongo.model.js +2 -1
- package/models/notification.model.js +2 -1
- package/models/pagination.model.js +5 -2
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +2 -1
- package/models/queue-method.model.js +2 -1
- package/models/queue-response.model.js +2 -1
- package/models/report-builder-dashboard-builder.model.js +2 -1
- package/models/report-builder-library.model.js +2 -1
- package/models/report-builder-report.model.js +2 -1
- package/models/report-builder.model.js +2 -1
- package/models/select-data-label.model.js +2 -1
- package/models/server-response.model.js +2 -1
- package/models/subscription.model.js +2 -1
- package/models/support-ticket.model.js +2 -1
- package/models/user-group.model.js +2 -1
- package/models/user-guide.model.js +2 -1
- package/models/user.model.js +2 -1
- package/package.json +1 -1
- package/public_api.js +82 -70
- package/public_api.js.map +1 -1
- package/publications/app-status.js +8 -4
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +8 -4
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +13 -9
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +15 -11
- package/publications/files.js.map +1 -1
- package/publications/flags.js +11 -7
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +35 -31
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +8 -4
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +8 -4
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +8 -4
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +12 -8
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +66 -16
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +21 -17
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +7 -3
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +8 -4
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +8 -4
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +534 -393
- package/server-app.js.map +1 -1
- package/util/common.js +92 -55
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +134 -76
- package/util/schema-report-builder.js.map +1 -1
package/methods/pdf.js
CHANGED
|
@@ -1,14 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
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.loadPDFMethods = void 0;
|
|
40
|
+
var fs = require('fs');
|
|
41
|
+
var bent = require("bent");
|
|
42
|
+
var simpl_schema_1 = require("simpl-schema");
|
|
43
|
+
var file_collection_1 = require("../collections/file.collection");
|
|
44
|
+
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
45
|
+
var pdfCnt = 0;
|
|
46
|
+
function loadPDFMethods(methodManager) {
|
|
8
47
|
methodManager.methods({
|
|
9
48
|
generatePDF: {
|
|
10
49
|
skipQueue: true,
|
|
11
|
-
check: new
|
|
50
|
+
check: new simpl_schema_1.default({
|
|
12
51
|
html: {
|
|
13
52
|
type: String
|
|
14
53
|
},
|
|
@@ -36,21 +75,26 @@ export function loadPDFMethods(methodManager) {
|
|
|
36
75
|
optional: true
|
|
37
76
|
}
|
|
38
77
|
}),
|
|
39
|
-
function: function (html, fileName, orientation
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
78
|
+
function: function (html, fileName, orientation, fontSize, upload, uploadFileOrder, uploadFileType) {
|
|
79
|
+
if (orientation === void 0) { orientation = 'portrait'; }
|
|
80
|
+
if (fontSize === void 0) { fontSize = '8px'; }
|
|
81
|
+
if (upload === void 0) { upload = false; }
|
|
82
|
+
if (uploadFileOrder === void 0) { uploadFileOrder = -1; }
|
|
83
|
+
if (uploadFileType === void 0) { uploadFileType = ''; }
|
|
84
|
+
var that = this;
|
|
85
|
+
return new Promise(function (resolve, reject) {
|
|
86
|
+
var phantom = require('phantom');
|
|
87
|
+
var phInstance = null;
|
|
88
|
+
phantom.create().then(function (instance) {
|
|
45
89
|
phInstance = instance;
|
|
46
90
|
return instance.createPage();
|
|
47
|
-
}).then(page
|
|
48
|
-
|
|
49
|
-
page.on('onResourceRequested', (requestData, networkRequest)
|
|
91
|
+
}).then(function (page) {
|
|
92
|
+
var requestsArray = [];
|
|
93
|
+
page.on('onResourceRequested', function (requestData, networkRequest) {
|
|
50
94
|
requestsArray.push(requestData.id);
|
|
51
95
|
});
|
|
52
|
-
page.on('onResourceReceived', (response)
|
|
53
|
-
|
|
96
|
+
page.on('onResourceReceived', function (response) {
|
|
97
|
+
var index = requestsArray.indexOf(response.id);
|
|
54
98
|
requestsArray.splice(index, 1);
|
|
55
99
|
});
|
|
56
100
|
page.property('paperSize', {
|
|
@@ -59,131 +103,30 @@ export function loadPDFMethods(methodManager) {
|
|
|
59
103
|
orientation: orientation,
|
|
60
104
|
footer: {
|
|
61
105
|
height: '1cm',
|
|
62
|
-
contents: phInstance.callback((pageNum, numPages)
|
|
106
|
+
contents: phInstance.callback(function (pageNum, numPages) {
|
|
63
107
|
return '<span style=\'float:right; font-size: 12px;\'>Page ' + pageNum + ' of ' + numPages + '</span>';
|
|
64
108
|
})
|
|
65
109
|
}
|
|
66
110
|
});
|
|
67
|
-
page.property('content',
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@font-face {
|
|
71
|
-
font-family: 'Dejavu Serif', serif;
|
|
72
|
-
font-style: normal;
|
|
73
|
-
font-weight: normal;
|
|
74
|
-
src: url("/usr/share/fonts/dejavu/DejaVuSerif.ttf");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@font-face {
|
|
78
|
-
font-family: 'Dejavu Serif', serif;
|
|
79
|
-
font-style: normal;
|
|
80
|
-
font-weight: bold;
|
|
81
|
-
src: url("/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@font-face {
|
|
85
|
-
font-family: 'Dejavu Serif', serif;
|
|
86
|
-
font-style: italic;
|
|
87
|
-
font-weight: normal;
|
|
88
|
-
src: url("/usr/share/fonts/dejavu/DejaVuSerif-Italic.ttf");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@font-face {
|
|
92
|
-
font-family: 'Dejavu Serif', serif;
|
|
93
|
-
font-style: italic;
|
|
94
|
-
font-weight: bold;
|
|
95
|
-
src: url("/usr/share/fonts/dejavu/DejaVuSerif-BoldItalic.ttf");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
body {
|
|
99
|
-
font-family: 'Dejavu Serif', serif;
|
|
100
|
-
font-size: ` + (fontSize ? fontSize : '8px') + `;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.row {
|
|
104
|
-
display: -webkit-flex;
|
|
105
|
-
display: flex;
|
|
106
|
-
flex-wrap: wrap;
|
|
107
|
-
-webkit-flex-wrap: wrap;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.page-break {
|
|
111
|
-
page-break-before: always !important;
|
|
112
|
-
margin-bottom: 1px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.cell {
|
|
116
|
-
box-sizing: border-box;
|
|
117
|
-
padding : 2px;
|
|
118
|
-
-webkit-flex: 1;
|
|
119
|
-
word-wrap: break-word;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.cell-no-padding {
|
|
123
|
-
box-sizing: border-box;
|
|
124
|
-
-webkit-flex: 1;
|
|
125
|
-
word-wrap: break-word;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.centered {
|
|
129
|
-
-webkit-justify-content: center;
|
|
130
|
-
-webkit-align-items: center;
|
|
131
|
-
display: -webkit-flex;
|
|
132
|
-
text-align: center;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.centered-left {
|
|
136
|
-
-webkit-align-items: center;
|
|
137
|
-
display: -webkit-flex;
|
|
138
|
-
-webkit-justify-content: flex-start;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.centered-right {
|
|
142
|
-
-webkit-justify-content: flex-end;
|
|
143
|
-
-webkit-align-items: center;
|
|
144
|
-
display: -webkit-flex;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.box {
|
|
148
|
-
border: 1px solid black;
|
|
149
|
-
margin: -1px 0px 0px -1px;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.boxNoBorder {
|
|
153
|
-
margin: -1px 0px 0px -1px;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
pre {
|
|
157
|
-
white-space: pre-wrap; /* css-3 */
|
|
158
|
-
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
|
159
|
-
white-space: -pre-wrap; /* Opera 4-6 */
|
|
160
|
-
white-space: -o-pre-wrap; /* Opera 7 */
|
|
161
|
-
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
|
162
|
-
font-size: 12px;
|
|
163
|
-
font-family: Open Sans;
|
|
164
|
-
}
|
|
165
|
-
</style>
|
|
166
|
-
</head>
|
|
167
|
-
<body>
|
|
168
|
-
` + html.replace(new RegExp('flex-basis:', 'g'), '-webkit-flex-basis:').replace(new RegExp('flex:', 'g'), '-webkit-flex:') + '</body>');
|
|
169
|
-
let tmpFileName = (pdfCnt++) + '-' + fileName.replace(new RegExp(/\W/g), '');
|
|
170
|
-
let interval = setInterval(() => {
|
|
111
|
+
page.property('content', "\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\"/usr/share/fonts/dejavu/DejaVuSerif.ttf\");\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-style: normal;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\"/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf\");\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: normal;\n\t\t\t\t\t\t\t\t\tsrc: url(\"/usr/share/fonts/dejavu/DejaVuSerif-Italic.ttf\");\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t@font-face {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-style: italic;\n\t\t\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t\t\t\tsrc: url(\"/usr/share/fonts/dejavu/DejaVuSerif-BoldItalic.ttf\");\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbody {\n\t\t\t\t\t\t\t\t\tfont-family: 'Dejavu Serif', serif;\n\t\t\t\t\t\t\t\t\tfont-size: " + (fontSize ? fontSize : '8px') + ";\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.row {\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\t\t\tflex-wrap: wrap;\n\t\t\t\t\t\t\t\t\t-webkit-flex-wrap: wrap;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.page-break {\n\t\t\t\t\t\t\t\t\tpage-break-before: always !important;\n\t\t\t\t\t\t\t\t\tmargin-bottom: 1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\tpadding : 2px;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.cell-no-padding {\n\t\t\t\t\t\t\t\t\tbox-sizing: border-box;\n\t\t\t\t\t\t\t\t\t-webkit-flex: 1;\n\t\t\t\t\t\t\t\t\tword-wrap: break-word;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: center;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-left {\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-start;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.centered-right {\n\t\t\t\t\t\t\t\t\t-webkit-justify-content: flex-end;\n\t\t\t\t\t\t\t\t\t-webkit-align-items: center;\n\t\t\t\t\t\t\t\t\tdisplay: -webkit-flex;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t.box {\n\t\t\t\t\t\t\t\t\tborder: 1px solid black;\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t.boxNoBorder {\n\t\t\t\t\t\t\t\t\tmargin: -1px 0px 0px -1px;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tpre {\n\t\t\t\t\t\t\t\t\twhite-space: pre-wrap; /* css-3 */\n\t\t\t\t\t\t\t\t\twhite-space: -moz-pre-wrap; /* Mozilla, since 1999 */\n\t\t\t\t\t\t\t\t\twhite-space: -pre-wrap; /* Opera 4-6 */\n\t\t\t\t\t\t\t\t\twhite-space: -o-pre-wrap; /* Opera 7 */\n\t\t\t\t\t\t\t\t\tword-wrap: break-word; /* Internet Explorer 5.5+ */\n\t\t\t\t\t\t\t\t\tfont-size: 12px;\n\t\t\t\t\t\t\t\t\tfont-family: Open Sans; \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t" + html.replace(new RegExp('flex-basis:', 'g'), '-webkit-flex-basis:').replace(new RegExp('flex:', 'g'), '-webkit-flex:') + '</body>');
|
|
112
|
+
var tmpFileName = (pdfCnt++) + '-' + fileName.replace(new RegExp(/\W/g), '');
|
|
113
|
+
var interval = setInterval(function () {
|
|
171
114
|
if (requestsArray.length === 0) {
|
|
172
115
|
clearInterval(interval);
|
|
173
116
|
page.render(tmpFileName, {
|
|
174
117
|
format: 'pdf',
|
|
175
118
|
quality: '100'
|
|
176
|
-
}).then(()
|
|
119
|
+
}).then(function () {
|
|
177
120
|
if (fs.existsSync(tmpFileName)) {
|
|
178
|
-
fs.readFile(tmpFileName, (errRead, data)
|
|
121
|
+
fs.readFile(tmpFileName, function (errRead, data) {
|
|
179
122
|
if (!errRead) {
|
|
180
123
|
fs.unlinkSync(tmpFileName);
|
|
181
124
|
if (!upload) {
|
|
182
125
|
resolve('data:application/pdf;base64,' + Buffer.from(data).toString('base64'));
|
|
183
126
|
}
|
|
184
127
|
else {
|
|
185
|
-
|
|
186
|
-
that.callMethodInternal.call(that, 'uploadFileAndSave', fileName, fileData, (4 * Math.ceil(fileData.length / 3)), uploadFileOrder, uploadFileType, false, (err, res)
|
|
128
|
+
var fileData = 'data:application/pdf;base64,' + Buffer.from(data).toString('base64');
|
|
129
|
+
that.callMethodInternal.call(that, 'uploadFileAndSave', fileName, fileData, (4 * Math.ceil(fileData.length / 3)), uploadFileOrder, uploadFileType, false, function (err, res) {
|
|
187
130
|
if (err) {
|
|
188
131
|
reject(err);
|
|
189
132
|
}
|
|
@@ -203,13 +146,13 @@ export function loadPDFMethods(methodManager) {
|
|
|
203
146
|
reject('No tmp file');
|
|
204
147
|
console.log('No tmp file ', tmpFileName);
|
|
205
148
|
}
|
|
206
|
-
}, err
|
|
149
|
+
}, function (err) {
|
|
207
150
|
console.log(err);
|
|
208
151
|
});
|
|
209
152
|
}
|
|
210
153
|
}, 1000);
|
|
211
154
|
})
|
|
212
|
-
.catch(error
|
|
155
|
+
.catch(function (error) {
|
|
213
156
|
reject(error);
|
|
214
157
|
phInstance.exit();
|
|
215
158
|
});
|
|
@@ -218,7 +161,7 @@ export function loadPDFMethods(methodManager) {
|
|
|
218
161
|
},
|
|
219
162
|
compressBase64AndUploadPDF: {
|
|
220
163
|
skipQueue: true,
|
|
221
|
-
check: new
|
|
164
|
+
check: new simpl_schema_1.default({
|
|
222
165
|
id_file: {
|
|
223
166
|
type: String
|
|
224
167
|
},
|
|
@@ -233,45 +176,58 @@ export function loadPDFMethods(methodManager) {
|
|
|
233
176
|
}
|
|
234
177
|
}),
|
|
235
178
|
function: function (id_file, fileName, filePath, fileContent) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
179
|
+
var _this = this;
|
|
180
|
+
return new Promise(function (resolve, reject) {
|
|
181
|
+
_this.callMethodInternal('getCCProcessURL').then(function (resCC) { return __awaiter(_this, void 0, void 0, function () {
|
|
182
|
+
var request, body, error_1;
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
switch (_a.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
request = bent('https:' + resCC.url, 'POST', 'json', 200);
|
|
187
|
+
_a.label = 1;
|
|
188
|
+
case 1:
|
|
189
|
+
_a.trys.push([1, 3, , 4]);
|
|
190
|
+
return [4 /*yield*/, request('', {
|
|
191
|
+
mode: 'compress',
|
|
192
|
+
input: 'base64',
|
|
193
|
+
file: fileContent,
|
|
194
|
+
filename: fileName,
|
|
195
|
+
outputformat: 'pdf',
|
|
196
|
+
wait: true,
|
|
197
|
+
output: {
|
|
198
|
+
's3': {
|
|
199
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
200
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
201
|
+
'region': this.serverConfig['AWSREGION'],
|
|
202
|
+
'bucket': this.serverConfig['AWSBUCKET'],
|
|
203
|
+
'path': filePath
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
})];
|
|
207
|
+
case 2:
|
|
208
|
+
body = _a.sent();
|
|
209
|
+
if (body.output.size) {
|
|
210
|
+
file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } });
|
|
211
|
+
resolve();
|
|
254
212
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
213
|
+
else {
|
|
214
|
+
reject('Compressed file has no size, compress failed');
|
|
215
|
+
}
|
|
216
|
+
return [3 /*break*/, 4];
|
|
217
|
+
case 3:
|
|
218
|
+
error_1 = _a.sent();
|
|
219
|
+
reject(error_1);
|
|
220
|
+
return [3 /*break*/, 4];
|
|
221
|
+
case 4: return [2 /*return*/];
|
|
263
222
|
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
reject(error);
|
|
267
|
-
}
|
|
268
|
-
}, errCC => reject(errCC));
|
|
223
|
+
});
|
|
224
|
+
}); }, function (errCC) { return reject(errCC); });
|
|
269
225
|
});
|
|
270
226
|
}
|
|
271
227
|
},
|
|
272
228
|
compressPDFOnS3: {
|
|
273
229
|
skipQueue: true,
|
|
274
|
-
check: new
|
|
230
|
+
check: new simpl_schema_1.default({
|
|
275
231
|
id_file: {
|
|
276
232
|
type: String
|
|
277
233
|
},
|
|
@@ -283,52 +239,65 @@ export function loadPDFMethods(methodManager) {
|
|
|
283
239
|
}
|
|
284
240
|
}),
|
|
285
241
|
function: function (id_file, fileName, filePath) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
'
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
242
|
+
var _this = this;
|
|
243
|
+
return new Promise(function (resolve, reject) {
|
|
244
|
+
_this.callMethodInternal('getCCProcessURL').then(function (resCC) { return __awaiter(_this, void 0, void 0, function () {
|
|
245
|
+
var request, body, error_2;
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
switch (_a.label) {
|
|
248
|
+
case 0:
|
|
249
|
+
request = bent('https:' + resCC.url, 'POST', 'json', 200);
|
|
250
|
+
_a.label = 1;
|
|
251
|
+
case 1:
|
|
252
|
+
_a.trys.push([1, 3, , 4]);
|
|
253
|
+
return [4 /*yield*/, request('', {
|
|
254
|
+
mode: 'compress',
|
|
255
|
+
input: {
|
|
256
|
+
's3': {
|
|
257
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
258
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
259
|
+
'region': this.serverConfig['AWSREGION'],
|
|
260
|
+
'bucket': this.serverConfig['AWSBUCKET']
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
file: filePath,
|
|
264
|
+
filename: fileName,
|
|
265
|
+
outputformat: 'pdf',
|
|
266
|
+
wait: true,
|
|
267
|
+
output: {
|
|
268
|
+
's3': {
|
|
269
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
270
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
271
|
+
'region': this.serverConfig['AWSREGION'],
|
|
272
|
+
'bucket': this.serverConfig['AWSBUCKET'],
|
|
273
|
+
'path': filePath
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
})];
|
|
277
|
+
case 2:
|
|
278
|
+
body = _a.sent();
|
|
279
|
+
if (body.output.size) {
|
|
280
|
+
file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } });
|
|
281
|
+
resolve();
|
|
298
282
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
filename: fileName,
|
|
302
|
-
outputformat: 'pdf',
|
|
303
|
-
wait: true,
|
|
304
|
-
output: {
|
|
305
|
-
's3': {
|
|
306
|
-
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
307
|
-
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
308
|
-
'region': this.serverConfig['AWSREGION'],
|
|
309
|
-
'bucket': this.serverConfig['AWSBUCKET'],
|
|
310
|
-
'path': filePath
|
|
283
|
+
else {
|
|
284
|
+
reject('Compressed file has no size, compress failed');
|
|
311
285
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
else {
|
|
319
|
-
reject('Compressed file has no size, compress failed');
|
|
286
|
+
return [3 /*break*/, 4];
|
|
287
|
+
case 3:
|
|
288
|
+
error_2 = _a.sent();
|
|
289
|
+
reject(error_2);
|
|
290
|
+
return [3 /*break*/, 4];
|
|
291
|
+
case 4: return [2 /*return*/];
|
|
320
292
|
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
reject(error);
|
|
324
|
-
}
|
|
325
|
-
}, errCC => reject(errCC));
|
|
293
|
+
});
|
|
294
|
+
}); }, function (errCC) { return reject(errCC); });
|
|
326
295
|
});
|
|
327
296
|
}
|
|
328
297
|
},
|
|
329
298
|
mergePDF: {
|
|
330
299
|
skipQueue: true,
|
|
331
|
-
check: new
|
|
300
|
+
check: new simpl_schema_1.default({
|
|
332
301
|
fileKeys: {
|
|
333
302
|
type: Array
|
|
334
303
|
},
|
|
@@ -344,20 +313,21 @@ export function loadPDFMethods(methodManager) {
|
|
|
344
313
|
}
|
|
345
314
|
}),
|
|
346
315
|
function: function (fileKeys, fileName, fileType) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
316
|
+
var _this = this;
|
|
317
|
+
return new Promise(function (resolve, reject) {
|
|
318
|
+
var mergeFileName = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
319
|
+
_this.callMethodInternal('createCloudConvertJob', fileKeys, ['merge', 'optimize'], mergeFileName, fileName).then(function (resCCJob) {
|
|
320
|
+
var resFile = {
|
|
321
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
352
322
|
__v: 0,
|
|
353
323
|
name: fileName,
|
|
354
|
-
size: resCCJob.data.tasks.filter(a
|
|
324
|
+
size: resCCJob.data.tasks.filter(function (a) { return a.name === 'task-2'; })[0].result.files[0].size,
|
|
355
325
|
key: mergeFileName,
|
|
356
326
|
type: fileType ? fileType : '',
|
|
357
327
|
order: -1
|
|
358
328
|
};
|
|
359
329
|
if (resFile.size) {
|
|
360
|
-
|
|
330
|
+
_this.callMethodInternal('insertDocument', 'files', resFile, function (errUpFile, resUpFile) {
|
|
361
331
|
if (resUpFile) {
|
|
362
332
|
resFile.status = 'Uploaded';
|
|
363
333
|
resolve(resFile);
|
|
@@ -370,13 +340,13 @@ export function loadPDFMethods(methodManager) {
|
|
|
370
340
|
else {
|
|
371
341
|
reject('Merged file has no size, merge failed');
|
|
372
342
|
}
|
|
373
|
-
}, ()
|
|
343
|
+
}, function () { });
|
|
374
344
|
});
|
|
375
345
|
}
|
|
376
346
|
},
|
|
377
347
|
mergePDFV1: {
|
|
378
348
|
skipQueue: true,
|
|
379
|
-
check: new
|
|
349
|
+
check: new simpl_schema_1.default({
|
|
380
350
|
fileKeys: {
|
|
381
351
|
type: Array
|
|
382
352
|
},
|
|
@@ -392,81 +362,95 @@ export function loadPDFMethods(methodManager) {
|
|
|
392
362
|
}
|
|
393
363
|
}),
|
|
394
364
|
function: function (fileKeys, fileName, fileType) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
365
|
+
var _this = this;
|
|
366
|
+
return new Promise(function (resolve, reject) {
|
|
367
|
+
_this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) { return __awaiter(_this, void 0, void 0, function () {
|
|
368
|
+
var mergeFileName, request, body, resFile_1, error_3;
|
|
369
|
+
var _this = this;
|
|
370
|
+
return __generator(this, function (_a) {
|
|
371
|
+
switch (_a.label) {
|
|
372
|
+
case 0:
|
|
373
|
+
mergeFileName = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
374
|
+
request = bent('https:' + resCC.url, 'POST', 'json', 200);
|
|
375
|
+
_a.label = 1;
|
|
376
|
+
case 1:
|
|
377
|
+
_a.trys.push([1, 3, , 4]);
|
|
378
|
+
return [4 /*yield*/, request('', {
|
|
379
|
+
mode: 'combine',
|
|
380
|
+
input: {
|
|
381
|
+
s3: {
|
|
382
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
383
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
384
|
+
'region': this.serverConfig['AWSREGION'],
|
|
385
|
+
'bucket': this.serverConfig['AWSBUCKET']
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
files: fileKeys,
|
|
389
|
+
outputformat: 'pdf',
|
|
390
|
+
wait: true,
|
|
391
|
+
output: {
|
|
392
|
+
's3': {
|
|
393
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
394
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
395
|
+
'region': this.serverConfig['AWSREGION'],
|
|
396
|
+
'bucket': this.serverConfig['AWSBUCKET'],
|
|
397
|
+
'path': mergeFileName
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
converteroptions: {
|
|
401
|
+
'resize': '612x792',
|
|
402
|
+
'resizemode': 'scale',
|
|
403
|
+
'resizeenlarge': null,
|
|
404
|
+
'grayscale': null,
|
|
405
|
+
'auto_orient': null,
|
|
406
|
+
'strip_metatags': false,
|
|
407
|
+
'density': 72,
|
|
408
|
+
'rotate': null,
|
|
409
|
+
'command': null
|
|
410
|
+
}
|
|
411
|
+
})];
|
|
412
|
+
case 2:
|
|
413
|
+
body = _a.sent();
|
|
414
|
+
resFile_1 = {
|
|
415
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
416
|
+
__v: 0,
|
|
417
|
+
name: fileName,
|
|
418
|
+
size: body.output.size,
|
|
419
|
+
key: mergeFileName,
|
|
420
|
+
type: fileType ? fileType : '',
|
|
421
|
+
order: -1
|
|
422
|
+
};
|
|
423
|
+
if (body.output.size) {
|
|
424
|
+
this.callMethodInternal('insertDocument', 'files', resFile_1, function (errUpFile, resUpFile) {
|
|
425
|
+
if (resUpFile) {
|
|
426
|
+
resFile_1.status = 'Uploaded';
|
|
427
|
+
_this.callMethodInternal('compressPDFOnS3', resFile_1._id, fileName, mergeFileName, function (errCompress, resCompress) {
|
|
428
|
+
resolve(resFile_1);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
reject(errUpFile);
|
|
433
|
+
}
|
|
449
434
|
});
|
|
450
435
|
}
|
|
451
436
|
else {
|
|
452
|
-
reject(
|
|
437
|
+
reject('Merged file has no size, merge failed');
|
|
453
438
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
439
|
+
return [3 /*break*/, 4];
|
|
440
|
+
case 3:
|
|
441
|
+
error_3 = _a.sent();
|
|
442
|
+
reject(error_3);
|
|
443
|
+
return [3 /*break*/, 4];
|
|
444
|
+
case 4: return [2 /*return*/];
|
|
458
445
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
reject(error);
|
|
462
|
-
}
|
|
463
|
-
}, errCC => reject(errCC));
|
|
446
|
+
});
|
|
447
|
+
}); }, function (errCC) { return reject(errCC); });
|
|
464
448
|
});
|
|
465
449
|
}
|
|
466
450
|
},
|
|
467
451
|
mergePDFNoUpload: {
|
|
468
452
|
skipQueue: true,
|
|
469
|
-
check: new
|
|
453
|
+
check: new simpl_schema_1.default({
|
|
470
454
|
fileKeys: {
|
|
471
455
|
type: Array
|
|
472
456
|
},
|
|
@@ -482,76 +466,91 @@ export function loadPDFMethods(methodManager) {
|
|
|
482
466
|
}
|
|
483
467
|
}),
|
|
484
468
|
function: function (fileKeys, fileName, fileType) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
469
|
+
var _this = this;
|
|
470
|
+
return new Promise(function (resolve, reject) {
|
|
471
|
+
_this.callMethodInternal('getCCProcessURL').then(function (resCC) { return __awaiter(_this, void 0, void 0, function () {
|
|
472
|
+
var mergeFileName, request, body, resFile_2, error_4;
|
|
473
|
+
var _this = this;
|
|
474
|
+
return __generator(this, function (_a) {
|
|
475
|
+
switch (_a.label) {
|
|
476
|
+
case 0:
|
|
477
|
+
mergeFileName = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
478
|
+
request = bent('https:' + resCC.url, 'POST', 'json', 200);
|
|
479
|
+
_a.label = 1;
|
|
480
|
+
case 1:
|
|
481
|
+
_a.trys.push([1, 3, , 4]);
|
|
482
|
+
return [4 /*yield*/, request('', {
|
|
483
|
+
mode: 'combine',
|
|
484
|
+
input: {
|
|
485
|
+
s3: {
|
|
486
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
487
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
488
|
+
'region': this.serverConfig['AWSREGION'],
|
|
489
|
+
'bucket': this.serverConfig['AWSBUCKET']
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
files: fileKeys,
|
|
493
|
+
outputformat: 'pdf',
|
|
494
|
+
wait: true,
|
|
495
|
+
output: {
|
|
496
|
+
's3': {
|
|
497
|
+
'accesskeyid': this.serverConfig['AWSACCESSKEYID'],
|
|
498
|
+
'secretaccesskey': this.serverConfig['AWSSECRETACCESSKEY'],
|
|
499
|
+
'region': this.serverConfig['AWSREGION'],
|
|
500
|
+
'bucket': this.serverConfig['AWSBUCKET'],
|
|
501
|
+
'path': mergeFileName
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
converteroptions: {
|
|
505
|
+
'resize': '612x792',
|
|
506
|
+
'resizemode': 'scale',
|
|
507
|
+
'resizeenlarge': null,
|
|
508
|
+
'grayscale': null,
|
|
509
|
+
'auto_orient': null,
|
|
510
|
+
'strip_metatags': false,
|
|
511
|
+
'density': 72,
|
|
512
|
+
'rotate': null,
|
|
513
|
+
'command': null
|
|
514
|
+
},
|
|
515
|
+
})];
|
|
516
|
+
case 2:
|
|
517
|
+
body = _a.sent();
|
|
518
|
+
resFile_2 = {
|
|
519
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
520
|
+
__v: 0,
|
|
521
|
+
name: fileName,
|
|
522
|
+
size: body.output.size,
|
|
523
|
+
key: mergeFileName,
|
|
524
|
+
type: fileType ? fileType : '',
|
|
525
|
+
order: -1
|
|
526
|
+
};
|
|
527
|
+
this.callMethodInternal('insertDocument', 'files', resFile_2, function (errUpFile, resUpFile) {
|
|
528
|
+
if (resUpFile) {
|
|
529
|
+
resFile_2.status = 'Uploaded';
|
|
530
|
+
resolve(resFile_2);
|
|
531
|
+
var that_1 = _this;
|
|
532
|
+
setTimeout(function () {
|
|
533
|
+
that_1.callMethodInternal.call(that_1, 'deleteFile', mergeFileName);
|
|
534
|
+
}, 60000);
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
reject(errUpFile);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
return [3 /*break*/, 4];
|
|
541
|
+
case 3:
|
|
542
|
+
error_4 = _a.sent();
|
|
543
|
+
reject(error_4);
|
|
544
|
+
return [3 /*break*/, 4];
|
|
545
|
+
case 4: return [2 /*return*/];
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}); }, function (errCC) { return reject(errCC); });
|
|
551
549
|
});
|
|
552
550
|
}
|
|
553
551
|
},
|
|
554
552
|
});
|
|
555
553
|
}
|
|
554
|
+
exports.loadPDFMethods = loadPDFMethods;
|
|
556
555
|
|
|
557
556
|
//# sourceMappingURL=pdf.js.map
|