@resolveio/server-lib 9.2.18 → 9.2.19
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 +1 -55
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +1 -40
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +1 -40
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -43
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -71
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -74
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -55
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -50
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -62
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +1 -44
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -53
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -57
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +1 -72
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -58
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +1 -51
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -55
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -57
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +1 -66
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +1 -74
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -68
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -62
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -40
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -93
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -76
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -138
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -79
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -46
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -248
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +1 -161
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +1 -72
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +1 -62
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +1 -697
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -10
- package/http/health.js.map +1 -1
- package/http/home.js +1 -64
- package/http/home.js.map +1 -1
- package/index.js +1 -123
- package/index.js.map +1 -1
- package/managers/cron.manager.js +1 -205
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +1 -599
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1 -1682
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +1 -334
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -867
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +1 -100
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +1 -224
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +1 -449
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +1 -214
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +1 -526
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +1 -121
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1 -1284
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -8
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +1 -370
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +1 -384
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +1 -685
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +1 -826
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +1 -263
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -3
- package/models/app-status.model.js.map +1 -1
- package/models/app-version.model.js +1 -3
- package/models/app-version.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +1 -3
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +1 -3
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +1 -3
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +1 -3
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +1 -3
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +1 -3
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +1 -3
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +1 -3
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +1 -3
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +1 -3
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +1 -3
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +1 -3
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +1 -3
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +1 -3
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-call.model.js +1 -3
- package/models/method-call.model.js.map +1 -1
- package/models/method-response.model.js +1 -3
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +1 -3
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +1 -3
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-https-inbound.model.js +1 -3
- package/models/monitor-https-inbound.model.js.map +1 -1
- package/models/monitor-https-outbound.model.js +1 -3
- package/models/monitor-https-outbound.model.js.map +1 -1
- package/models/monitor-memory.model.js +1 -3
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +1 -3
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +1 -3
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +1 -23
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -3
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +1 -3
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +1 -3
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +1 -3
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +1 -3
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +1 -3
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +1 -3
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +1 -3
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +1 -3
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +1 -3
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +1 -3
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +1 -3
- package/models/user.model.js.map +1 -1
- package/package.json +2 -1
- package/public_api.js +1 -78
- package/public_api.js.map +1 -1
- package/publications/app-status.js +1 -16
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +1 -16
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +1 -32
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -36
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -22
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -90
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +1 -16
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +1 -16
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -16
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -42
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +1 -89
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -50
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -16
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -16
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -16
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +1 -682
- package/server-app.js.map +1 -1
- package/util/common.js +1 -498
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +1 -452
- package/util/schema-report-builder.js.map +1 -1
package/methods/cloudconvert.js
CHANGED
|
@@ -1,215 +1,2 @@
|
|
|
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.loadCloudConvertMethods = void 0;
|
|
40
|
-
var bent = require("bent");
|
|
41
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
42
|
-
function loadCloudConvertMethods(methodManager) {
|
|
43
|
-
methodManager.methods({
|
|
44
|
-
getCCProcessURL: {
|
|
45
|
-
function: function () {
|
|
46
|
-
var _this = this;
|
|
47
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
48
|
-
var request, body, error_1;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
request = bent('https://api.cloudconvert.com', 'POST', 'json', 200);
|
|
53
|
-
_a.label = 1;
|
|
54
|
-
case 1:
|
|
55
|
-
_a.trys.push([1, 3, , 4]);
|
|
56
|
-
return [4 /*yield*/, request('/process', {
|
|
57
|
-
'apikey': this.serverConfig['CLOUDCONVERT'],
|
|
58
|
-
'mode': 'combine',
|
|
59
|
-
'inputformat': 'pdf',
|
|
60
|
-
'outputformat': 'pdf'
|
|
61
|
-
})];
|
|
62
|
-
case 2:
|
|
63
|
-
body = _a.sent();
|
|
64
|
-
resolve(body);
|
|
65
|
-
return [3 /*break*/, 4];
|
|
66
|
-
case 3:
|
|
67
|
-
error_1 = _a.sent();
|
|
68
|
-
console.log('Error happened: ' + error_1);
|
|
69
|
-
reject(error_1);
|
|
70
|
-
return [3 /*break*/, 4];
|
|
71
|
-
case 4: return [2 /*return*/];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}); });
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
createCloudConvertJob: {
|
|
78
|
-
check: new simpl_schema_1.default({
|
|
79
|
-
file_input_keys: {
|
|
80
|
-
type: Array
|
|
81
|
-
},
|
|
82
|
-
'file_input_keys.$': {
|
|
83
|
-
type: String
|
|
84
|
-
},
|
|
85
|
-
tasks: {
|
|
86
|
-
type: Array
|
|
87
|
-
},
|
|
88
|
-
'tasks.$': {
|
|
89
|
-
type: String
|
|
90
|
-
},
|
|
91
|
-
file_output_key: {
|
|
92
|
-
type: String
|
|
93
|
-
},
|
|
94
|
-
file_name: {
|
|
95
|
-
type: String
|
|
96
|
-
}
|
|
97
|
-
}),
|
|
98
|
-
function: function (file_input_keys, tasks, file_output_key, file_name) {
|
|
99
|
-
var _this = this;
|
|
100
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
101
|
-
var cloudJob, jobImports, jobConverts, jobTasks, request, jobBody, body, requestWait_1, running_1, interval_1, error_2;
|
|
102
|
-
var _this = this;
|
|
103
|
-
return __generator(this, function (_a) {
|
|
104
|
-
switch (_a.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
cloudJob = {};
|
|
107
|
-
jobImports = [];
|
|
108
|
-
file_input_keys.forEach(function (key, keyIdx) {
|
|
109
|
-
cloudJob['import-' + (keyIdx + 1)] = {
|
|
110
|
-
operation: 'import/s3',
|
|
111
|
-
bucket: _this.serverConfig['AWSBUCKET'],
|
|
112
|
-
region: _this.serverConfig['AWSREGION'],
|
|
113
|
-
access_key_id: _this.serverConfig['AWSACCESSKEYID'],
|
|
114
|
-
secret_access_key: _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
115
|
-
key: key
|
|
116
|
-
};
|
|
117
|
-
jobImports.push('import-' + (keyIdx + 1));
|
|
118
|
-
});
|
|
119
|
-
jobConverts = [];
|
|
120
|
-
jobImports.forEach(function (key, keyIdx) {
|
|
121
|
-
cloudJob['convert-' + (keyIdx + 1)] = {
|
|
122
|
-
operation: 'convert',
|
|
123
|
-
input: key,
|
|
124
|
-
output_format: "pdf",
|
|
125
|
-
width: 612,
|
|
126
|
-
height: 792,
|
|
127
|
-
fit: 'scale',
|
|
128
|
-
auto_orient: true
|
|
129
|
-
};
|
|
130
|
-
jobConverts.push('convert-' + (keyIdx + 1));
|
|
131
|
-
});
|
|
132
|
-
jobTasks = [];
|
|
133
|
-
tasks.forEach(function (task, taskIdx) {
|
|
134
|
-
cloudJob['task-' + (taskIdx + 1)] = {
|
|
135
|
-
operation: task,
|
|
136
|
-
output_format: 'pdf',
|
|
137
|
-
input: taskIdx === 0 ? jobConverts : 'task-' + taskIdx,
|
|
138
|
-
filename: file_name
|
|
139
|
-
};
|
|
140
|
-
jobTasks.push('task-' + (taskIdx + 1));
|
|
141
|
-
});
|
|
142
|
-
cloudJob['export-1'] = {
|
|
143
|
-
operation: 'export/s3',
|
|
144
|
-
input: jobTasks[jobTasks.length - 1],
|
|
145
|
-
bucket: this.serverConfig['AWSBUCKET'],
|
|
146
|
-
region: this.serverConfig['AWSREGION'],
|
|
147
|
-
access_key_id: this.serverConfig['AWSACCESSKEYID'],
|
|
148
|
-
secret_access_key: this.serverConfig['AWSSECRETACCESSKEY'],
|
|
149
|
-
key: file_output_key
|
|
150
|
-
};
|
|
151
|
-
request = bent('https://api.cloudconvert.com/v2', 'POST', 'json', 201);
|
|
152
|
-
_a.label = 1;
|
|
153
|
-
case 1:
|
|
154
|
-
_a.trys.push([1, 3, , 4]);
|
|
155
|
-
return [4 /*yield*/, request('/jobs', {
|
|
156
|
-
tasks: cloudJob
|
|
157
|
-
}, {
|
|
158
|
-
'Authorization': 'Bearer ' + this.serverConfig['CLOUDCONVERT_V2']
|
|
159
|
-
})];
|
|
160
|
-
case 2:
|
|
161
|
-
jobBody = _a.sent();
|
|
162
|
-
body = typeof jobBody === 'string' ? JSON.parse(jobBody) : jobBody;
|
|
163
|
-
if (body && body.data && body.data.links) {
|
|
164
|
-
requestWait_1 = bent(body.data.links.self, 'GET', 'json', 200);
|
|
165
|
-
running_1 = false;
|
|
166
|
-
interval_1 = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
167
|
-
var bodyWait, responseBody, errorWait_1;
|
|
168
|
-
return __generator(this, function (_a) {
|
|
169
|
-
switch (_a.label) {
|
|
170
|
-
case 0:
|
|
171
|
-
if (!!running_1) return [3 /*break*/, 5];
|
|
172
|
-
running_1 = true;
|
|
173
|
-
_a.label = 1;
|
|
174
|
-
case 1:
|
|
175
|
-
_a.trys.push([1, 3, , 4]);
|
|
176
|
-
return [4 /*yield*/, requestWait_1('', null, {
|
|
177
|
-
'Authorization': 'Bearer ' + this.serverConfig['CLOUDCONVERT_V2']
|
|
178
|
-
})];
|
|
179
|
-
case 2:
|
|
180
|
-
bodyWait = _a.sent();
|
|
181
|
-
responseBody = typeof bodyWait === 'string' ? JSON.parse(bodyWait) : bodyWait;
|
|
182
|
-
if (responseBody.data.status === 'finished') {
|
|
183
|
-
clearInterval(interval_1);
|
|
184
|
-
resolve(responseBody);
|
|
185
|
-
}
|
|
186
|
-
return [3 /*break*/, 4];
|
|
187
|
-
case 3:
|
|
188
|
-
errorWait_1 = _a.sent();
|
|
189
|
-
console.log('Error happened wait :', JSON.stringify(errorWait_1, null, 2));
|
|
190
|
-
return [3 /*break*/, 4];
|
|
191
|
-
case 4:
|
|
192
|
-
running_1 = false;
|
|
193
|
-
_a.label = 5;
|
|
194
|
-
case 5: return [2 /*return*/];
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}); }, 1000);
|
|
198
|
-
}
|
|
199
|
-
return [3 /*break*/, 4];
|
|
200
|
-
case 3:
|
|
201
|
-
error_2 = _a.sent();
|
|
202
|
-
console.log('Error happened: ', JSON.stringify(error_2, null, 2));
|
|
203
|
-
reject(error_2);
|
|
204
|
-
return [3 /*break*/, 4];
|
|
205
|
-
case 4: return [2 /*return*/];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}); });
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
exports.loadCloudConvertMethods = loadCloudConvertMethods;
|
|
214
|
-
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n.throw(e))}catch(e){i(e)}}function step(e){e.done?o(e.value):function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(i){return function(a){return function step(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadCloudConvertMethods=void 0;var bent=require("bent"),simpl_schema_1=require("simpl-schema");function loadCloudConvertMethods(e){e.methods({getCCProcessURL:{function:function(){var e=this;return new Promise((function(t,r){return __awaiter(e,void 0,void 0,(function(){var e,n,o;return __generator(this,(function(i){switch(i.label){case 0:e=bent("https://api.cloudconvert.com","POST","json",200),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e("/process",{apikey:this.serverConfig.CLOUDCONVERT,mode:"combine",inputformat:"pdf",outputformat:"pdf"})];case 2:return n=i.sent(),t(n),[3,4];case 3:return o=i.sent(),console.log("Error happened: "+o),r(o),[3,4];case 4:return[2]}}))}))}))}},createCloudConvertJob:{check:new simpl_schema_1.default({file_input_keys:{type:Array},"file_input_keys.$":{type:String},tasks:{type:Array},"tasks.$":{type:String},file_output_key:{type:String},file_name:{type:String}}),function:function(e,t,r,n){var o=this;return new Promise((function(i,s){return __awaiter(o,void 0,void 0,(function(){var o,a,u,c,l,f,p,h,d,v,_,C=this;return __generator(this,(function(y){switch(y.label){case 0:o={},a=[],e.forEach((function(e,t){o["import-"+(t+1)]={operation:"import/s3",bucket:C.serverConfig.AWSBUCKET,region:C.serverConfig.AWSREGION,access_key_id:C.serverConfig.AWSACCESSKEYID,secret_access_key:C.serverConfig.AWSSECRETACCESSKEY,key:e},a.push("import-"+(t+1))})),u=[],a.forEach((function(e,t){o["convert-"+(t+1)]={operation:"convert",input:e,output_format:"pdf",width:612,height:792,fit:"scale",auto_orient:!0},u.push("convert-"+(t+1))})),c=[],t.forEach((function(e,t){o["task-"+(t+1)]={operation:e,output_format:"pdf",input:0===t?u:"task-"+t,filename:n},c.push("task-"+(t+1))})),o["export-1"]={operation:"export/s3",input:c[c.length-1],bucket:this.serverConfig.AWSBUCKET,region:this.serverConfig.AWSREGION,access_key_id:this.serverConfig.AWSACCESSKEYID,secret_access_key:this.serverConfig.AWSSECRETACCESSKEY,key:r},l=bent("https://api.cloudconvert.com/v2","POST","json",201),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,l("/jobs",{tasks:o},{Authorization:"Bearer "+this.serverConfig.CLOUDCONVERT_V2})];case 2:return f=y.sent(),(p="string"==typeof f?JSON.parse(f):f)&&p.data&&p.data.links&&(h=bent(p.data.links.self,"GET","json",200),d=!1,v=setInterval((function(){return __awaiter(C,void 0,void 0,(function(){var e,t,r;return __generator(this,(function(n){switch(n.label){case 0:if(d)return[3,5];d=!0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,h("",null,{Authorization:"Bearer "+this.serverConfig.CLOUDCONVERT_V2})];case 2:return e=n.sent(),"finished"===(t="string"==typeof e?JSON.parse(e):e).data.status&&(clearInterval(v),i(t)),[3,4];case 3:return r=n.sent(),console.log("Error happened wait :",JSON.stringify(r,null,2)),[3,4];case 4:d=!1,n.label=5;case 5:return[2]}}))}))}),1e3)),[3,4];case 3:return _=y.sent(),console.log("Error happened: ",JSON.stringify(_,null,2)),s(_),[3,4];case 4:return[2]}}))}))}))}}})}exports.loadCloudConvertMethods=loadCloudConvertMethods;
|
|
215
2
|
//# sourceMappingURL=cloudconvert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/cloudconvert.ts"],"names":[
|
|
1
|
+
{"version":3,"sources":["../../src/methods/cloudconvert.ts"],"names":["bent","require","simpl_schema_1","loadCloudConvertMethods","methodManager","methods","getCCProcessURL","function","_this","this","Promise","resolve","reject","__awaiter","request","apikey","serverConfig","mode","inputformat","outputformat","body","_a","sent","console","log","error_1","createCloudConvertJob","check","default","file_input_keys","type","Array","file_input_keys.$","String","tasks","tasks.$","file_output_key","file_name","cloudJob","jobImports","forEach","key","keyIdx","operation","bucket","region","access_key_id","secret_access_key","push","jobConverts","input","output_format","width","height","fit","auto_orient","jobTasks","task","taskIdx","filename","length","Authorization","jobBody","JSON","parse","data","links","requestWait_1","self","running_1","interval_1","setInterval","bodyWait","responseBody","status","clearInterval","stringify","errorWait_1","error_2","exports"],"mappings":"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","file":"cloudconvert.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport * as bent from 'bent';\nimport SimpleSchema from 'simpl-schema';\n\nexport function loadCloudConvertMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tgetCCProcessURL: {\n\t\t\tfunction: function() {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tconst request = bent('https://api.cloudconvert.com', 'POST', 'json', 200);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet body = await request('/process', {\n\t\t\t\t\t\t\t'apikey': this.serverConfig['CLOUDCONVERT'],\n\t\t\t\t\t\t\t'mode': 'combine',\n\t\t\t\t\t\t\t'inputformat': 'pdf',\n\t\t\t\t\t\t\t'outputformat': 'pdf'\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tresolve(body);\n\t\t\t\t\t}\n\t\t\t\t\tcatch(error) {\n\t\t\t\t\t\tconsole.log('Error happened: ' + error);\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateCloudConvertJob: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tfile_input_keys: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'file_input_keys.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\ttasks: {\n\t\t\t\t\ttype: Array\n\t\t\t\t},\n\t\t\t\t'tasks.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfile_output_key: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tfile_name: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(file_input_keys: string[], tasks: string[], file_output_key: string, file_name: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet cloudJob = {};\n\t\t\t\t\tlet jobImports = [];\n\n\t\t\t\t\tfile_input_keys.forEach((key, keyIdx) => {\n\t\t\t\t\t\tcloudJob['import-' + (keyIdx + 1)] = {\n\t\t\t\t\t\t\toperation: 'import/s3',\n\t\t\t\t\t\t\tbucket: this.serverConfig['AWSBUCKET'],\n\t\t\t\t\t\t\tregion: this.serverConfig['AWSREGION'],\n\t\t\t\t\t\t\taccess_key_id: this.serverConfig['AWSACCESSKEYID'],\n\t\t\t\t\t\t\tsecret_access_key: this.serverConfig['AWSSECRETACCESSKEY'],\n\t\t\t\t\t\t\tkey: key\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tjobImports.push('import-' + (keyIdx + 1));\n\t\t\t\t\t});\n\n\t\t\t\t\tlet jobConverts = [];\n\n\t\t\t\t\tjobImports.forEach((key, keyIdx) => {\n\t\t\t\t\t\tcloudJob['convert-' + (keyIdx + 1)] = {\n\t\t\t\t\t\t\toperation: 'convert',\n\t\t\t\t\t\t\tinput: key,\n\t\t\t\t\t\t\toutput_format: \"pdf\",\n\t\t\t\t\t\t\twidth: 612,\n\t\t\t\t\t\t\theight: 792,\n\t\t\t\t\t\t\tfit: 'scale',\n\t\t\t\t\t\t\tauto_orient: true\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tjobConverts.push('convert-' + (keyIdx + 1));\n\t\t\t\t\t});\n\n\t\t\t\t\tlet jobTasks = [];\n\n\t\t\t\t\ttasks.forEach((task, taskIdx) => {\n\t\t\t\t\t\tcloudJob['task-' + (taskIdx + 1)] = {\n\t\t\t\t\t\t\toperation: task,\n\t\t\t\t\t\t\toutput_format: 'pdf',\n\t\t\t\t\t\t\tinput: taskIdx === 0 ? jobConverts : 'task-' + taskIdx,\n\t\t\t\t\t\t\tfilename: file_name\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tjobTasks.push('task-' + (taskIdx + 1));\n\t\t\t\t\t});\n\n\t\t\t\t\tcloudJob['export-1'] = {\n\t\t\t\t\t\toperation: 'export/s3',\n\t\t\t\t\t\tinput: jobTasks[jobTasks.length - 1],\n\t\t\t\t\t\tbucket: this.serverConfig['AWSBUCKET'],\n\t\t\t\t\t\tregion: this.serverConfig['AWSREGION'],\n\t\t\t\t\t\taccess_key_id: this.serverConfig['AWSACCESSKEYID'],\n\t\t\t\t\t\tsecret_access_key: this.serverConfig['AWSSECRETACCESSKEY'],\n\t\t\t\t\t\tkey: file_output_key\n\t\t\t\t\t};\n\n\t\t\t\t\tconst request = bent('https://api.cloudconvert.com/v2', 'POST', 'json', 201);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet jobBody = await request('/jobs', {\n\t\t\t\t\t\t\ttasks: cloudJob\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t'Authorization': 'Bearer ' + this.serverConfig['CLOUDCONVERT_V2']\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tlet body = typeof jobBody === 'string' ? JSON.parse(jobBody) : jobBody;\n\n\t\t\t\t\t\tif (body && body.data && body.data.links) {\n\t\t\t\t\t\t\tconst requestWait = bent(body.data.links.self, 'GET', 'json', 200);\n\n\t\t\t\t\t\t\tlet running = false;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlet interval = setInterval(async () => {\n\t\t\t\t\t\t\t\tif (!running) {\n\t\t\t\t\t\t\t\t\trunning = true;\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet bodyWait = await requestWait('', null, {\n\t\t\t\t\t\t\t\t\t\t\t'Authorization': 'Bearer ' + this.serverConfig['CLOUDCONVERT_V2']\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\t\t\t\tlet responseBody = typeof bodyWait === 'string' ? JSON.parse(bodyWait) : bodyWait;\n\t\t\n\t\t\t\t\t\t\t\t\t\tif (responseBody.data.status === 'finished') {\n\t\t\t\t\t\t\t\t\t\t\tclearInterval(interval);\n\t\t\t\t\t\t\t\t\t\t\tresolve(responseBody);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcatch(errorWait) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error happened wait :',JSON.stringify(errorWait, null, 2));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\trunning = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, 1000);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch(error) {\n\t\t\t\t\t\tconsole.log('Error happened: ', JSON.stringify(error, null, 2));\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}"]}
|