n8n-nodes-make-pdf 1.2.1 → 1.2.3
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.
|
@@ -161,6 +161,10 @@ class MakePdf {
|
|
|
161
161
|
},
|
|
162
162
|
},
|
|
163
163
|
options: [
|
|
164
|
+
{
|
|
165
|
+
name: 'n8n Binary Data',
|
|
166
|
+
value: 'binaryData',
|
|
167
|
+
},
|
|
164
168
|
{
|
|
165
169
|
name: 'Form-Data Multipart',
|
|
166
170
|
value: 'multipart-form-data',
|
|
@@ -177,12 +181,8 @@ class MakePdf {
|
|
|
177
181
|
name: 'RAW/Custom',
|
|
178
182
|
value: 'raw',
|
|
179
183
|
},
|
|
180
|
-
{
|
|
181
|
-
name: 'n8n Binary Data',
|
|
182
|
-
value: 'binaryData',
|
|
183
|
-
},
|
|
184
184
|
],
|
|
185
|
-
default: '
|
|
185
|
+
default: 'binaryData',
|
|
186
186
|
description: 'Content-Type to use for body',
|
|
187
187
|
},
|
|
188
188
|
{
|
|
@@ -362,36 +362,68 @@ class MakePdf {
|
|
|
362
362
|
description: 'Maximum number of redirects to follow',
|
|
363
363
|
},
|
|
364
364
|
{
|
|
365
|
-
displayName: 'Response
|
|
366
|
-
name: '
|
|
367
|
-
|
|
365
|
+
displayName: 'Response',
|
|
366
|
+
name: 'response',
|
|
367
|
+
placeholder: 'Add Response',
|
|
368
|
+
type: 'fixedCollection',
|
|
369
|
+
typeOptions: {
|
|
370
|
+
multipleValues: false,
|
|
371
|
+
},
|
|
372
|
+
default: {},
|
|
368
373
|
options: [
|
|
369
374
|
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
375
|
+
displayName: 'Response',
|
|
376
|
+
name: 'response',
|
|
377
|
+
values: [
|
|
378
|
+
{
|
|
379
|
+
displayName: 'Include Response Headers and Status',
|
|
380
|
+
name: 'fullResponse',
|
|
381
|
+
type: 'boolean',
|
|
382
|
+
default: false,
|
|
383
|
+
description: 'Whether to return the full response (headers and status code) instead of only the body',
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
displayName: 'Never Error',
|
|
387
|
+
name: 'neverError',
|
|
388
|
+
type: 'boolean',
|
|
389
|
+
default: false,
|
|
390
|
+
description: 'Whether to succeed even when the HTTP status indicates an error',
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
displayName: 'Response Format',
|
|
394
|
+
name: 'responseFormat',
|
|
395
|
+
type: 'options',
|
|
396
|
+
options: [
|
|
397
|
+
{
|
|
398
|
+
name: 'Autodetect',
|
|
399
|
+
value: 'autodetect',
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
name: 'File',
|
|
403
|
+
value: 'file',
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
name: 'JSON',
|
|
407
|
+
value: 'json',
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: 'Text',
|
|
411
|
+
value: 'text',
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
default: 'file',
|
|
415
|
+
description: 'The format in which the data gets returned from the URL',
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
displayName: 'Put Output in Field',
|
|
419
|
+
name: 'outputPropertyName',
|
|
420
|
+
type: 'string',
|
|
421
|
+
default: 'data',
|
|
422
|
+
description: 'Name of the binary property to write the file to',
|
|
423
|
+
},
|
|
424
|
+
],
|
|
384
425
|
},
|
|
385
426
|
],
|
|
386
|
-
default: 'file',
|
|
387
|
-
description: 'The format in which the data gets returned from the URL',
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
displayName: 'Output Binary Field Name',
|
|
391
|
-
name: 'outputBinaryField',
|
|
392
|
-
type: 'string',
|
|
393
|
-
default: 'data',
|
|
394
|
-
description: 'Name of the binary property to write the file to (only used when Response Format is File)',
|
|
395
427
|
},
|
|
396
428
|
{
|
|
397
429
|
displayName: 'Timeout',
|
|
@@ -528,20 +560,37 @@ class MakePdf {
|
|
|
528
560
|
if (options.proxy) {
|
|
529
561
|
requestOptions.proxy = options.proxy;
|
|
530
562
|
}
|
|
531
|
-
|
|
563
|
+
// Get response options
|
|
564
|
+
const responseOptions = this.getNodeParameter('options.response.response', itemIndex, {});
|
|
565
|
+
const responseFormat = responseOptions.responseFormat || 'file';
|
|
566
|
+
const outputPropertyName = responseOptions.outputPropertyName || 'data';
|
|
567
|
+
const fullResponse = responseOptions.fullResponse || false;
|
|
568
|
+
const neverError = responseOptions.neverError || false;
|
|
569
|
+
// Set response format options
|
|
532
570
|
if (responseFormat === 'file') {
|
|
533
571
|
requestOptions.encoding = 'arraybuffer';
|
|
534
|
-
requestOptions.returnFullResponse =
|
|
572
|
+
requestOptions.returnFullResponse = fullResponse;
|
|
535
573
|
}
|
|
536
574
|
else if (responseFormat === 'json') {
|
|
537
575
|
requestOptions.json = true;
|
|
576
|
+
requestOptions.returnFullResponse = fullResponse;
|
|
538
577
|
}
|
|
539
578
|
// Make the request
|
|
540
|
-
|
|
579
|
+
let response;
|
|
580
|
+
try {
|
|
581
|
+
response = await this.helpers.httpRequest(requestOptions);
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
if (neverError) {
|
|
585
|
+
response = { error: error.message };
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
541
591
|
// Process response
|
|
542
592
|
let newItem;
|
|
543
593
|
if (responseFormat === 'file') {
|
|
544
|
-
const outputBinaryField = options.outputBinaryField || 'data';
|
|
545
594
|
const binaryData = {
|
|
546
595
|
data: Buffer.from(response).toString('base64'),
|
|
547
596
|
mimeType: 'application/pdf',
|
|
@@ -551,7 +600,7 @@ class MakePdf {
|
|
|
551
600
|
json: items[itemIndex].json,
|
|
552
601
|
binary: {
|
|
553
602
|
...items[itemIndex].binary,
|
|
554
|
-
[
|
|
603
|
+
[outputPropertyName]: binaryData,
|
|
555
604
|
},
|
|
556
605
|
pairedItem: itemIndex,
|
|
557
606
|
};
|