@activepieces/piece-cloudconvert 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -22
- package/src/index.js +25 -45
- package/README.md +0 -7
- package/src/index.d.ts +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/actions/archive-file.d.ts +0 -11
- package/src/lib/actions/archive-file.js +0 -251
- package/src/lib/actions/archive-file.js.map +0 -1
- package/src/lib/actions/capture-website.d.ts +0 -28
- package/src/lib/actions/capture-website.js +0 -347
- package/src/lib/actions/capture-website.js.map +0 -1
- package/src/lib/actions/convert-file.d.ts +0 -14
- package/src/lib/actions/convert-file.js +0 -228
- package/src/lib/actions/convert-file.js.map +0 -1
- package/src/lib/actions/download-file.d.ts +0 -5
- package/src/lib/actions/download-file.js +0 -168
- package/src/lib/actions/download-file.js.map +0 -1
- package/src/lib/actions/merge-pdf.d.ts +0 -10
- package/src/lib/actions/merge-pdf.js +0 -237
- package/src/lib/actions/merge-pdf.js.map +0 -1
- package/src/lib/actions/optimize-file.d.ts +0 -16
- package/src/lib/actions/optimize-file.js +0 -285
- package/src/lib/actions/optimize-file.js.map +0 -1
- package/src/lib/common/auth.d.ts +0 -1
- package/src/lib/common/auth.js +0 -29
- package/src/lib/common/auth.js.map +0 -1
- package/src/lib/common/client.d.ts +0 -99
- package/src/lib/common/client.js +0 -283
- package/src/lib/common/client.js.map +0 -1
- package/src/lib/common/index.d.ts +0 -9
- package/src/lib/common/index.js +0 -33
- package/src/lib/common/index.js.map +0 -1
- package/src/lib/common/properties.d.ts +0 -14
- package/src/lib/common/properties.js +0 -191
- package/src/lib/common/properties.js.map +0 -1
- package/src/lib/common/schemas.d.ts +0 -127
- package/src/lib/common/schemas.js +0 -178
- package/src/lib/common/schemas.js.map +0 -1
- package/src/lib/triggers/job-failed.d.ts +0 -2
- package/src/lib/triggers/job-failed.js +0 -113
- package/src/lib/triggers/job-failed.js.map +0 -1
- package/src/lib/triggers/job-finished.d.ts +0 -2
- package/src/lib/triggers/job-finished.js +0 -151
- package/src/lib/triggers/job-finished.js.map +0 -1
- package/src/lib/triggers/new-job.d.ts +0 -2
- package/src/lib/triggers/new-job.js +0 -125
- package/src/lib/triggers/new-job.js.map +0 -1
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.archiveFile = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
-
const common_1 = require("../common");
|
|
8
|
-
const pieces_framework_2 = require("@activepieces/pieces-framework");
|
|
9
|
-
const archiveFileProps = () => ({
|
|
10
|
-
import_method: pieces_framework_2.Property.StaticDropdown({
|
|
11
|
-
displayName: 'Import Method',
|
|
12
|
-
description: 'How to import the files for archiving',
|
|
13
|
-
required: true,
|
|
14
|
-
options: {
|
|
15
|
-
options: [
|
|
16
|
-
{ label: 'File Upload', value: 'upload' },
|
|
17
|
-
{ label: 'File URL', value: 'url' },
|
|
18
|
-
{ label: 'Stored File ID', value: 'stored_file' },
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
defaultValue: 'upload'
|
|
22
|
-
}),
|
|
23
|
-
files: pieces_framework_2.Property.Array({
|
|
24
|
-
displayName: 'Files to Archive',
|
|
25
|
-
description: 'List of files to include in the archive',
|
|
26
|
-
required: true,
|
|
27
|
-
properties: {
|
|
28
|
-
url: pieces_framework_2.Property.ShortText({
|
|
29
|
-
displayName: 'File URL',
|
|
30
|
-
description: 'URL of the file to archive',
|
|
31
|
-
required: false,
|
|
32
|
-
}),
|
|
33
|
-
file: pieces_framework_2.Property.File({
|
|
34
|
-
displayName: 'File',
|
|
35
|
-
description: 'File to upload and archive',
|
|
36
|
-
required: false,
|
|
37
|
-
}),
|
|
38
|
-
stored_file_id: pieces_framework_2.Property.ShortText({
|
|
39
|
-
displayName: 'Stored File ID',
|
|
40
|
-
description: 'ID of a previously stored file in Activepieces to archive',
|
|
41
|
-
required: false,
|
|
42
|
-
}),
|
|
43
|
-
filename: pieces_framework_2.Property.ShortText({
|
|
44
|
-
displayName: 'Filename in Archive',
|
|
45
|
-
description: 'Optional filename for this file within the archive',
|
|
46
|
-
required: false,
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}),
|
|
50
|
-
output_format: pieces_framework_2.Property.StaticDropdown({
|
|
51
|
-
displayName: 'Archive Format',
|
|
52
|
-
description: 'The archive format to create',
|
|
53
|
-
required: true,
|
|
54
|
-
options: {
|
|
55
|
-
options: [
|
|
56
|
-
{ label: 'ZIP', value: 'zip' },
|
|
57
|
-
{ label: 'RAR', value: 'rar' },
|
|
58
|
-
{ label: '7Z', value: '7z' },
|
|
59
|
-
{ label: 'TAR', value: 'tar' },
|
|
60
|
-
{ label: 'TAR.GZ', value: 'targz' },
|
|
61
|
-
{ label: 'TAR.BZ2', value: 'tarbz2' },
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
defaultValue: 'zip'
|
|
65
|
-
}),
|
|
66
|
-
filename: pieces_framework_2.Property.ShortText({
|
|
67
|
-
displayName: 'Archive Filename',
|
|
68
|
-
description: 'Choose a filename (including extension) for the archive file',
|
|
69
|
-
required: false,
|
|
70
|
-
defaultValue: 'archive.zip'
|
|
71
|
-
}),
|
|
72
|
-
engine: pieces_framework_2.Property.StaticDropdown({
|
|
73
|
-
displayName: 'Engine',
|
|
74
|
-
description: 'Use a specific engine for the archiving',
|
|
75
|
-
required: false,
|
|
76
|
-
options: {
|
|
77
|
-
options: [
|
|
78
|
-
{ label: '7-Zip', value: '7z' },
|
|
79
|
-
{ label: 'Archive Tool (Default)', value: 'archivetool' },
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
}),
|
|
83
|
-
engine_version: pieces_framework_2.Property.ShortText({
|
|
84
|
-
displayName: 'Engine Version',
|
|
85
|
-
description: 'Use a specific engine version for the archiving',
|
|
86
|
-
required: false,
|
|
87
|
-
}),
|
|
88
|
-
timeout: pieces_framework_2.Property.Number({
|
|
89
|
-
displayName: 'Timeout (seconds)',
|
|
90
|
-
description: 'Timeout in seconds after which the task will be cancelled',
|
|
91
|
-
required: false,
|
|
92
|
-
}),
|
|
93
|
-
wait_for_completion: pieces_framework_2.Property.Checkbox({
|
|
94
|
-
displayName: 'Wait for Completion',
|
|
95
|
-
description: 'Wait for the archive creation to complete before returning',
|
|
96
|
-
required: true,
|
|
97
|
-
defaultValue: true,
|
|
98
|
-
}),
|
|
99
|
-
store_file: pieces_framework_2.Property.Checkbox({
|
|
100
|
-
displayName: 'Store File',
|
|
101
|
-
description: 'Download and store the created archive in Activepieces',
|
|
102
|
-
required: false,
|
|
103
|
-
defaultValue: true,
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
106
|
-
exports.archiveFile = (0, pieces_framework_1.createAction)({
|
|
107
|
-
name: 'archive_file',
|
|
108
|
-
displayName: 'Archive File',
|
|
109
|
-
description: 'Creates a ZIP, RAR, 7Z, TAR, TAR.GZ or TAR.BZ2 archive',
|
|
110
|
-
auth: common_1.cloudconvertAuth,
|
|
111
|
-
requireAuth: true,
|
|
112
|
-
props: archiveFileProps(),
|
|
113
|
-
run(context) {
|
|
114
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
116
|
-
yield common_1.archiveFileSchema.parseAsync(context.propsValue);
|
|
117
|
-
const { import_method, files, output_format, filename, engine, engine_version, timeout, wait_for_completion, store_file } = context.propsValue;
|
|
118
|
-
if (!files || files.length === 0) {
|
|
119
|
-
throw new Error('At least one file is required to create an archive');
|
|
120
|
-
}
|
|
121
|
-
const client = new common_1.CloudConvertClient(context.auth);
|
|
122
|
-
try {
|
|
123
|
-
const jobTasks = {};
|
|
124
|
-
files.forEach((file, index) => {
|
|
125
|
-
var _a;
|
|
126
|
-
const taskName = `import-file-${index + 1}`;
|
|
127
|
-
if (import_method === 'url') {
|
|
128
|
-
if (!file.url) {
|
|
129
|
-
throw new Error(`File URL is required for file ${index + 1} when using URL import method`);
|
|
130
|
-
}
|
|
131
|
-
jobTasks[taskName] = Object.assign({ operation: 'import/url', url: file.url }, (file.filename && { filename: file.filename }));
|
|
132
|
-
}
|
|
133
|
-
else if (import_method === 'stored_file') {
|
|
134
|
-
if (!file.stored_file_id) {
|
|
135
|
-
throw new Error(`Stored File ID is required for file ${index + 1} when using stored file import method`);
|
|
136
|
-
}
|
|
137
|
-
if (!((_a = context.server) === null || _a === void 0 ? void 0 : _a.apiUrl)) {
|
|
138
|
-
throw new Error('Server API URL is not available. Please check your Activepieces server configuration.');
|
|
139
|
-
}
|
|
140
|
-
const baseUrl = context.server.apiUrl.replace(/\/$/, '');
|
|
141
|
-
const fileUrl = `${baseUrl}/v1/step-files/${file.stored_file_id}`;
|
|
142
|
-
try {
|
|
143
|
-
new URL(fileUrl);
|
|
144
|
-
}
|
|
145
|
-
catch (urlError) {
|
|
146
|
-
throw new Error(`Invalid file URL constructed: ${fileUrl}. URL Error: ${urlError instanceof Error ? urlError.message : String(urlError)}`);
|
|
147
|
-
}
|
|
148
|
-
jobTasks[taskName] = Object.assign({ operation: 'import/url', url: fileUrl }, (file.filename && { filename: file.filename }));
|
|
149
|
-
}
|
|
150
|
-
else if (import_method === 'upload') {
|
|
151
|
-
if (!file.file || !file.file.base64) {
|
|
152
|
-
throw new Error(`Please select a file to upload for file ${index + 1}`);
|
|
153
|
-
}
|
|
154
|
-
throw new Error('Upload method for multiple files is not yet supported with the new job format. Please use URL or stored file methods.');
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
throw new Error('Invalid import method selected');
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
// Collect all import task names
|
|
161
|
-
const importTaskNames = files.map((_, index) => `import-file-${index + 1}`);
|
|
162
|
-
// Archive task
|
|
163
|
-
const archiveOptions = {
|
|
164
|
-
input: importTaskNames.length === 1 ? importTaskNames[0] : importTaskNames,
|
|
165
|
-
output_format,
|
|
166
|
-
};
|
|
167
|
-
if (filename)
|
|
168
|
-
archiveOptions.filename = filename;
|
|
169
|
-
if (engine)
|
|
170
|
-
archiveOptions.engine = engine;
|
|
171
|
-
if (engine_version)
|
|
172
|
-
archiveOptions.engine_version = engine_version;
|
|
173
|
-
if (timeout)
|
|
174
|
-
archiveOptions.timeout = timeout;
|
|
175
|
-
jobTasks['archive-files'] = Object.assign({ operation: 'archive' }, archiveOptions);
|
|
176
|
-
// Export task
|
|
177
|
-
jobTasks['export-file'] = {
|
|
178
|
-
operation: 'export/url',
|
|
179
|
-
input: 'archive-files'
|
|
180
|
-
};
|
|
181
|
-
const job = yield client.createJob(jobTasks, `archive-${Date.now()}`);
|
|
182
|
-
if (wait_for_completion) {
|
|
183
|
-
let attempts = 0;
|
|
184
|
-
const maxAttempts = 60;
|
|
185
|
-
while (attempts < maxAttempts) {
|
|
186
|
-
const currentJob = yield client.getJob(job.id);
|
|
187
|
-
if (currentJob.status === 'finished') {
|
|
188
|
-
// Find the export task by name in the job
|
|
189
|
-
const exportTaskData = (_a = currentJob.tasks) === null || _a === void 0 ? void 0 : _a.find((task) => task.name === 'export-file');
|
|
190
|
-
const downloadUrl = (_d = (_c = (_b = exportTaskData === null || exportTaskData === void 0 ? void 0 : exportTaskData.result) === null || _b === void 0 ? void 0 : _b.files) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.url;
|
|
191
|
-
const outputFilename = ((_g = (_f = (_e = exportTaskData === null || exportTaskData === void 0 ? void 0 : exportTaskData.result) === null || _e === void 0 ? void 0 : _e.files) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.filename) || `archive.${output_format}`;
|
|
192
|
-
let storedFileId;
|
|
193
|
-
if (store_file && downloadUrl) {
|
|
194
|
-
try {
|
|
195
|
-
const fileResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
196
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
197
|
-
url: downloadUrl,
|
|
198
|
-
});
|
|
199
|
-
if (fileResponse.status === 200 && fileResponse.body) {
|
|
200
|
-
let fileData;
|
|
201
|
-
if (typeof fileResponse.body === 'string') {
|
|
202
|
-
fileData = Buffer.from(fileResponse.body, 'binary');
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
fileData = Buffer.from(fileResponse.body);
|
|
206
|
-
}
|
|
207
|
-
storedFileId = yield context.files.write({
|
|
208
|
-
data: fileData,
|
|
209
|
-
fileName: outputFilename,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
// Continue without throwing
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
job: currentJob,
|
|
219
|
-
download_url: downloadUrl,
|
|
220
|
-
filename: outputFilename,
|
|
221
|
-
stored_file_id: storedFileId,
|
|
222
|
-
file_count: files.length,
|
|
223
|
-
output_format,
|
|
224
|
-
size: ((_k = (_j = (_h = exportTaskData === null || exportTaskData === void 0 ? void 0 : exportTaskData.result) === null || _h === void 0 ? void 0 : _h.files) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.size) || 0
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
else if (currentJob.status === 'error') {
|
|
228
|
-
throw new Error(`Archive job failed: ${currentJob.message || 'Unknown error'}`);
|
|
229
|
-
}
|
|
230
|
-
yield new Promise(resolve => setTimeout(resolve, 5000));
|
|
231
|
-
attempts++;
|
|
232
|
-
}
|
|
233
|
-
throw new Error('Archive creation did not complete within the timeout period');
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
job,
|
|
237
|
-
file_count: files.length,
|
|
238
|
-
output_format,
|
|
239
|
-
status: 'processing'
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
if (error instanceof Error) {
|
|
244
|
-
throw error;
|
|
245
|
-
}
|
|
246
|
-
throw new Error(`Archive creation failed: ${String(error)}`);
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
//# sourceMappingURL=archive-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"archive-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/cloudconvert/src/lib/actions/archive-file.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAsF;AACtF,sCAAoF;AACpF,qEAA0D;AAE1D,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,CAAC;IAC9B,aAAa,EAAE,2BAAQ,CAAC,cAAc,CAAC;QACrC,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,uCAAuC;QACpD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE;gBACzC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;gBACnC,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE;aAClD;SACF;QACD,YAAY,EAAE,QAAQ;KACvB,CAAC;IACF,KAAK,EAAE,2BAAQ,CAAC,KAAK,CAAC;QACpB,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,yCAAyC;QACtD,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE;YACV,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;gBACtB,WAAW,EAAE,UAAU;gBACvB,WAAW,EAAE,4BAA4B;gBACzC,QAAQ,EAAE,KAAK;aAChB,CAAC;YACF,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;gBAClB,WAAW,EAAE,MAAM;gBACnB,WAAW,EAAE,4BAA4B;gBACzC,QAAQ,EAAE,KAAK;aACh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6BACtD,CAAC;wBACN,CAAC;6BAAM,IAAI,UAAU,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;4BACvC,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;wBACpF,CAAC;wBAED,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;wBACxD,QAAQ,EAAE,CAAC;oBACf,CAAC;oBAED,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;gBACnF,CAAC;gBAED,OAAO;oBACH,GAAG;oBACH,UAAU,EAAE,KAAK,CAAC,MAAM;oBACxB,aAAa;oBACb,MAAM,EAAE,YAAY;iBACvB,CAAC;YACN,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;oBACzB,MAAM,KAAK,CAAC;gBAChB,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACjE,CAAC;QACL,CAAC;KAAA;CAGJ,CAAC,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare const captureWebsite: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
-
url: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
-
output_format: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
4
|
-
pages: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
-
zoom: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
6
|
-
page_width: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
7
|
-
page_height: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
8
|
-
page_format: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
9
|
-
page_orientation: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
10
|
-
margin_top: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
11
|
-
margin_bottom: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
12
|
-
margin_left: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
13
|
-
margin_right: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
14
|
-
print_background: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
15
|
-
display_header_footer: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
16
|
-
header_template: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
17
|
-
footer_template: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
18
|
-
wait_until: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
19
|
-
wait_for_element: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
20
|
-
wait_time: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
21
|
-
css_media_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
22
|
-
filename: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
23
|
-
engine: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
24
|
-
engine_version: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
25
|
-
timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
26
|
-
wait_for_completion: import("@activepieces/pieces-framework").CheckboxProperty<true>;
|
|
27
|
-
store_file: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
28
|
-
}>;
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.captureWebsite = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
-
const common_1 = require("../common");
|
|
8
|
-
const pieces_framework_2 = require("@activepieces/pieces-framework");
|
|
9
|
-
const captureWebsiteProps = () => ({
|
|
10
|
-
url: pieces_framework_2.Property.ShortText({
|
|
11
|
-
displayName: 'Website URL',
|
|
12
|
-
description: 'The URL of the website to capture',
|
|
13
|
-
required: true,
|
|
14
|
-
}),
|
|
15
|
-
output_format: pieces_framework_2.Property.StaticDropdown({
|
|
16
|
-
displayName: 'Output Format',
|
|
17
|
-
description: 'The target format to convert to',
|
|
18
|
-
required: true,
|
|
19
|
-
options: {
|
|
20
|
-
options: [
|
|
21
|
-
{ label: 'PDF', value: 'pdf' },
|
|
22
|
-
{ label: 'PNG', value: 'png' },
|
|
23
|
-
{ label: 'JPG', value: 'jpg' },
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
defaultValue: 'pdf'
|
|
27
|
-
}),
|
|
28
|
-
pages: pieces_framework_2.Property.ShortText({
|
|
29
|
-
displayName: 'Pages',
|
|
30
|
-
description: 'Page range (e.g. 1-3) or comma separated list (e.g. 1,2,3) of pages',
|
|
31
|
-
required: false,
|
|
32
|
-
}),
|
|
33
|
-
zoom: pieces_framework_2.Property.Number({
|
|
34
|
-
displayName: 'Zoom Level',
|
|
35
|
-
description: 'Zoom level to display the website. Defaults to 1',
|
|
36
|
-
required: false,
|
|
37
|
-
}),
|
|
38
|
-
page_width: pieces_framework_2.Property.Number({
|
|
39
|
-
displayName: 'Page Width (cm)',
|
|
40
|
-
description: 'Page width in cm',
|
|
41
|
-
required: false,
|
|
42
|
-
}),
|
|
43
|
-
page_height: pieces_framework_2.Property.Number({
|
|
44
|
-
displayName: 'Page Height (cm)',
|
|
45
|
-
description: 'Page height in cm',
|
|
46
|
-
required: false,
|
|
47
|
-
}),
|
|
48
|
-
page_format: pieces_framework_2.Property.StaticDropdown({
|
|
49
|
-
displayName: 'Page Format',
|
|
50
|
-
description: 'Paper format type when printing a PDF. Overrides page_width and page_height',
|
|
51
|
-
required: false,
|
|
52
|
-
options: {
|
|
53
|
-
options: [
|
|
54
|
-
{ label: 'Letter', value: 'letter' },
|
|
55
|
-
{ label: 'Legal', value: 'legal' },
|
|
56
|
-
{ label: 'Tabloid', value: 'tabloid' },
|
|
57
|
-
{ label: 'Ledger', value: 'ledger' },
|
|
58
|
-
{ label: 'A0', value: 'a0' },
|
|
59
|
-
{ label: 'A1', value: 'a1' },
|
|
60
|
-
{ label: 'A2', value: 'a2' },
|
|
61
|
-
{ label: 'A3', value: 'a3' },
|
|
62
|
-
{ label: 'A4', value: 'a4' },
|
|
63
|
-
{ label: 'A5', value: 'a5' },
|
|
64
|
-
{ label: 'A6', value: 'a6' },
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
}),
|
|
68
|
-
page_orientation: pieces_framework_2.Property.StaticDropdown({
|
|
69
|
-
displayName: 'Page Orientation',
|
|
70
|
-
description: 'Page orientation for PDF output',
|
|
71
|
-
required: false,
|
|
72
|
-
options: {
|
|
73
|
-
options: [
|
|
74
|
-
{ label: 'Portrait', value: 'portrait' },
|
|
75
|
-
{ label: 'Landscape', value: 'landscape' },
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
defaultValue: 'portrait'
|
|
79
|
-
}),
|
|
80
|
-
margin_top: pieces_framework_2.Property.Number({
|
|
81
|
-
displayName: 'Top Margin (mm)',
|
|
82
|
-
description: 'Page top margin in mm',
|
|
83
|
-
required: false,
|
|
84
|
-
}),
|
|
85
|
-
margin_bottom: pieces_framework_2.Property.Number({
|
|
86
|
-
displayName: 'Bottom Margin (mm)',
|
|
87
|
-
description: 'Page bottom margin in mm',
|
|
88
|
-
required: false,
|
|
89
|
-
}),
|
|
90
|
-
margin_left: pieces_framework_2.Property.Number({
|
|
91
|
-
displayName: 'Left Margin (mm)',
|
|
92
|
-
description: 'Page left margin in mm',
|
|
93
|
-
required: false,
|
|
94
|
-
}),
|
|
95
|
-
margin_right: pieces_framework_2.Property.Number({
|
|
96
|
-
displayName: 'Right Margin (mm)',
|
|
97
|
-
description: 'Page right margin in mm',
|
|
98
|
-
required: false,
|
|
99
|
-
}),
|
|
100
|
-
print_background: pieces_framework_2.Property.Checkbox({
|
|
101
|
-
displayName: 'Print Background',
|
|
102
|
-
description: 'Render the background of websites',
|
|
103
|
-
required: false,
|
|
104
|
-
defaultValue: true,
|
|
105
|
-
}),
|
|
106
|
-
display_header_footer: pieces_framework_2.Property.Checkbox({
|
|
107
|
-
displayName: 'Display Header/Footer',
|
|
108
|
-
description: 'Create a header and a footer with the URL and page numbers',
|
|
109
|
-
required: false,
|
|
110
|
-
}),
|
|
111
|
-
header_template: pieces_framework_2.Property.LongText({
|
|
112
|
-
displayName: 'Header Template',
|
|
113
|
-
description: 'HTML template for the print header with classes: date, title, url, pageNumber, totalPages',
|
|
114
|
-
required: false,
|
|
115
|
-
}),
|
|
116
|
-
footer_template: pieces_framework_2.Property.LongText({
|
|
117
|
-
displayName: 'Footer Template',
|
|
118
|
-
description: 'HTML template for the print footer with classes: date, title, url, pageNumber, totalPages',
|
|
119
|
-
required: false,
|
|
120
|
-
}),
|
|
121
|
-
wait_until: pieces_framework_2.Property.StaticDropdown({
|
|
122
|
-
displayName: 'Wait Until',
|
|
123
|
-
description: 'When to consider navigation finished',
|
|
124
|
-
required: false,
|
|
125
|
-
options: {
|
|
126
|
-
options: [
|
|
127
|
-
{ label: 'Load Event', value: 'load' },
|
|
128
|
-
{ label: 'DOMContentLoaded', value: 'domcontentloaded' },
|
|
129
|
-
{ label: 'Network Idle (0 connections)', value: 'networkidle0' },
|
|
130
|
-
{ label: 'Network Idle (2 connections)', value: 'networkidle2' },
|
|
131
|
-
]
|
|
132
|
-
},
|
|
133
|
-
defaultValue: 'load'
|
|
134
|
-
}),
|
|
135
|
-
wait_for_element: pieces_framework_2.Property.ShortText({
|
|
136
|
-
displayName: 'Wait for Element',
|
|
137
|
-
description: 'CSS selector for element to wait for (e.g. "body" or "#element")',
|
|
138
|
-
required: false,
|
|
139
|
-
}),
|
|
140
|
-
wait_time: pieces_framework_2.Property.Number({
|
|
141
|
-
displayName: 'Wait Time (ms)',
|
|
142
|
-
description: 'Additional time in ms to wait after the page load',
|
|
143
|
-
required: false,
|
|
144
|
-
}),
|
|
145
|
-
css_media_type: pieces_framework_2.Property.StaticDropdown({
|
|
146
|
-
displayName: 'CSS Media Type',
|
|
147
|
-
description: 'Changes the CSS media type of the page',
|
|
148
|
-
required: false,
|
|
149
|
-
options: {
|
|
150
|
-
options: [
|
|
151
|
-
{ label: 'Print', value: 'print' },
|
|
152
|
-
{ label: 'Screen', value: 'screen' },
|
|
153
|
-
]
|
|
154
|
-
},
|
|
155
|
-
defaultValue: 'print'
|
|
156
|
-
}),
|
|
157
|
-
filename: pieces_framework_2.Property.ShortText({
|
|
158
|
-
displayName: 'Output Filename',
|
|
159
|
-
description: 'Choose a filename (including extension) for the output file',
|
|
160
|
-
required: false,
|
|
161
|
-
defaultValue: 'captured-website'
|
|
162
|
-
}),
|
|
163
|
-
engine: pieces_framework_2.Property.StaticDropdown({
|
|
164
|
-
displayName: 'Engine',
|
|
165
|
-
description: 'Use a specific engine for the conversion',
|
|
166
|
-
required: false,
|
|
167
|
-
options: {
|
|
168
|
-
options: [
|
|
169
|
-
{ label: 'Chrome (Default)', value: 'chrome' },
|
|
170
|
-
{ label: 'wkhtmltopdf', value: 'wkhtml' },
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
engine_version: pieces_framework_2.Property.ShortText({
|
|
175
|
-
displayName: 'Engine Version',
|
|
176
|
-
description: 'Use a specific engine version for the conversion',
|
|
177
|
-
required: false,
|
|
178
|
-
}),
|
|
179
|
-
timeout: pieces_framework_2.Property.Number({
|
|
180
|
-
displayName: 'Timeout (seconds)',
|
|
181
|
-
description: 'Timeout in seconds after the task will be cancelled',
|
|
182
|
-
required: false,
|
|
183
|
-
}),
|
|
184
|
-
wait_for_completion: pieces_framework_2.Property.Checkbox({
|
|
185
|
-
displayName: 'Wait for Completion',
|
|
186
|
-
description: 'Wait for the capture to complete before returning',
|
|
187
|
-
required: true,
|
|
188
|
-
defaultValue: true,
|
|
189
|
-
}),
|
|
190
|
-
store_file: pieces_framework_2.Property.Checkbox({
|
|
191
|
-
displayName: 'Store File',
|
|
192
|
-
description: 'Download and store the captured file in Activepieces',
|
|
193
|
-
required: false,
|
|
194
|
-
defaultValue: true,
|
|
195
|
-
}),
|
|
196
|
-
});
|
|
197
|
-
exports.captureWebsite = (0, pieces_framework_1.createAction)({
|
|
198
|
-
name: 'capture_website',
|
|
199
|
-
displayName: 'Capture Website',
|
|
200
|
-
description: 'Capture webpage as PDF, screenshot PNG, or JPG from a URL',
|
|
201
|
-
auth: common_1.cloudconvertAuth,
|
|
202
|
-
requireAuth: true,
|
|
203
|
-
props: captureWebsiteProps(),
|
|
204
|
-
run(context) {
|
|
205
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
var _a, _b, _c, _d, _e, _f;
|
|
207
|
-
yield common_1.captureWebsiteSchema.parseAsync(context.propsValue);
|
|
208
|
-
const { url, output_format, pages, zoom, page_width, page_height, page_format, page_orientation, margin_top, margin_bottom, margin_left, margin_right, print_background, display_header_footer, header_template, footer_template, wait_until, wait_for_element, wait_time, css_media_type, filename, engine, engine_version, timeout, wait_for_completion, store_file } = context.propsValue;
|
|
209
|
-
const client = new common_1.CloudConvertClient(context.auth);
|
|
210
|
-
try {
|
|
211
|
-
const captureOptions = {
|
|
212
|
-
url,
|
|
213
|
-
output_format,
|
|
214
|
-
};
|
|
215
|
-
if (pages)
|
|
216
|
-
captureOptions.pages = pages;
|
|
217
|
-
if (zoom !== undefined)
|
|
218
|
-
captureOptions.zoom = zoom;
|
|
219
|
-
if (page_width !== undefined)
|
|
220
|
-
captureOptions.page_width = page_width;
|
|
221
|
-
if (page_height !== undefined)
|
|
222
|
-
captureOptions.page_height = page_height;
|
|
223
|
-
if (page_format)
|
|
224
|
-
captureOptions.page_format = page_format;
|
|
225
|
-
if (page_orientation)
|
|
226
|
-
captureOptions.page_orientation = page_orientation;
|
|
227
|
-
if (margin_top !== undefined)
|
|
228
|
-
captureOptions.margin_top = margin_top;
|
|
229
|
-
if (margin_bottom !== undefined)
|
|
230
|
-
captureOptions.margin_bottom = margin_bottom;
|
|
231
|
-
if (margin_left !== undefined)
|
|
232
|
-
captureOptions.margin_left = margin_left;
|
|
233
|
-
if (margin_right !== undefined)
|
|
234
|
-
captureOptions.margin_right = margin_right;
|
|
235
|
-
if (print_background !== undefined)
|
|
236
|
-
captureOptions.print_background = print_background;
|
|
237
|
-
if (display_header_footer !== undefined)
|
|
238
|
-
captureOptions.display_header_footer = display_header_footer;
|
|
239
|
-
if (header_template)
|
|
240
|
-
captureOptions.header_template = header_template;
|
|
241
|
-
if (footer_template)
|
|
242
|
-
captureOptions.footer_template = footer_template;
|
|
243
|
-
if (wait_until)
|
|
244
|
-
captureOptions.wait_until = wait_until;
|
|
245
|
-
if (wait_for_element)
|
|
246
|
-
captureOptions.wait_for_element = wait_for_element;
|
|
247
|
-
if (wait_time !== undefined)
|
|
248
|
-
captureOptions.wait_time = wait_time;
|
|
249
|
-
if (css_media_type)
|
|
250
|
-
captureOptions.css_media_type = css_media_type;
|
|
251
|
-
if (filename)
|
|
252
|
-
captureOptions.filename = filename;
|
|
253
|
-
if (engine)
|
|
254
|
-
captureOptions.engine = engine;
|
|
255
|
-
if (engine_version)
|
|
256
|
-
captureOptions.engine_version = engine_version;
|
|
257
|
-
if (timeout !== undefined)
|
|
258
|
-
captureOptions.timeout = timeout;
|
|
259
|
-
const captureTask = yield client.createCaptureTask(captureOptions);
|
|
260
|
-
if (wait_for_completion) {
|
|
261
|
-
let attempts = 0;
|
|
262
|
-
const maxAttempts = 60;
|
|
263
|
-
while (attempts < maxAttempts) {
|
|
264
|
-
const currentTask = yield client.getTask(captureTask.id);
|
|
265
|
-
if (currentTask.status === 'finished') {
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
else if (currentTask.status === 'error') {
|
|
269
|
-
throw new Error(`Capture task failed: ${currentTask.message || 'Unknown error'}`);
|
|
270
|
-
}
|
|
271
|
-
yield new Promise(resolve => setTimeout(resolve, 5000));
|
|
272
|
-
attempts++;
|
|
273
|
-
}
|
|
274
|
-
if (attempts >= maxAttempts) {
|
|
275
|
-
throw new Error('Capture task did not complete within the timeout period');
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
const exportTask = yield client.createExportTask(captureTask.id);
|
|
279
|
-
if (wait_for_completion) {
|
|
280
|
-
let attempts = 0;
|
|
281
|
-
const maxAttempts = 60;
|
|
282
|
-
while (attempts < maxAttempts) {
|
|
283
|
-
const exportTaskData = yield client.getTask(exportTask.id);
|
|
284
|
-
if (exportTaskData.status === 'finished') {
|
|
285
|
-
const downloadUrl = (_c = (_b = (_a = exportTaskData.result) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.url;
|
|
286
|
-
const filename = ((_f = (_e = (_d = exportTaskData.result) === null || _d === void 0 ? void 0 : _d.files) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.filename) || 'captured-website.pdf';
|
|
287
|
-
let storedFileId;
|
|
288
|
-
if (store_file && downloadUrl) {
|
|
289
|
-
try {
|
|
290
|
-
const fileResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
291
|
-
method: pieces_common_1.HttpMethod.GET,
|
|
292
|
-
url: downloadUrl,
|
|
293
|
-
});
|
|
294
|
-
if (fileResponse.status === 200 && fileResponse.body) {
|
|
295
|
-
let fileData;
|
|
296
|
-
if (typeof fileResponse.body === 'string') {
|
|
297
|
-
fileData = Buffer.from(fileResponse.body, 'binary');
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
fileData = Buffer.from(fileResponse.body);
|
|
301
|
-
}
|
|
302
|
-
storedFileId = yield context.files.write({
|
|
303
|
-
data: fileData,
|
|
304
|
-
fileName: filename,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
catch (error) {
|
|
309
|
-
// Continue without throwing
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return {
|
|
313
|
-
capture_task: captureTask,
|
|
314
|
-
export_task: exportTaskData,
|
|
315
|
-
download_url: downloadUrl,
|
|
316
|
-
filename,
|
|
317
|
-
stored_file_id: storedFileId,
|
|
318
|
-
url,
|
|
319
|
-
output_format,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
else if (exportTaskData.status === 'error') {
|
|
323
|
-
throw new Error(`Export task failed: ${exportTaskData.message || 'Unknown error'}`);
|
|
324
|
-
}
|
|
325
|
-
yield new Promise(resolve => setTimeout(resolve, 5000));
|
|
326
|
-
attempts++;
|
|
327
|
-
}
|
|
328
|
-
throw new Error('Export did not complete within the timeout period');
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
capture_task: captureTask,
|
|
332
|
-
export_task: exportTask,
|
|
333
|
-
url,
|
|
334
|
-
output_format,
|
|
335
|
-
status: 'processing',
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
if (error instanceof Error) {
|
|
340
|
-
throw error;
|
|
341
|
-
}
|
|
342
|
-
throw new Error(`Website capture failed: ${String(error)}`);
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
},
|
|
346
|
-
});
|
|
347
|
-
//# sourceMappingURL=capture-website.js.map
|