@activepieces/piece-cloudconvert 0.0.1

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.
Files changed (47) hide show
  1. package/README.md +7 -0
  2. package/package.json +32 -0
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +45 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/archive-file.d.ts +11 -0
  7. package/src/lib/actions/archive-file.js +251 -0
  8. package/src/lib/actions/archive-file.js.map +1 -0
  9. package/src/lib/actions/capture-website.d.ts +28 -0
  10. package/src/lib/actions/capture-website.js +347 -0
  11. package/src/lib/actions/capture-website.js.map +1 -0
  12. package/src/lib/actions/convert-file.d.ts +14 -0
  13. package/src/lib/actions/convert-file.js +228 -0
  14. package/src/lib/actions/convert-file.js.map +1 -0
  15. package/src/lib/actions/download-file.d.ts +5 -0
  16. package/src/lib/actions/download-file.js +167 -0
  17. package/src/lib/actions/download-file.js.map +1 -0
  18. package/src/lib/actions/merge-pdf.d.ts +10 -0
  19. package/src/lib/actions/merge-pdf.js +237 -0
  20. package/src/lib/actions/merge-pdf.js.map +1 -0
  21. package/src/lib/actions/optimize-file.d.ts +16 -0
  22. package/src/lib/actions/optimize-file.js +285 -0
  23. package/src/lib/actions/optimize-file.js.map +1 -0
  24. package/src/lib/common/auth.d.ts +1 -0
  25. package/src/lib/common/auth.js +29 -0
  26. package/src/lib/common/auth.js.map +1 -0
  27. package/src/lib/common/client.d.ts +99 -0
  28. package/src/lib/common/client.js +283 -0
  29. package/src/lib/common/client.js.map +1 -0
  30. package/src/lib/common/index.d.ts +9 -0
  31. package/src/lib/common/index.js +33 -0
  32. package/src/lib/common/index.js.map +1 -0
  33. package/src/lib/common/properties.d.ts +14 -0
  34. package/src/lib/common/properties.js +242 -0
  35. package/src/lib/common/properties.js.map +1 -0
  36. package/src/lib/common/schemas.d.ts +533 -0
  37. package/src/lib/common/schemas.js +178 -0
  38. package/src/lib/common/schemas.js.map +1 -0
  39. package/src/lib/triggers/job-failed.d.ts +2 -0
  40. package/src/lib/triggers/job-failed.js +111 -0
  41. package/src/lib/triggers/job-failed.js.map +1 -0
  42. package/src/lib/triggers/job-finished.d.ts +2 -0
  43. package/src/lib/triggers/job-finished.js +150 -0
  44. package/src/lib/triggers/job-finished.js.map +1 -0
  45. package/src/lib/triggers/new-job.d.ts +2 -0
  46. package/src/lib/triggers/new-job.js +124 -0
  47. package/src/lib/triggers/new-job.js.map +1 -0
@@ -0,0 +1,347 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-website.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/cloudconvert/src/lib/actions/capture-website.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAsF;AACtF,sCAAuF;AACvF,qEAA0D;AAE1D,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,CAAC;IACjC,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;QACtB,WAAW,EAAE,aAAa;QAC1B,WAAW,EAAE,mCAAmC;QAChD,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,aAAa,EAAE,2BAAQ,CAAC,cAAc,CAAC;QACrC,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,iCAAiC;QAC9C,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;gBAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;gBAC9B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;aAC/B;SACF;QACD,YAAY,EAAE,KAAK;KACpB,CAAC;IACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;QACxB,WAAW,EAAE,OAAO;QACpB,WAAW,EAAE,qEAAqE;QAClF,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,YAAY;QACzB,WAAW,EAAE,kDAAkD;QAC/D,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;QAC1B,WAAW,EAAE,iBAAiB;QAC9B,WAAW,E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AE,UAAU;oBACvB,GAAG;oBACH,aAAa;oBACb,MAAM,EAAE,YAAY;iBACrB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;oBAC3B,MAAM,KAAK,CAAC;gBACd,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;KAAA;CAEF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const convertFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ import_method: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
3
+ file: import("@activepieces/pieces-framework").FileProperty<false>;
4
+ url: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ stored_file_id: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ input_format: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
7
+ output_format: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
8
+ filename: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ engine: import("@activepieces/pieces-framework").DropdownProperty<string, true> | import("@activepieces/pieces-framework").DropdownProperty<string, false>;
10
+ engine_version: import("@activepieces/pieces-framework").ShortTextProperty<false>;
11
+ timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
12
+ wait_for_completion: import("@activepieces/pieces-framework").CheckboxProperty<true>;
13
+ store_file: import("@activepieces/pieces-framework").CheckboxProperty<false>;
14
+ }>;
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertFile = 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
+ // Get the props function result
9
+ const getConvertFileProps = common_1.convertFileProps;
10
+ exports.convertFile = (0, pieces_framework_1.createAction)({
11
+ name: 'convert_file',
12
+ displayName: 'Convert File',
13
+ description: 'Create a basic file conversion task for a single file with desired output format',
14
+ auth: common_1.cloudconvertAuth,
15
+ requireAuth: true,
16
+ props: getConvertFileProps(),
17
+ run(context) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
20
+ yield common_1.convertFileSchema.parseAsync(context.propsValue);
21
+ const { import_method, url, file, stored_file_id, input_format, output_format, filename, engine, engine_version, timeout, wait_for_completion, store_file } = context.propsValue;
22
+ const client = new common_1.CloudConvertClient(context.auth);
23
+ try {
24
+ const supportedFormats = yield client.getSupportedFormats({
25
+ inputFormat: input_format === 'auto' ? undefined : input_format,
26
+ outputFormat: output_format,
27
+ include: ['options', 'engine_versions']
28
+ });
29
+ if (supportedFormats.length === 0) {
30
+ const allOutputFormats = yield client.getSupportedFormats({
31
+ outputFormat: output_format,
32
+ include: ['options', 'engine_versions']
33
+ });
34
+ throw new Error(`Conversion from ${input_format || 'auto-detected format'} to ${output_format} is not supported by CloudConvert. Available input formats for ${output_format}: ${allOutputFormats.map((f) => f.input_format).join(', ')}`);
35
+ }
36
+ const engines = [...new Set(supportedFormats.map((f) => f.engine))];
37
+ const jobTasks = {};
38
+ if (import_method === 'url') {
39
+ if (!url) {
40
+ throw new Error('File URL is required when using URL import method');
41
+ }
42
+ jobTasks['import-file'] = Object.assign({ operation: 'import/url', url: url }, (filename && { filename }));
43
+ }
44
+ else if (import_method === 'stored_file') {
45
+ if (!stored_file_id) {
46
+ throw new Error('Stored File ID is required when using stored file import method');
47
+ }
48
+ if (!((_a = context.server) === null || _a === void 0 ? void 0 : _a.apiUrl)) {
49
+ throw new Error('Server API URL is not available. Please check your Activepieces server configuration.');
50
+ }
51
+ const baseUrl = context.server.apiUrl.replace(/\/$/, '');
52
+ const fileUrl = `${baseUrl}/v1/step-files/${stored_file_id}`;
53
+ try {
54
+ new URL(fileUrl);
55
+ }
56
+ catch (urlError) {
57
+ throw new Error(`Invalid file URL constructed: ${fileUrl}. URL Error: ${urlError instanceof Error ? urlError.message : String(urlError)}`);
58
+ }
59
+ jobTasks['import-file'] = Object.assign({ operation: 'import/url', url: fileUrl }, (filename && { filename }));
60
+ }
61
+ else if (import_method === 'upload') {
62
+ if (!file || !file.base64) {
63
+ throw new Error('Please select a file to upload from your device');
64
+ }
65
+ const uploadTask = yield client.createUploadTask(file.filename || 'uploaded-file');
66
+ const uploadUrl = uploadTask.result.form.url;
67
+ const uploadForm = uploadTask.result.form.parameters;
68
+ const formData = new FormData();
69
+ Object.entries(uploadForm).forEach(([key, value]) => {
70
+ formData.append(key, value);
71
+ });
72
+ if (file.base64) {
73
+ const buffer = Buffer.from(file.base64, 'base64');
74
+ const blob = new Blob([buffer], { type: file.extension ? `application/${file.extension}` : 'application/octet-stream' });
75
+ formData.append('file', blob, file.filename);
76
+ }
77
+ const uploadResponse = yield pieces_common_1.httpClient.sendRequest({
78
+ method: pieces_common_1.HttpMethod.POST,
79
+ url: uploadUrl,
80
+ body: formData,
81
+ });
82
+ if (uploadResponse.status < 200 || uploadResponse.status >= 300) {
83
+ throw new Error(`Failed to upload file: HTTP ${uploadResponse.status} - ${((_b = uploadResponse.body) === null || _b === void 0 ? void 0 : _b.message) || 'Upload failed'}`);
84
+ }
85
+ jobTasks['import-file'] = Object.assign({ operation: 'import/upload' }, (filename && { filename }));
86
+ }
87
+ else {
88
+ throw new Error('Invalid import method selected');
89
+ }
90
+ const convertOptions = {
91
+ input: 'import-file',
92
+ output_format,
93
+ };
94
+ if (input_format && input_format !== 'auto') {
95
+ convertOptions.input_format = input_format;
96
+ }
97
+ if (filename) {
98
+ convertOptions.filename = filename;
99
+ }
100
+ if (engine) {
101
+ if (!engines.includes(engine)) {
102
+ convertOptions.engine = engines[0];
103
+ }
104
+ else {
105
+ convertOptions.engine = engine;
106
+ }
107
+ }
108
+ else if (engines.length > 0) {
109
+ convertOptions.engine = engines[0];
110
+ }
111
+ if (engine_version)
112
+ convertOptions.engine_version = engine_version;
113
+ if (timeout)
114
+ convertOptions.timeout = timeout;
115
+ jobTasks['convert-file'] = Object.assign({ operation: 'convert' }, convertOptions);
116
+ jobTasks['export-file'] = {
117
+ operation: 'export/url',
118
+ input: 'convert-file'
119
+ };
120
+ const job = yield client.createJob(jobTasks, `convert-${Date.now()}`);
121
+ if (wait_for_completion) {
122
+ let attempts = 0;
123
+ const maxAttempts = 60;
124
+ while (attempts < maxAttempts) {
125
+ const currentJob = yield client.getJob(job.id);
126
+ if (currentJob.status === 'finished') {
127
+ const exportTaskData = (_c = currentJob.tasks) === null || _c === void 0 ? void 0 : _c.find((task) => task.name === 'export-file');
128
+ const downloadUrl = (_f = (_e = (_d = exportTaskData === null || exportTaskData === void 0 ? void 0 : 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.url;
129
+ const outputFilename = ((_j = (_h = (_g = exportTaskData === null || exportTaskData === void 0 ? void 0 : exportTaskData.result) === null || _g === void 0 ? void 0 : _g.files) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.filename) || `converted-${output_format}`;
130
+ let storedFileId;
131
+ if (store_file && downloadUrl) {
132
+ try {
133
+ if (!downloadUrl || typeof downloadUrl !== 'string') {
134
+ throw new Error(`Invalid download URL: ${downloadUrl}`);
135
+ }
136
+ try {
137
+ new URL(downloadUrl);
138
+ }
139
+ catch (urlError) {
140
+ throw new Error(`Invalid download URL format: ${downloadUrl} - ${urlError instanceof Error ? urlError.message : String(urlError)}`);
141
+ }
142
+ const fileResponse = yield pieces_common_1.httpClient.sendRequest({
143
+ method: pieces_common_1.HttpMethod.GET,
144
+ url: downloadUrl,
145
+ });
146
+ if (fileResponse.status === 200 && fileResponse.body) {
147
+ let fileData;
148
+ if (typeof fileResponse.body === 'string') {
149
+ fileData = Buffer.from(fileResponse.body, 'binary');
150
+ }
151
+ else {
152
+ fileData = Buffer.from(fileResponse.body);
153
+ }
154
+ storedFileId = yield context.files.write({
155
+ data: fileData,
156
+ fileName: outputFilename,
157
+ });
158
+ }
159
+ }
160
+ catch (error) {
161
+ // Continue without throwing
162
+ }
163
+ }
164
+ return {
165
+ job: currentJob,
166
+ download_url: downloadUrl,
167
+ filename: outputFilename,
168
+ stored_file_id: storedFileId,
169
+ input_format,
170
+ output_format,
171
+ };
172
+ }
173
+ else if (currentJob.status === 'error') {
174
+ const failedTasks = ((_k = currentJob.tasks) === null || _k === void 0 ? void 0 : _k.filter((task) => task.status === 'error')) || [];
175
+ let errorMessage = `Conversion job failed: ${currentJob.message || 'Unknown error'}`;
176
+ if (failedTasks.length > 0) {
177
+ const taskErrors = failedTasks.map((task) => {
178
+ let taskError = `${task.name} (${task.operation})`;
179
+ if (task.code)
180
+ taskError += ` - Code: ${task.code}`;
181
+ if (task.message)
182
+ taskError += ` - ${task.message}`;
183
+ if (task.engine)
184
+ taskError += ` - Engine: ${task.engine}`;
185
+ if (task.engine_version)
186
+ taskError += ` v${task.engine_version}`;
187
+ return taskError;
188
+ }).join('; ');
189
+ errorMessage += `\n\nTask errors: ${taskErrors}`;
190
+ const convertTask = failedTasks.find((task) => task.operation === 'convert');
191
+ if (convertTask) {
192
+ if (convertTask.engine === 'pdftron-pdf2word' && convertTask.code === 'UNKNOWN_ERROR') {
193
+ errorMessage += '\n\nThis appears to be a file-specific issue. PDFs from website captures often contain complex layouts or images that cannot be converted to editable formats.';
194
+ errorMessage += '\n\nSuggested alternatives:';
195
+ errorMessage += '\n• Try converting to TXT (text only) or HTML format instead';
196
+ errorMessage += '\n• Use RTF format which is simpler than DOCX';
197
+ errorMessage += '\n• If this is a scanned/image-based PDF, it may need OCR processing';
198
+ errorMessage += '\n• Consider capturing the website directly to HTML instead of PDF→DOCX';
199
+ }
200
+ else if (convertTask.engine === 'pdftron-pdf2word') {
201
+ errorMessage += '\n\nTip: Try converting without specifying an engine, or try a different engine for better compatibility.';
202
+ }
203
+ }
204
+ }
205
+ throw new Error(errorMessage);
206
+ }
207
+ yield new Promise(resolve => setTimeout(resolve, 5000));
208
+ attempts++;
209
+ }
210
+ throw new Error('Conversion did not complete within the timeout period');
211
+ }
212
+ return {
213
+ job,
214
+ input_format,
215
+ output_format,
216
+ status: 'processing',
217
+ };
218
+ }
219
+ catch (error) {
220
+ if (error instanceof Error) {
221
+ throw error;
222
+ }
223
+ throw new Error(`File conversion failed: ${String(error)}`);
224
+ }
225
+ });
226
+ },
227
+ });
228
+ //# sourceMappingURL=convert-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/cloudconvert/src/lib/actions/convert-file.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAsF;AACtF,sCAAsG;AAEtG,gCAAgC;AAChC,MAAM,mBAAmB,GAAG,yBAAgB,CAAC;AAEhC,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACpC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,kFAAkF;IAC/F,IAAI,EAAE,yBAAgB;IACtB,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,mBAAmB,EAAE;IACtB,GAAG,CAAC,OAAO;;;YACb,MAAM,0BAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAEvD,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEjL,MAAM,MAAM,GAAG,IAAI,2BAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEpD,IAAI,CAAC;gBACD,MAAM,gBAAg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AC;gCACL,CAAC;4BACL,CAAC;4BAED,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;wBAClC,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,uDAAuD,CAAC,CAAC;gBAC7E,CAAC;gBAED,OAAO;oBACH,GAAG;oBACH,YAAY;oBACZ,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,2BAA2B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAChE,CAAC;QACL,CAAC;KAAA;CAEJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const downloadFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ task_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ include: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false>;
4
+ store_file: import("@activepieces/pieces-framework").CheckboxProperty<false>;
5
+ }>;