@custom-js/n8n-nodes-pdf-toolkit-v2 0.2.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.
Files changed (29) hide show
  1. package/README.md +139 -0
  2. package/credentials/CustomJsApi.credentials.ts +48 -0
  3. package/dist/credentials/CustomJsApi.credentials.js +45 -0
  4. package/dist/nodes/PdfToolkit/PdfToolkit.node.js +725 -0
  5. package/dist/nodes/PdfToolkit/customJs.svg +24 -0
  6. package/dist/nodes/PdfToolkit/modules/ApiHelper.js +28 -0
  7. package/dist/nodes/PdfToolkit/modules/Convert/HtmlToDocx.js +24 -0
  8. package/dist/nodes/PdfToolkit/modules/Convert/HtmlToPdf.js +24 -0
  9. package/dist/nodes/PdfToolkit/modules/Convert/JsonToToon.js +15 -0
  10. package/dist/nodes/PdfToolkit/modules/Convert/MarkdownToHtml.js +15 -0
  11. package/dist/nodes/PdfToolkit/modules/Convert/PdfToPng.js +38 -0
  12. package/dist/nodes/PdfToolkit/modules/Convert/PdfToText.js +29 -0
  13. package/dist/nodes/PdfToolkit/modules/Convert/ToonToJson.js +15 -0
  14. package/dist/nodes/PdfToolkit/modules/Convert/index.js +31 -0
  15. package/dist/nodes/PdfToolkit/modules/Data/JsonSelect.js +16 -0
  16. package/dist/nodes/PdfToolkit/modules/Data/Regex.js +19 -0
  17. package/dist/nodes/PdfToolkit/modules/Data/index.js +16 -0
  18. package/dist/nodes/PdfToolkit/modules/PDF/Compress.js +38 -0
  19. package/dist/nodes/PdfToolkit/modules/PDF/ExtractPages.js +39 -0
  20. package/dist/nodes/PdfToolkit/modules/PDF/FillForm.js +33 -0
  21. package/dist/nodes/PdfToolkit/modules/PDF/GenerateInvoice.js +36 -0
  22. package/dist/nodes/PdfToolkit/modules/PDF/GetFormFields.js +22 -0
  23. package/dist/nodes/PdfToolkit/modules/PDF/Merge.js +47 -0
  24. package/dist/nodes/PdfToolkit/modules/PDF/index.js +28 -0
  25. package/dist/nodes/PdfToolkit/modules/Web/Scrape.js +32 -0
  26. package/dist/nodes/PdfToolkit/modules/Web/Screenshot.js +24 -0
  27. package/dist/nodes/PdfToolkit/modules/Web/SslCheck.js +15 -0
  28. package/dist/nodes/PdfToolkit/modules/Web/index.js +19 -0
  29. package/package.json +49 -0
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1080" height="1080" viewBox="-4.05 0.71 1080 1080" xml:space="preserve">
4
+ <desc>Created with Fabric.js 5.2.4</desc>
5
+ <defs>
6
+ </defs>
7
+ <g transform="matrix(1 0 0 1 540 540)" id="7b7fdf64-c054-4bb3-b5ef-d6fe7aa96b80" >
8
+ </g>
9
+ <g transform="matrix(1 0 0 1 540 540)" id="2321b111-224a-48e9-80a9-902df05610a3" >
10
+ <rect style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1; visibility: hidden;" vector-effect="non-scaling-stroke" x="-540" y="-540" rx="0" ry="0" width="1080" height="1080" />
11
+ </g>
12
+ <g transform="matrix(4.13 0 0 4.13 647.9 542.9)" >
13
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(48,54,66); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(0.18, -33.93)" d="M 0 0 C 0.95519531 -0.02449219 1.91039062 -0.04898438 2.89453125 -0.07421875 C 10.75518323 -0.10656711 15.93854482 1.68421562 21.9375 6.75 C 26.17018533 11.82922239 27.125 14.6375154 27.125 21.375 C 21.845 21.375 16.565 21.375 11.125 21.375 C 10.795 19.725 10.465 18.075 10.125 16.375 C 6.92258427 13.91160329 3.06611543 13.64219427 -0.875 13.375 C -5.89692506 14.39355354 -5.89692506 14.39355354 -9.875 17.375 C -9.93401922 19.39577346 -9.93401922 19.39577346 -8.875 21.375 C -4.97022671 24.22403829 -1.41266547 25.02415633 3.3125 25.8125 C 12.98753164 27.5907989 20.69236359 29.62284843 27.125 37.375 C 29.08446946 43.25340839 28.91830377 49.95101626 27 55.8125 C 22.43966545 62.04495721 16.63551271 65.68083127 9.125 67.375 C -2.61215098 68.64064057 -13.5103272 68.21287726 -23.3125 61.0625 C -27.71010172 56.45038113 -28.875 52.69781875 -28.875 46.375 C -23.595 46.375 -18.315 46.375 -12.875 46.375 C -12.215 47.695 -11.555 49.015 -10.875 50.375 C -5.78345043 53.35673199 -0.54227389 53.66361208 5.1796875 52.89453125 C 7.42635563 52.40609382 7.42635563 52.40609382 10.125 50.375 C 10.37515873 46.79142759 10.37515873 46.79142759 10.125 43.375 C 9.57714844 43.27703125 9.02929688 43.1790625 8.46484375 43.078125 C -17.41488576 38.19674513 -17.41488576 38.19674513 -24.1875 30.875 C -24.744375 30.05 -25.30125 29.225 -25.875 28.375 C -26.2875 27.776875 -26.7 27.17875 -27.125 26.5625 C -28.84418454 21.54821175 -28.43469544 17.00444643 -26.3125 12.25 C -23.48323329 7.1713163 -19.62629451 3.60717484 -14.328125 1.234375 C -9.52745168 0.0396373 -4.92945889 0.00659901 0 0 Z" stroke-linecap="round" />
14
+ </g>
15
+ <g transform="matrix(4.13 0 0 4.13 928.17 539.82)" >
16
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(100,93,232); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(-18.57, -40.8)" d="M 0 0 C 15.4154719 -0.84597102 15.4154719 -0.84597102 21 4 C 25.06368486 8.87350357 25.58279783 12.54788736 25.625 18.625 C 25.45573423 25.19052179 25.45573423 25.19052179 28 31 C 29.89870478 32.07978487 29.89870478 32.07978487 32.0625 32.6875 C 35.94385027 33.94385027 35.94385027 33.94385027 37 35 C 37.09879565 36.810285 37.12971514 38.62452727 37.125 40.4375 C 37.12886719 41.92056641 37.12886719 41.92056641 37.1328125 43.43359375 C 37 46 37 46 36 48 C 33.98520282 48.55794383 31.97029439 48.89073018 29.91015625 49.2421875 C 27.90623469 49.85384843 27.90623469 49.85384843 26.765625 51.55078125 C 25.65607384 55.10021277 25.74653168 58.62876465 25.6875 62.3125 C 25.43034016 68.99865595 25.10546095 73.23490311 20 78 C 13.44010105 82.09993684 7.51058045 82.11209822 0 82 C 0 78.04 0 74.08 0 70 C 1.134375 69.71125 2.26875 69.4225 3.4375 69.125 C 4.613125 68.75375 5.78875 68.3825 7 68 C 8.25632496 65.48735008 8.15398868 63.25590872 8.23950195 60.48901367 C 8.64668723 48.34835569 8.64668723 48.34835569 13 43 C 15.25 41.0625 15.25 41.0625 17 40 C 16.236875 39.62875 15.47375 39.2575 14.6875 38.875 C 11.33373962 36.53516717 10.52691928 34.78467172 9 31 C 8.55767009 28.25130909 8.44629424 25.53047551 8.375 22.75 C 8.39497409 17.72129005 8.39497409 17.72129005 7 13 C 4.67843403 12.59270772 2.3431213 12.25561323 0 12 C 0 8.04 0 4.08 0 0 Z" stroke-linecap="round" />
17
+ </g>
18
+ <g transform="matrix(4.13 0 0 4.13 149.69 540.72)" >
19
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(94,86,231); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(11.7, -41.08)" d="M 0 0 C 1.75570313 0.01353516 1.75570313 0.01353516 3.546875 0.02734375 C 4.43890625 0.03894531 5.3309375 0.05054687 6.25 0.0625 C 6.25 3.6925 6.25 7.3225 6.25 11.0625 C 5.115625 11.35125 3.98125 11.64 2.8125 11.9375 C 1.636875 12.30875 0.46125 12.68 -0.75 13.0625 C -2.24215637 16.04681274 -1.98735138 18.93004634 -2.125 22.25 C -2.43666193 27.77348756 -2.73652838 32.32704459 -5.75 37.0625 C -8.4375 39 -8.4375 39 -10.75 40.0625 C -9.986875 40.578125 -9.22375 41.09375 -8.4375 41.625 C -4.27259808 45.40246919 -2.68701725 49.67149825 -2.30859375 55.17578125 C -2.25502591 56.57507775 -2.21474855 57.97494367 -2.1875 59.375 C -2.35499664 64.70839017 -2.35499664 64.70839017 0.25 69.0625 C 2.23821313 69.46014263 4.23944339 69.80025349 6.25 70.0625 C 6.27687279 71.87492052 6.29633715 73.68745233 6.3125 75.5 C 6.32410156 76.50933594 6.33570313 77.51867187 6.34765625 78.55859375 C 6.25 81.0625 6.25 81.0625 5.25 82.0625 C -2.32464922 82.60354637 -9.17557982 81.37262698 -15.25 76.5625 C -19.80461172 72.00788828 -19.05763186 66.37850593 -19.26757812 60.31054688 C -19.38990221 54.84257441 -19.38990221 54.84257441 -21.75 50.0625 C -23.68981618 49.15640008 -23.68981618 49.15640008 -25.875 48.8125 C -27.15375 48.565 -28.4325 48.3175 -29.75 48.0625 C -29.75 43.4425 -29.75 38.8225 -29.75 34.0625 C -27.43880208 33.11848958 -25.12760417 32.17447917 -22.81640625 31.23046875 C -20.41627512 30.17846912 -20.41627512 30.17846912 -19.75 27.0625 C -19.58691355 23.53620844 -19.453885 20.01601458 -19.40820312 16.48632812 C -19.21063493 11.25306836 -18.14493176 8.25361651 -14.75 4.0625 C -10.18531329 -0.07424733 -6.00456455 -0.06004565 0 0 Z" stroke-linecap="round" />
20
+ </g>
21
+ <g transform="matrix(4.13 0 0 4.13 400.2 543.8)" >
22
+ <path style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(43,48,61); fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke" transform=" translate(7.3, -33.77)" d="M 0 0 C 2.47923801 -0.02685095 4.9581884 -0.04676547 7.4375 -0.0625 C 8.14455078 -0.07087891 8.85160156 -0.07925781 9.58007812 -0.08789062 C 11.38693559 -0.09653588 13.19387603 -0.05220011 15 0 C 16.63250229 1.63250229 16.16872849 3.49008236 16.20874023 5.74414062 C 16.22803085 6.75609497 16.24732147 7.76804932 16.26719666 8.81066895 C 16.32488713 13.47302889 16.37428059 18.13522937 16.4050293 22.79785156 C 16.42655207 25.25177126 16.46058591 27.70561539 16.50756836 30.15917969 C 16.57478207 33.70021823 16.60207198 37.23966222 16.62109375 40.78125 C 16.64892441 41.8690979 16.67675507 42.9569458 16.70542908 44.07775879 C 16.68552495 51.51836273 15.13219782 56.48869158 10 62 C 2.5308992 67.80202095 -5.97170003 68.13040294 -15.08837891 67.29101562 C -19.4631827 66.6250174 -22.66465564 64.81817861 -26 62 C -26.54269531 61.5771875 -27.08539063 61.154375 -27.64453125 60.71875 C -30.04154058 58.44720396 -30.95650141 56.41438127 -31.296875 53.171875 C -31.31094808 50.42762393 -31.21897411 47.73474339 -31 45 C -26.28715138 44.65976761 -21.70082374 44.44728382 -17 45 C -14.5625 47.9375 -14.5625 47.9375 -13 51 C -9.27256275 52.13154345 -7.18419111 52.56093263 -3.625 50.875 C 0.20150211 46.45980525 -0.78258786 39.43477346 -0.68359375 33.88671875 C -0.66281265 32.91716751 -0.64203156 31.94761627 -0.62062073 30.94868469 C -0.55541059 27.86169293 -0.4963732 24.77461848 -0.4375 21.6875 C -0.39428763 19.59048636 -0.35067248 17.49348097 -0.30664062 15.39648438 C -0.19975849 10.26440693 -0.09841104 5.13224659 0 0 Z" stroke-linecap="round" />
23
+ </g>
24
+ </svg>
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiHelper = void 0;
4
+ class ApiHelper {
5
+ constructor(executeFunctions) {
6
+ this.executeFunctions = executeFunctions;
7
+ }
8
+ async makeRequest(origin, body, returnBinary = false, itemIndex = 0) {
9
+ const credentials = await this.executeFunctions.getCredentials('customJsApi');
10
+ const options = {
11
+ url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
12
+ method: 'POST',
13
+ headers: {
14
+ 'customjs-origin': origin,
15
+ },
16
+ body: {
17
+ ...body,
18
+ returnBinary: returnBinary ? 'true' : 'false',
19
+ },
20
+ json: true,
21
+ };
22
+ if (returnBinary) {
23
+ options.encoding = 'arraybuffer';
24
+ }
25
+ return this.executeFunctions.helpers.httpRequestWithAuthentication.call(this.executeFunctions, 'customJsApi', options);
26
+ }
27
+ }
28
+ exports.ApiHelper = ApiHelper;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeHtmlToDocx = void 0;
4
+ async function executeHtmlToDocx(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const html = executeFunctions.getNodeParameter('html', itemIndex);
7
+ const body = {
8
+ input: html,
9
+ code: "const { HTML2DOCX } = require('./utils'); return HTML2DOCX(input)",
10
+ returnBinary: 'true',
11
+ };
12
+ const response = await apiHelper.makeRequest('n8n/html2Docx', body, true, itemIndex);
13
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenameDocx', itemIndex, 'output.docx');
14
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
15
+ return { json: item.json, pairedItem: { item: itemIndex } };
16
+ }
17
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
18
+ return {
19
+ json: item.json,
20
+ binary: { data: binaryData },
21
+ pairedItem: { item: itemIndex }
22
+ };
23
+ }
24
+ exports.executeHtmlToDocx = executeHtmlToDocx;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeHtmlToPdf = void 0;
4
+ async function executeHtmlToPdf(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const html = executeFunctions.getNodeParameter('html', itemIndex);
7
+ const body = {
8
+ input: html,
9
+ code: "const { HTML2PDF } = require('./utils'); return HTML2PDF(input)",
10
+ returnBinary: 'true',
11
+ };
12
+ const response = await apiHelper.makeRequest('n8n/generatePDF', body, true, itemIndex);
13
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePdf', itemIndex, 'output.pdf');
14
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
15
+ return { json: item.json, pairedItem: { item: itemIndex } };
16
+ }
17
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
18
+ return {
19
+ json: item.json,
20
+ binary: { data: binaryData },
21
+ pairedItem: { item: itemIndex }
22
+ };
23
+ }
24
+ exports.executeHtmlToPdf = executeHtmlToPdf;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeJsonToToon = void 0;
4
+ async function executeJsonToToon(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const json = executeFunctions.getNodeParameter('json', itemIndex);
7
+ const body = {
8
+ input: json,
9
+ code: "const toon = require('./utils/toon-cjs'); const data = typeof input === 'string' ? JSON.parse(input) : input; const encoded = await toon.encode(data); return encoded;",
10
+ returnBinary: 'false',
11
+ };
12
+ const response = await apiHelper.makeRequest('make/jsonToToon', body, false, itemIndex);
13
+ return { json: { toon: response }, pairedItem: { item: itemIndex } };
14
+ }
15
+ exports.executeJsonToToon = executeJsonToToon;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeMarkdownToHtml = void 0;
4
+ async function executeMarkdownToHtml(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const markdown = executeFunctions.getNodeParameter('markdown', itemIndex);
7
+ const body = {
8
+ input: markdown,
9
+ code: "const { MD2HTML } = require('./utils'); return MD2HTML(input)",
10
+ returnBinary: 'false',
11
+ };
12
+ const response = await apiHelper.makeRequest('n8n/markdown2html', body, false, itemIndex);
13
+ return { json: { output: response.toString() }, pairedItem: { item: itemIndex } };
14
+ }
15
+ exports.executeMarkdownToHtml = executeMarkdownToHtml;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executePdfToPng = void 0;
4
+ async function executePdfToPng(executeFunctions, apiHelper, itemIndex) {
5
+ var _a;
6
+ const item = executeFunctions.getInputData()[itemIndex];
7
+ const inputType = executeFunctions.getNodeParameter('inputType', itemIndex);
8
+ const body = {
9
+ code: `
10
+ const { PDF2PNG } = require('./utils');
11
+ input = input.file || input.urls;
12
+ return PDF2PNG(input);`,
13
+ returnBinary: 'true',
14
+ };
15
+ if (inputType === 'binary') {
16
+ const binaryPropertyName = executeFunctions.getNodeParameter('binaryPropertyName', itemIndex);
17
+ const binaryData = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
18
+ if (!binaryData)
19
+ throw new Error(`Binary property ${binaryPropertyName} not found`);
20
+ body.input = { file: Buffer.from(binaryData.data, 'base64') };
21
+ }
22
+ else {
23
+ const url = executeFunctions.getNodeParameter('url', itemIndex);
24
+ body.input = { urls: url };
25
+ }
26
+ const response = await apiHelper.makeRequest('n8n/pdfToPng', body, true, itemIndex);
27
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePng', itemIndex, 'output.png');
28
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
29
+ return { json: item.json, pairedItem: { item: itemIndex } };
30
+ }
31
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
32
+ return {
33
+ json: item.json,
34
+ binary: { data: binaryData },
35
+ pairedItem: { item: itemIndex }
36
+ };
37
+ }
38
+ exports.executePdfToPng = executePdfToPng;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executePdfToText = void 0;
4
+ async function executePdfToText(executeFunctions, apiHelper, itemIndex) {
5
+ var _a;
6
+ const item = executeFunctions.getInputData()[itemIndex];
7
+ const inputType = executeFunctions.getNodeParameter('inputType', itemIndex);
8
+ const body = {
9
+ code: `
10
+ const { PDFTOTEXT } = require('./utils');
11
+ input = input.file || input.urls;
12
+ return PDFTOTEXT(input);`,
13
+ returnBinary: 'false',
14
+ };
15
+ if (inputType === 'binary') {
16
+ const binaryPropertyName = executeFunctions.getNodeParameter('binaryPropertyName', itemIndex);
17
+ const binaryData = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
18
+ if (!binaryData)
19
+ throw new Error(`Binary property ${binaryPropertyName} not found`);
20
+ body.input = { file: Buffer.from(binaryData.data, 'base64') };
21
+ }
22
+ else {
23
+ const url = executeFunctions.getNodeParameter('url', itemIndex);
24
+ body.input = { urls: url };
25
+ }
26
+ const response = await apiHelper.makeRequest('n8n/pdfToText', body, false, itemIndex);
27
+ return { json: response, pairedItem: { item: itemIndex } };
28
+ }
29
+ exports.executePdfToText = executePdfToText;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeToonToJson = void 0;
4
+ async function executeToonToJson(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const toon = executeFunctions.getNodeParameter('toon', itemIndex);
7
+ const body = {
8
+ input: toon,
9
+ code: "const toon = require('./utils/toon-cjs'); return await toon.decode(input);",
10
+ returnBinary: 'false',
11
+ };
12
+ const response = await apiHelper.makeRequest('make/toonToJson', body, false, itemIndex);
13
+ return { json: response, pairedItem: { item: itemIndex } };
14
+ }
15
+ exports.executeToonToJson = executeToonToJson;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeConvert = void 0;
4
+ const PdfToPng_1 = require("./PdfToPng");
5
+ const PdfToText_1 = require("./PdfToText");
6
+ const HtmlToDocx_1 = require("./HtmlToDocx");
7
+ const HtmlToPdf_1 = require("./HtmlToPdf");
8
+ const JsonToToon_1 = require("./JsonToToon");
9
+ const ToonToJson_1 = require("./ToonToJson");
10
+ const MarkdownToHtml_1 = require("./MarkdownToHtml");
11
+ async function executeConvert(executeFunctions, apiHelper, itemIndex, operation) {
12
+ switch (operation) {
13
+ case 'pdfToPng':
14
+ return (0, PdfToPng_1.executePdfToPng)(executeFunctions, apiHelper, itemIndex);
15
+ case 'pdfToText':
16
+ return (0, PdfToText_1.executePdfToText)(executeFunctions, apiHelper, itemIndex);
17
+ case 'htmlToDocx':
18
+ return (0, HtmlToDocx_1.executeHtmlToDocx)(executeFunctions, apiHelper, itemIndex);
19
+ case 'htmlToPdf':
20
+ return (0, HtmlToPdf_1.executeHtmlToPdf)(executeFunctions, apiHelper, itemIndex);
21
+ case 'jsonToToon':
22
+ return (0, JsonToToon_1.executeJsonToToon)(executeFunctions, apiHelper, itemIndex);
23
+ case 'toonToJson':
24
+ return (0, ToonToJson_1.executeToonToJson)(executeFunctions, apiHelper, itemIndex);
25
+ case 'markdownToHtml':
26
+ return (0, MarkdownToHtml_1.executeMarkdownToHtml)(executeFunctions, apiHelper, itemIndex);
27
+ default:
28
+ throw new Error(`Unknown operation: ${operation}`);
29
+ }
30
+ }
31
+ exports.executeConvert = executeConvert;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeJsonSelect = void 0;
4
+ async function executeJsonSelect(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const json = executeFunctions.getNodeParameter('json', itemIndex);
7
+ const path = executeFunctions.getNodeParameter('path', itemIndex);
8
+ const body = {
9
+ input: { json, path },
10
+ code: "const { JSONPath } = require('jsonpath-plus'); return JSONPath({ path: input.path, json: JSON.parse(input.json) });",
11
+ returnBinary: 'false',
12
+ };
13
+ const response = await apiHelper.makeRequest('make/jsonSelector', body, false, itemIndex);
14
+ return { json: { result: response }, pairedItem: { item: itemIndex } };
15
+ }
16
+ exports.executeJsonSelect = executeJsonSelect;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeRegex = void 0;
4
+ async function executeRegex(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const textData = executeFunctions.getNodeParameter('textData', itemIndex);
7
+ const regexPattern = executeFunctions.getNodeParameter('regexPattern', itemIndex);
8
+ const regexFlags = executeFunctions.getNodeParameter('regexFlags', itemIndex);
9
+ const regexOperation = executeFunctions.getNodeParameter('regexOperation', itemIndex);
10
+ const replacement = executeFunctions.getNodeParameter('replacement', itemIndex, '');
11
+ const body = {
12
+ input: { textData, regexPattern, regexFlags, operation: regexOperation, replacement },
13
+ code: "const pattern = input.regexPattern.trim().replace(/^['\"]+|['\"]+$/g, ''); return REGEX({ operation: input.operation, inputText: input.textData, pattern: pattern, flags: input.regexFlags, replacement: input.replacement });",
14
+ returnBinary: 'false',
15
+ };
16
+ const response = await apiHelper.makeRequest('make/regexTool', body, false, itemIndex);
17
+ return { json: { result: response }, pairedItem: { item: itemIndex } };
18
+ }
19
+ exports.executeRegex = executeRegex;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeData = void 0;
4
+ const JsonSelect_1 = require("./JsonSelect");
5
+ const Regex_1 = require("./Regex");
6
+ async function executeData(executeFunctions, apiHelper, itemIndex, operation) {
7
+ switch (operation) {
8
+ case 'jsonSelect':
9
+ return (0, JsonSelect_1.executeJsonSelect)(executeFunctions, apiHelper, itemIndex);
10
+ case 'regex':
11
+ return (0, Regex_1.executeRegex)(executeFunctions, apiHelper, itemIndex);
12
+ default:
13
+ throw new Error(`Unknown operation: ${operation}`);
14
+ }
15
+ }
16
+ exports.executeData = executeData;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeCompress = void 0;
4
+ async function executeCompress(executeFunctions, apiHelper, itemIndex) {
5
+ var _a;
6
+ const item = executeFunctions.getInputData()[itemIndex];
7
+ const inputType = executeFunctions.getNodeParameter('inputType', itemIndex);
8
+ const body = {
9
+ code: `
10
+ const { PDF_COMPRESS } = require('./utils');
11
+ input = input.file || input.urls;
12
+ return PDF_COMPRESS(input);`,
13
+ returnBinary: 'true',
14
+ };
15
+ if (inputType === 'binary') {
16
+ const binaryPropertyName = executeFunctions.getNodeParameter('binaryPropertyName', itemIndex);
17
+ const binaryData = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
18
+ if (!binaryData)
19
+ throw new Error(`Binary property ${binaryPropertyName} not found`);
20
+ body.input = { file: Buffer.from(binaryData.data, 'base64') };
21
+ }
22
+ else {
23
+ const url = executeFunctions.getNodeParameter('url', itemIndex);
24
+ body.input = { urls: url };
25
+ }
26
+ const response = await apiHelper.makeRequest('n8n/compressPdf', body, true, itemIndex);
27
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePdf', itemIndex, 'output.pdf');
28
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
29
+ return { json: item.json, pairedItem: { item: itemIndex } };
30
+ }
31
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
32
+ return {
33
+ json: item.json,
34
+ binary: { data: binaryData },
35
+ pairedItem: { item: itemIndex }
36
+ };
37
+ }
38
+ exports.executeCompress = executeCompress;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeExtractPages = void 0;
4
+ async function executeExtractPages(executeFunctions, apiHelper, itemIndex) {
5
+ var _a;
6
+ const item = executeFunctions.getInputData()[itemIndex];
7
+ const inputType = executeFunctions.getNodeParameter('inputType', itemIndex);
8
+ const pageRange = executeFunctions.getNodeParameter('pageRange', itemIndex);
9
+ const body = {
10
+ code: `
11
+ const { EXTRACT_PAGES_FROM_PDF } = require('./utils');
12
+ const pdfBuffer = input.file ? Buffer.from(input.file, 'base64') : input.urls;
13
+ return EXTRACT_PAGES_FROM_PDF(pdfBuffer, input.pageRange);`,
14
+ returnBinary: 'true',
15
+ };
16
+ if (inputType === 'binary') {
17
+ const binaryPropertyName = executeFunctions.getNodeParameter('binaryPropertyName', itemIndex);
18
+ const binaryData = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
19
+ if (!binaryData)
20
+ throw new Error(`Binary property ${binaryPropertyName} not found`);
21
+ body.input = { file: Buffer.from(binaryData.data, 'base64'), pageRange };
22
+ }
23
+ else {
24
+ const url = executeFunctions.getNodeParameter('url', itemIndex);
25
+ body.input = { urls: url, pageRange };
26
+ }
27
+ const response = await apiHelper.makeRequest('n8n/extractPages', body, true, itemIndex);
28
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePdf', itemIndex, 'output.pdf');
29
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
30
+ return { json: item.json, pairedItem: { item: itemIndex } };
31
+ }
32
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
33
+ return {
34
+ json: item.json,
35
+ binary: { data: binaryData },
36
+ pairedItem: { item: itemIndex }
37
+ };
38
+ }
39
+ exports.executeExtractPages = executeExtractPages;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeFillForm = void 0;
4
+ async function executeFillForm(executeFunctions, apiHelper, itemIndex) {
5
+ var _a, _b;
6
+ const item = executeFunctions.getInputData()[itemIndex];
7
+ const binaryPropertyName = executeFunctions.getNodeParameter('binaryPropertyName', itemIndex);
8
+ const binaryData = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
9
+ if (!binaryData)
10
+ throw new Error(`Binary property ${binaryPropertyName} not found`);
11
+ const formFields = ((_b = executeFunctions.getNodeParameter('formFields', itemIndex)) === null || _b === void 0 ? void 0 : _b.field) || [];
12
+ const body = {
13
+ input: { file: Buffer.from(binaryData.data, 'base64'), fields: formFields },
14
+ code: `
15
+ const { PDF_FILL_FORM } = require('./utils');
16
+ const pdfInput = input.file;
17
+ const fieldValues = Object.fromEntries((input.fields || []).map(x => [x.name, x.value]));
18
+ return PDF_FILL_FORM(pdfInput, fieldValues);`,
19
+ returnBinary: 'true',
20
+ };
21
+ const response = await apiHelper.makeRequest('n8n/pdfFormFill', body, true, itemIndex);
22
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePdf', itemIndex, 'output.pdf');
23
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
24
+ return { json: item.json, pairedItem: { item: itemIndex } };
25
+ }
26
+ const binaryDataResult = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
27
+ return {
28
+ json: item.json,
29
+ binary: { data: binaryDataResult },
30
+ pairedItem: { item: itemIndex }
31
+ };
32
+ }
33
+ exports.executeFillForm = executeFillForm;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeGenerateInvoice = void 0;
4
+ async function executeGenerateInvoice(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const issuer = executeFunctions.getNodeParameter('issuer.issuerValues', itemIndex);
7
+ const recipient = executeFunctions.getNodeParameter('recipient.recipientValues', itemIndex);
8
+ const itemsJson = executeFunctions.getNodeParameter('itemsJson', itemIndex);
9
+ const invoiceItems = typeof itemsJson === 'string' ? JSON.parse(itemsJson) : itemsJson;
10
+ const data = { issuer, recipient, items: invoiceItems };
11
+ const body = {
12
+ input: data,
13
+ code: `
14
+ const { HTML2PDF } = require('./utils');
15
+ const nunjucks = require('nunjucks');
16
+ const fetch = require('node-fetch');
17
+ const tpl = 'https://www.customjs.space/pdf-templates/Invoice1.html';
18
+ const templateString = await fetch(tpl).then(r => r.text());
19
+ const renderedHtml = await nunjucks.renderString(templateString, { invoiceData: JSON.stringify(input) });
20
+ return HTML2PDF(renderedHtml);
21
+ `,
22
+ returnBinary: 'true',
23
+ };
24
+ const response = await apiHelper.makeRequest('n8n/invoice-generator', body, true, itemIndex);
25
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePdf', itemIndex, 'Invoice.pdf');
26
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
27
+ return { json: item.json, pairedItem: { item: itemIndex } };
28
+ }
29
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
30
+ return {
31
+ json: item.json,
32
+ binary: { data: binaryData },
33
+ pairedItem: { item: itemIndex }
34
+ };
35
+ }
36
+ exports.executeGenerateInvoice = executeGenerateInvoice;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeGetFormFields = void 0;
4
+ async function executeGetFormFields(executeFunctions, apiHelper, itemIndex) {
5
+ var _a;
6
+ const item = executeFunctions.getInputData()[itemIndex];
7
+ const binaryPropertyName = executeFunctions.getNodeParameter('binaryPropertyName', itemIndex);
8
+ const binaryData = (_a = item.binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName];
9
+ if (!binaryData)
10
+ throw new Error(`Binary property ${binaryPropertyName} not found`);
11
+ const body = {
12
+ input: { file: Buffer.from(binaryData.data, 'base64') },
13
+ code: `
14
+ const { PDF_GET_FORM_FIELD_NAMES } = require('./utils');
15
+ const pdfInput = input.file;
16
+ return PDF_GET_FORM_FIELD_NAMES(pdfInput);`,
17
+ returnBinary: 'false',
18
+ };
19
+ const response = await apiHelper.makeRequest('n8n/getFormFieldNames', body, false, itemIndex);
20
+ return { json: response, pairedItem: { item: itemIndex } };
21
+ }
22
+ exports.executeGetFormFields = executeGetFormFields;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeMerge = void 0;
4
+ async function executeMerge(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const inputType = executeFunctions.getNodeParameter('inputType', itemIndex);
7
+ const body = {
8
+ code: `
9
+ const { PDF_MERGE } = require('./utils');
10
+ input = [...input.files || [],...input.urls || []].filter(i => i);
11
+ return PDF_MERGE(input);`,
12
+ returnBinary: 'true',
13
+ };
14
+ if (inputType === 'binary') {
15
+ // Merge all items if binary
16
+ if (itemIndex > 0)
17
+ return { json: {}, pairedItem: { item: itemIndex } }; // Skip subsequent items
18
+ const items = executeFunctions.getInputData();
19
+ const files = items.map(itm => {
20
+ var _a;
21
+ const bin = (_a = itm.binary) === null || _a === void 0 ? void 0 : _a[executeFunctions.getNodeParameter('binaryPropertyName', 0)];
22
+ return bin ? Buffer.from(bin.data, 'base64') : null;
23
+ }).filter(f => f);
24
+ body.input = { files };
25
+ }
26
+ else {
27
+ const urls = executeFunctions.getNodeParameter('urls', itemIndex);
28
+ if (Array.isArray(urls)) {
29
+ body.input = { urls: urls.map(u => u.trim()) };
30
+ }
31
+ else {
32
+ body.input = { urls: urls.split(',').map(u => u.trim()) };
33
+ }
34
+ }
35
+ const response = await apiHelper.makeRequest('n8n/mergePDFs', body, true, itemIndex);
36
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePdf', itemIndex, 'output.pdf');
37
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
38
+ return { json: item.json, pairedItem: { item: itemIndex } };
39
+ }
40
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
41
+ return {
42
+ json: item.json,
43
+ binary: { data: binaryData },
44
+ pairedItem: { item: itemIndex }
45
+ };
46
+ }
47
+ exports.executeMerge = executeMerge;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executePDF = void 0;
4
+ const Compress_1 = require("./Compress");
5
+ const Merge_1 = require("./Merge");
6
+ const ExtractPages_1 = require("./ExtractPages");
7
+ const GetFormFields_1 = require("./GetFormFields");
8
+ const FillForm_1 = require("./FillForm");
9
+ const GenerateInvoice_1 = require("./GenerateInvoice");
10
+ async function executePDF(executeFunctions, apiHelper, itemIndex, operation) {
11
+ switch (operation) {
12
+ case 'compress':
13
+ return (0, Compress_1.executeCompress)(executeFunctions, apiHelper, itemIndex);
14
+ case 'merge':
15
+ return (0, Merge_1.executeMerge)(executeFunctions, apiHelper, itemIndex);
16
+ case 'extractPages':
17
+ return (0, ExtractPages_1.executeExtractPages)(executeFunctions, apiHelper, itemIndex);
18
+ case 'getFormFields':
19
+ return (0, GetFormFields_1.executeGetFormFields)(executeFunctions, apiHelper, itemIndex);
20
+ case 'fillForm':
21
+ return (0, FillForm_1.executeFillForm)(executeFunctions, apiHelper, itemIndex);
22
+ case 'generateInvoice':
23
+ return (0, GenerateInvoice_1.executeGenerateInvoice)(executeFunctions, apiHelper, itemIndex);
24
+ default:
25
+ throw new Error(`Unknown operation: ${operation}`);
26
+ }
27
+ }
28
+ exports.executePDF = executePDF;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeScrape = void 0;
4
+ async function executeScrape(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const url = executeFunctions.getNodeParameter('url', itemIndex);
7
+ const returnValueType = executeFunctions.getNodeParameter('returnValueType', itemIndex);
8
+ const debug = executeFunctions.getNodeParameter('debug', itemIndex);
9
+ const returnBinary = returnValueType === 'binary';
10
+ const body = {
11
+ input: JSON.stringify({ url }),
12
+ code: `const { SCRAPER } = require('./utils'); const payload = input; return SCRAPER(payload.url, [], "${returnValueType === 'binary' ? 'image' : 'html'}", ${debug});`,
13
+ returnBinary: returnBinary ? 'true' : 'false',
14
+ };
15
+ const response = await apiHelper.makeRequest('n8n/scraper', body, returnBinary, itemIndex);
16
+ if (returnBinary) {
17
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePng', itemIndex, 'screenshot.png');
18
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
19
+ return { json: item.json, pairedItem: { item: itemIndex } };
20
+ }
21
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
22
+ return {
23
+ json: item.json,
24
+ binary: { data: binaryData },
25
+ pairedItem: { item: itemIndex }
26
+ };
27
+ }
28
+ else {
29
+ return { json: { output: response.toString() }, pairedItem: { item: itemIndex } };
30
+ }
31
+ }
32
+ exports.executeScrape = executeScrape;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeScreenshot = void 0;
4
+ async function executeScreenshot(executeFunctions, apiHelper, itemIndex) {
5
+ const item = executeFunctions.getInputData()[itemIndex];
6
+ const url = executeFunctions.getNodeParameter('url', itemIndex);
7
+ const body = {
8
+ input: url,
9
+ code: "const { SCREENSHOT } = require('./utils'); return SCREENSHOT(input);",
10
+ returnBinary: 'true',
11
+ };
12
+ const response = await apiHelper.makeRequest('n8n/screenshot', body, true, itemIndex);
13
+ const outputFilename = executeFunctions.getNodeParameter('outputFilenamePng', itemIndex, 'screenshot.png');
14
+ if (!response || (Buffer.isBuffer(response) && response.length === 0)) {
15
+ return { json: item.json, pairedItem: { item: itemIndex } };
16
+ }
17
+ const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
18
+ return {
19
+ json: item.json,
20
+ binary: { data: binaryData },
21
+ pairedItem: { item: itemIndex }
22
+ };
23
+ }
24
+ exports.executeScreenshot = executeScreenshot;