n8n-nodes-make-pdf 1.2.1 → 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,36 +362,68 @@ class MakePdf {
362
362
  description: 'Maximum number of redirects to follow',
363
363
  },
364
364
  {
365
- displayName: 'Response Format',
366
- name: 'responseFormat',
367
- type: 'options',
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
- name: 'Autodetect',
371
- value: 'autodetect',
372
- },
373
- {
374
- name: 'File',
375
- value: 'file',
376
- },
377
- {
378
- name: 'JSON',
379
- value: 'json',
380
- },
381
- {
382
- name: 'Text',
383
- value: 'text',
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
- const responseFormat = options.responseFormat || 'autodetect';
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 = false;
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
- const response = await this.helpers.httpRequest(requestOptions);
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
- [outputBinaryField]: binaryData,
603
+ [outputPropertyName]: binaryData,
555
604
  },
556
605
  pairedItem: itemIndex,
557
606
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-make-pdf",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "n8n node to generate PDFs via Gotenberg - Convert HTML to PDF with ease",
5
5
  "keywords": [
6
6
  "n8n",