@custom-js/n8n-nodes-pdf-toolkit 1.39.0 → 1.40.0

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.
@@ -76,21 +76,19 @@ class CompressPDF {
76
76
  headers: {
77
77
  "customjs-origin": "n8n/compressPdf",
78
78
  "x-api-key": credentials.apiKey,
79
- "Content-Type": "application/json",
80
79
  },
81
- body: JSON.stringify({
80
+ body: {
82
81
  input: isBinary ? { file: file } : { urls: field_name },
83
82
  code: `
84
83
  const { PDF_COMPRESS } = require('./utils');
85
84
  input = input.file || input.urls;
86
85
  return PDF_COMPRESS(input);`,
87
86
  returnBinary: "true",
88
- }),
89
- returnFullResponse: true,
90
- responseType: 'arraybuffer',
87
+ },
88
+ encoding: null,
89
+ json: true,
91
90
  };
92
- const responseData = await this.helpers.httpRequest(options);
93
- const response = responseData.body;
91
+ const response = await this.helpers.request(options);
94
92
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
95
93
  // No binary data returned; emit only JSON without a binary property
96
94
  returnData.push({
@@ -84,9 +84,8 @@ class ExtractPages {
84
84
  headers: {
85
85
  "customjs-origin": "n8n/extractPages",
86
86
  "x-api-key": credentials.apiKey,
87
- "Content-Type": "application/json",
88
87
  },
89
- body: JSON.stringify({
88
+ body: {
90
89
  input: isBinary
91
90
  ? { file: file, pageRange }
92
91
  : { urls: field_name, pageRange },
@@ -95,12 +94,11 @@ class ExtractPages {
95
94
  const pdfBuffer = input.file ? Buffer.from(input.file, 'base64') : input.urls;
96
95
  return EXTRACT_PAGES_FROM_PDF(pdfBuffer, input.pageRange);`,
97
96
  returnBinary: "true",
98
- }),
99
- returnFullResponse: true,
100
- responseType: 'arraybuffer',
97
+ },
98
+ encoding: null,
99
+ json: true,
101
100
  };
102
- const responseData = await this.helpers.httpRequest(options);
103
- const response = responseData.body;
101
+ const response = await this.helpers.request(options);
104
102
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
105
103
  // No binary data returned; emit only JSON without a binary property
106
104
  returnData.push({
@@ -81,7 +81,7 @@ class GetFormFieldNames {
81
81
  },
82
82
  json: true,
83
83
  };
84
- const response = await this.helpers.httpRequest(options);
84
+ const response = await this.helpers.request(options);
85
85
  returnData.push({
86
86
  json: {
87
87
  output: JSON.parse(response.toString()),
@@ -48,18 +48,16 @@ class Html2Docx {
48
48
  headers: {
49
49
  "customjs-origin": "n8n/html2Docx",
50
50
  "x-api-key": credentials.apiKey,
51
- "Content-Type": "application/json",
52
51
  },
53
- body: JSON.stringify({
52
+ body: {
54
53
  input: htmlInput,
55
54
  code: "const { HTML2DOCX } = require('./utils'); return HTML2DOCX(input)",
56
55
  returnBinary: "true",
57
- }),
58
- returnFullResponse: true,
59
- responseType: 'arraybuffer',
56
+ },
57
+ encoding: null,
58
+ json: true,
60
59
  };
61
- const responseData = await this.helpers.httpRequest(options);
62
- const response = responseData.body;
60
+ const response = await this.helpers.request(options);
63
61
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
64
62
  // No binary data returned; emit only JSON without a binary property
65
63
  returnData.push({
@@ -48,18 +48,16 @@ class Html2Pdf {
48
48
  headers: {
49
49
  "customjs-origin": "n8n/generatePDF",
50
50
  "x-api-key": credentials.apiKey,
51
- "Content-Type": "application/json",
52
51
  },
53
- body: JSON.stringify({
52
+ body: {
54
53
  input: htmlInput,
55
54
  code: "const { HTML2PDF } = require('./utils'); return HTML2PDF(input)",
56
55
  returnBinary: "true",
57
- }),
58
- returnFullResponse: true,
59
- responseType: 'arraybuffer',
56
+ },
57
+ encoding: null,
58
+ json: true,
60
59
  };
61
- const responseData = await this.helpers.httpRequest(options);
62
- const response = responseData.body;
60
+ const response = await this.helpers.request(options);
63
61
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
64
62
  // No binary data returned; emit only JSON without a binary property
65
63
  returnData.push({
@@ -254,22 +254,21 @@ class InvoiceGenerator {
254
254
  headers: {
255
255
  'customjs-origin': 'n8n/invoice-generator',
256
256
  'x-api-key': credentials.apiKey,
257
- 'Content-Type': 'application/json',
258
257
  },
259
- body: JSON.stringify({
258
+ body: {
260
259
  input: invoiceData,
261
260
  code: code,
262
261
  returnBinary: 'true',
263
- }),
264
- returnFullResponse: true,
265
- responseType: 'arraybuffer',
262
+ },
263
+ encoding: null,
264
+ json: true,
266
265
  };
267
- const responseData = await this.helpers.httpRequest(options);
268
- const response = responseData.body;
266
+ const response = await this.helpers.request(options);
269
267
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
270
268
  returnData.push({
271
269
  json: items[i].json,
272
270
  });
271
+ continue;
273
272
  }
274
273
  const binaryData = await this.helpers.prepareBinaryData(response, "Invoice.pdf");
275
274
  returnData.push({
@@ -56,7 +56,7 @@ class Markdown2Html {
56
56
  },
57
57
  json: true,
58
58
  };
59
- const response = await this.helpers.httpRequest(options);
59
+ const response = await this.helpers.request(options);
60
60
  returnData.push({
61
61
  json: {
62
62
  output: response.toString(),
@@ -68,21 +68,19 @@ class MergePdfs {
68
68
  headers: {
69
69
  "customjs-origin": "n8n/mergePDFs",
70
70
  "x-api-key": credentials.apiKey,
71
- "Content-Type": "application/json",
72
71
  },
73
- body: JSON.stringify({
72
+ body: {
74
73
  input: isBinary ? { files } : { urls },
75
74
  code: `
76
75
  const { PDF_MERGE } = require('./utils');
77
76
  input = [...input.files || [],...input.urls || []].filter(i => i);
78
77
  return PDF_MERGE(input);`,
79
78
  returnBinary: "true",
80
- }),
81
- returnFullResponse: true,
82
- responseType: 'arraybuffer',
79
+ },
80
+ encoding: null,
81
+ json: true,
83
82
  };
84
- const responseData = await this.helpers.httpRequest(options);
85
- const response = responseData.body;
83
+ const response = await this.helpers.request(options);
86
84
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
87
85
  // No binary data returned; emit only JSON without a binary property
88
86
  returnData.push({
@@ -103,9 +103,8 @@ class PdfFormFill {
103
103
  headers: {
104
104
  "customjs-origin": "n8n/pdfFormFill",
105
105
  "x-api-key": credentials.apiKey,
106
- "Content-Type": "application/json",
107
106
  },
108
- body: JSON.stringify({
107
+ body: {
109
108
  input: {
110
109
  file: file,
111
110
  // n8n fixedCollection with multipleValues returns an object like { field: [{ name, value }, ...] }
@@ -117,12 +116,11 @@ class PdfFormFill {
117
116
  const fieldValues = Object.fromEntries((input.fields || []).map(x => [x.name, x.value]));
118
117
  return PDF_FILL_FORM(pdfInput, fieldValues);`,
119
118
  returnBinary: "true",
120
- }),
121
- returnFullResponse: true,
122
- responseType: 'arraybuffer',
119
+ },
120
+ encoding: null,
121
+ json: true,
123
122
  };
124
- const responseData = await this.helpers.httpRequest(options);
125
- const response = responseData.body;
123
+ const response = await this.helpers.request(options);
126
124
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
127
125
  // No binary data returned; emit only JSON without a binary property
128
126
  returnData.push({
@@ -76,21 +76,19 @@ class PdfToPng {
76
76
  headers: {
77
77
  "customjs-origin": "n8n/pdfToPng",
78
78
  "x-api-key": credentials.apiKey,
79
- "Content-Type": "application/json",
80
79
  },
81
- body: JSON.stringify({
80
+ body: {
82
81
  input: isBinary ? { file: file } : { urls: field_name },
83
82
  code: `
84
83
  const { PDF2PNG } = require('./utils');
85
84
  input = input.file || input.urls;
86
85
  return PDF2PNG(input);`,
87
86
  returnBinary: "true",
88
- }),
89
- returnFullResponse: true,
90
- responseType: 'arraybuffer',
87
+ },
88
+ encoding: null,
89
+ json: true,
91
90
  };
92
- const responseData = await this.helpers.httpRequest(options);
93
- const response = responseData.body;
91
+ const response = await this.helpers.request(options);
94
92
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
95
93
  // No binary data returned; emit only JSON without a binary property
96
94
  returnData.push({
@@ -87,7 +87,7 @@ class PdfToText {
87
87
  },
88
88
  json: true,
89
89
  };
90
- const response = await this.helpers.httpRequest(options);
90
+ const response = await this.helpers.request(options);
91
91
  returnData.push({
92
92
  json: {
93
93
  output: response.toString(),
@@ -60,7 +60,7 @@ class SSLChecker {
60
60
  },
61
61
  json: true,
62
62
  };
63
- const response = await this.helpers.httpRequest(options);
63
+ const response = await this.helpers.request(options);
64
64
  returnData.push({
65
65
  json: {
66
66
  output: response,
@@ -137,20 +137,18 @@ class Scraper {
137
137
  headers: {
138
138
  "customjs-origin": "n8n/scraper",
139
139
  "x-api-key": credentials.apiKey,
140
- "Content-Type": "application/json",
141
140
  },
142
- body: JSON.stringify({
141
+ body: {
143
142
  input: JSON.stringify(payload),
144
143
  code: `const { SCRAPER } = require('./utils'); ` +
145
144
  `const payload = input; ` +
146
145
  `return SCRAPER(payload.url, payload.commands || [], "${returnValueType === "binary" ? "image" : "html"}", ${debug ? "true" : "false"});`,
147
146
  returnBinary: returnValueType === "binary" ? "true" : "false",
148
- }),
149
- returnFullResponse: returnValueType === "binary",
150
- responseType: returnValueType === "binary" ? 'arraybuffer' : undefined,
147
+ },
148
+ encoding: null,
149
+ json: true,
151
150
  };
152
- const responseData = await this.helpers.httpRequest(options);
153
- const response = returnValueType === "binary" ? responseData.body : responseData;
151
+ const response = await this.helpers.request(options);
154
152
  if (returnValueType === "binary") {
155
153
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
156
154
  // No binary data returned; emit only JSON without a binary property
@@ -45,18 +45,16 @@ class WebsiteScreenshot {
45
45
  headers: {
46
46
  "customjs-origin": "n8n/screenshot",
47
47
  "x-api-key": credentials.apiKey,
48
- "Content-Type": "application/json",
49
48
  },
50
- body: JSON.stringify({
49
+ body: {
51
50
  input: urlInput,
52
51
  code: "const { SCREENSHOT } = require('./utils'); return SCREENSHOT(input);",
53
52
  returnBinary: "true",
54
- }),
55
- returnFullResponse: true,
56
- responseType: 'arraybuffer',
53
+ },
54
+ encoding: null,
55
+ json: true,
57
56
  };
58
- const responseData = await this.helpers.httpRequest(options);
59
- const response = responseData.body;
57
+ const response = await this.helpers.request(options);
60
58
  if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
61
59
  // No binary data returned; emit only JSON without a binary property
62
60
  returnData.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.39.0",
3
+ "version": "1.40.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",