n8n-nodes-make-pdf 1.2.0 → 1.2.2
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.
|
@@ -362,41 +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: 'autodetect',
|
|
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
|
-
displayOptions: {
|
|
393
|
-
show: {
|
|
394
|
-
responseFormat: ['file'],
|
|
395
|
-
},
|
|
396
|
-
},
|
|
397
|
-
type: 'string',
|
|
398
|
-
default: 'data',
|
|
399
|
-
description: 'Name of the binary property to write the file to',
|
|
400
427
|
},
|
|
401
428
|
{
|
|
402
429
|
displayName: 'Timeout',
|
|
@@ -533,20 +560,37 @@ class MakePdf {
|
|
|
533
560
|
if (options.proxy) {
|
|
534
561
|
requestOptions.proxy = options.proxy;
|
|
535
562
|
}
|
|
536
|
-
|
|
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
|
|
537
570
|
if (responseFormat === 'file') {
|
|
538
571
|
requestOptions.encoding = 'arraybuffer';
|
|
539
|
-
requestOptions.returnFullResponse =
|
|
572
|
+
requestOptions.returnFullResponse = fullResponse;
|
|
540
573
|
}
|
|
541
574
|
else if (responseFormat === 'json') {
|
|
542
575
|
requestOptions.json = true;
|
|
576
|
+
requestOptions.returnFullResponse = fullResponse;
|
|
543
577
|
}
|
|
544
578
|
// Make the request
|
|
545
|
-
|
|
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
|
+
}
|
|
546
591
|
// Process response
|
|
547
592
|
let newItem;
|
|
548
593
|
if (responseFormat === 'file') {
|
|
549
|
-
const outputBinaryField = options.outputBinaryField || 'data';
|
|
550
594
|
const binaryData = {
|
|
551
595
|
data: Buffer.from(response).toString('base64'),
|
|
552
596
|
mimeType: 'application/pdf',
|
|
@@ -556,7 +600,7 @@ class MakePdf {
|
|
|
556
600
|
json: items[itemIndex].json,
|
|
557
601
|
binary: {
|
|
558
602
|
...items[itemIndex].binary,
|
|
559
|
-
[
|
|
603
|
+
[outputPropertyName]: binaryData,
|
|
560
604
|
},
|
|
561
605
|
pairedItem: itemIndex,
|
|
562
606
|
};
|