@custom-js/n8n-nodes-pdf-toolkit 1.48.0 → 1.50.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.
- package/README.md +39 -0
- package/dist/nodes/CompressPDF/CompressPDF.node.js +63 -40
- package/dist/nodes/ExtractPages/ExtractPages.node.js +64 -41
- package/dist/nodes/GetFormFieldNames/GetFormFieldNames.node.js +50 -30
- package/dist/nodes/Html2Docx/Html2Docx.node.js +51 -28
- package/dist/nodes/Html2Pdf/Html2Pdf.node.js +51 -28
- package/dist/nodes/InvoiceGenerator/InvoiceGenerator.node.js +93 -70
- package/dist/nodes/Markdown2Html/Markdown2Html.node.js +42 -22
- package/dist/nodes/MergePdfs/MergePdfs.node.js +60 -37
- package/dist/nodes/PdfFormFill/PdfFormFill.node.js +60 -37
- package/dist/nodes/PdfToPng/PdfToPng.node.js +59 -36
- package/dist/nodes/PdfToText/PdfToText.node.js +50 -30
- package/dist/nodes/SSLChecker/SSLChecker.node.js +41 -21
- package/dist/nodes/Scraper/Scraper.node.js +75 -49
- package/dist/nodes/WebsiteScreenshot/WebsiteScreenshot.node.js +51 -28
- package/package.json +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PdfToText = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class PdfToText {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -61,38 +62,57 @@ class PdfToText {
|
|
|
61
62
|
return Buffer.from(file.data, "base64");
|
|
62
63
|
};
|
|
63
64
|
for (let i = 0; i < items.length; i++) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
!
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const { PDFTOTEXT } =
|
|
65
|
+
try {
|
|
66
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
67
|
+
const field_name = this.getNodeParameter("field_name", i);
|
|
68
|
+
const isBinary = this.getNodeParameter("resource", i) === "binary";
|
|
69
|
+
const file = isBinary ? getFile(field_name, i) : "";
|
|
70
|
+
if (!isBinary &&
|
|
71
|
+
!field_name.startsWith("http://") &&
|
|
72
|
+
!field_name.startsWith("https://")) {
|
|
73
|
+
throw new Error(`Invalid URL: ${field_name}`);
|
|
74
|
+
}
|
|
75
|
+
const options = {
|
|
76
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: {
|
|
79
|
+
"customjs-origin": "n8n/pdfToText",
|
|
80
|
+
},
|
|
81
|
+
body: {
|
|
82
|
+
input: isBinary ? { file: file } : { urls: field_name },
|
|
83
|
+
code: `
|
|
84
|
+
const { PDFTOTEXT } = require('./utils');
|
|
84
85
|
input = input.file || input.urls;
|
|
85
86
|
return PDFTOTEXT(input);`,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
returnBinary: "false",
|
|
88
|
+
},
|
|
89
|
+
json: true,
|
|
90
|
+
};
|
|
91
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
92
|
+
returnData.push({
|
|
93
|
+
json: {
|
|
94
|
+
output: response.toString(),
|
|
95
|
+
},
|
|
96
|
+
pairedItem: {
|
|
97
|
+
item: i,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
103
|
+
if (this.continueOnFail()) {
|
|
104
|
+
returnData.push({
|
|
105
|
+
json: {
|
|
106
|
+
error: errorMessage,
|
|
107
|
+
},
|
|
108
|
+
pairedItem: {
|
|
109
|
+
item: i,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
115
|
+
}
|
|
96
116
|
}
|
|
97
117
|
return [returnData];
|
|
98
118
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SSLChecker = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class SSLChecker {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -45,27 +46,46 @@ class SSLChecker {
|
|
|
45
46
|
const items = this.getInputData();
|
|
46
47
|
const returnData = [];
|
|
47
48
|
for (let i = 0; i < items.length; i++) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
try {
|
|
50
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
51
|
+
const domain = this.getNodeParameter("domain", i);
|
|
52
|
+
const options = {
|
|
53
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: {
|
|
56
|
+
"customjs-origin": "n8n/sslchecker",
|
|
57
|
+
},
|
|
58
|
+
body: {
|
|
59
|
+
input: domain,
|
|
60
|
+
code: "const checkCertExpiration = require('check-cert-expiration'); return checkCertExpiration(input);",
|
|
61
|
+
},
|
|
62
|
+
json: true,
|
|
63
|
+
};
|
|
64
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
65
|
+
returnData.push({
|
|
66
|
+
json: {
|
|
67
|
+
output: response,
|
|
68
|
+
},
|
|
69
|
+
pairedItem: {
|
|
70
|
+
item: i,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
76
|
+
if (this.continueOnFail()) {
|
|
77
|
+
returnData.push({
|
|
78
|
+
json: {
|
|
79
|
+
error: errorMessage,
|
|
80
|
+
},
|
|
81
|
+
pairedItem: {
|
|
82
|
+
item: i,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
88
|
+
}
|
|
69
89
|
}
|
|
70
90
|
return [returnData];
|
|
71
91
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Scraper = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class Scraper {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -117,60 +118,85 @@ class Scraper {
|
|
|
117
118
|
const items = this.getInputData();
|
|
118
119
|
const returnData = [];
|
|
119
120
|
for (let i = 0; i < items.length; i++) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
121
|
+
try {
|
|
122
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
123
|
+
const url = this.getNodeParameter("url", i);
|
|
124
|
+
if (!url.startsWith("https://")) {
|
|
125
|
+
throw new Error("Website URL must start with https://");
|
|
126
|
+
}
|
|
127
|
+
const commandsRaw = this.getNodeParameter("commands", i, []);
|
|
128
|
+
const returnValueType = this.getNodeParameter("returnValueType", i);
|
|
129
|
+
const debug = this.getNodeParameter("debug", i);
|
|
130
|
+
// Flatten commands array
|
|
131
|
+
const commands = Array.isArray(commandsRaw.command) ? commandsRaw.command : [];
|
|
132
|
+
const payload = {
|
|
133
|
+
url,
|
|
134
|
+
commands,
|
|
135
|
+
};
|
|
136
|
+
const options = {
|
|
137
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
138
|
+
method: 'POST',
|
|
139
|
+
headers: {
|
|
140
|
+
"customjs-origin": "n8n/scraper",
|
|
141
|
+
},
|
|
142
|
+
body: {
|
|
143
|
+
input: JSON.stringify(payload),
|
|
144
|
+
code: `const { SCRAPER } = require('./utils'); ` +
|
|
145
|
+
`const payload = input; ` +
|
|
146
|
+
`return SCRAPER(payload.url, payload.commands || [], "${returnValueType === "binary" ? "image" : "html"}", ${debug ? "true" : "false"});`,
|
|
147
|
+
returnBinary: returnValueType === "binary" ? "true" : "false",
|
|
148
|
+
},
|
|
149
|
+
encoding: returnValueType === "binary" ? null : undefined,
|
|
150
|
+
json: true,
|
|
151
|
+
};
|
|
152
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
153
|
+
if (returnValueType === "binary") {
|
|
154
|
+
if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
|
|
155
|
+
// No binary data returned; emit only JSON without a binary property
|
|
156
|
+
returnData.push({
|
|
157
|
+
json: items[i].json,
|
|
158
|
+
pairedItem: {
|
|
159
|
+
item: i,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const binaryData = await this.helpers.prepareBinaryData(response, "output.png");
|
|
155
165
|
returnData.push({
|
|
156
166
|
json: items[i].json,
|
|
167
|
+
binary: {
|
|
168
|
+
data: binaryData,
|
|
169
|
+
},
|
|
170
|
+
pairedItem: {
|
|
171
|
+
item: i,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
returnData.push({
|
|
177
|
+
json: {
|
|
178
|
+
output: response.toString(),
|
|
179
|
+
},
|
|
180
|
+
pairedItem: {
|
|
181
|
+
item: i,
|
|
182
|
+
},
|
|
157
183
|
});
|
|
158
|
-
continue;
|
|
159
184
|
}
|
|
160
|
-
const binaryData = await this.helpers.prepareBinaryData(response, "output.png");
|
|
161
|
-
returnData.push({
|
|
162
|
-
json: items[i].json,
|
|
163
|
-
binary: {
|
|
164
|
-
data: binaryData,
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
185
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
186
|
+
catch (error) {
|
|
187
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
188
|
+
if (this.continueOnFail()) {
|
|
189
|
+
returnData.push({
|
|
190
|
+
json: {
|
|
191
|
+
error: errorMessage,
|
|
192
|
+
},
|
|
193
|
+
pairedItem: {
|
|
194
|
+
item: i,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
174
200
|
}
|
|
175
201
|
}
|
|
176
202
|
return [returnData];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebsiteScreenshot = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
4
5
|
class WebsiteScreenshot {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.description = {
|
|
@@ -37,38 +38,60 @@ class WebsiteScreenshot {
|
|
|
37
38
|
const items = this.getInputData();
|
|
38
39
|
const returnData = [];
|
|
39
40
|
for (let i = 0; i < items.length; i++) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
try {
|
|
42
|
+
const credentials = await this.getCredentials("customJsApi");
|
|
43
|
+
const urlInput = this.getNodeParameter("urlInput", i);
|
|
44
|
+
const options = {
|
|
45
|
+
url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: {
|
|
48
|
+
"customjs-origin": "n8n/screenshot",
|
|
49
|
+
},
|
|
50
|
+
body: {
|
|
51
|
+
input: urlInput,
|
|
52
|
+
code: "const { SCREENSHOT } = require('./utils'); return SCREENSHOT(input);",
|
|
53
|
+
returnBinary: "true",
|
|
54
|
+
},
|
|
55
|
+
encoding: null,
|
|
56
|
+
json: true,
|
|
57
|
+
};
|
|
58
|
+
const response = await this.helpers.requestWithAuthentication.call(this, 'customJsApi', options);
|
|
59
|
+
if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
|
|
60
|
+
// No binary data returned; emit only JSON without a binary property
|
|
61
|
+
returnData.push({
|
|
62
|
+
json: items[i].json,
|
|
63
|
+
pairedItem: {
|
|
64
|
+
item: i,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const binaryData = await this.helpers.prepareBinaryData(response, "output.png");
|
|
60
70
|
returnData.push({
|
|
61
71
|
json: items[i].json,
|
|
72
|
+
binary: {
|
|
73
|
+
data: binaryData,
|
|
74
|
+
},
|
|
75
|
+
pairedItem: {
|
|
76
|
+
item: i,
|
|
77
|
+
},
|
|
62
78
|
});
|
|
63
|
-
continue;
|
|
64
79
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
catch (error) {
|
|
81
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
82
|
+
if (this.continueOnFail()) {
|
|
83
|
+
returnData.push({
|
|
84
|
+
json: {
|
|
85
|
+
error: errorMessage,
|
|
86
|
+
},
|
|
87
|
+
pairedItem: {
|
|
88
|
+
item: i,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
94
|
+
}
|
|
72
95
|
}
|
|
73
96
|
return [returnData];
|
|
74
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@custom-js/n8n-nodes-pdf-toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.0",
|
|
4
4
|
"description": "This is official node for interacting with APIs from customjs.space",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"customjs",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"dist/nodes/InvoiceGenerator/InvoiceGenerator.node.js"
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"n8n-workflow": "^0.141.0"
|
|
49
|
-
},
|
|
50
47
|
"devDependencies": {
|
|
51
48
|
"typescript": "~4.8.4",
|
|
52
49
|
"gulp": "^4.0.2",
|
|
53
50
|
"@types/node": "^16.11.7"
|
|
54
51
|
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"n8n-workflow": "*"
|
|
54
|
+
},
|
|
55
55
|
"type": "commonjs",
|
|
56
56
|
"main": "index.js",
|
|
57
57
|
"scripts": {
|