@custom-js/n8n-nodes-pdf-toolkit-v2 0.5.0 → 0.6.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 CHANGED
@@ -151,4 +151,12 @@ Add your Api Key and store securely
151
151
  - Add the **TOON to JSON** node to your workflow.
152
152
  - Configure your CustomJS API credentials.
153
153
  - Input your TOON data.
154
- - Execute the workflow to convert TOON to JSON format.
154
+ - Execute the workflow to convert TOON to JSON format.
155
+
156
+ ### Host HTML Page node
157
+
158
+ - Add the **Host HTML Page** node to your workflow.
159
+ - Configure your CustomJS API credentials.
160
+ - Input your HTML content.
161
+ - Execute the workflow to host the HTML page.
162
+ - You can then access the hosted page via the provided URL.
@@ -7,6 +7,7 @@ const Convert_1 = require("./modules/Convert");
7
7
  const PDF_1 = require("./modules/PDF");
8
8
  const Web_1 = require("./modules/Web");
9
9
  const Data_1 = require("./modules/Data");
10
+ const Page_1 = require("./modules/Page");
10
11
  class PdfToolkit {
11
12
  constructor() {
12
13
  this.description = {
@@ -50,6 +51,10 @@ class PdfToolkit {
50
51
  name: 'Data',
51
52
  value: 'data',
52
53
  },
54
+ {
55
+ name: 'HTML Hosting',
56
+ value: 'page',
57
+ },
53
58
  ],
54
59
  default: 'convert',
55
60
  },
@@ -203,6 +208,36 @@ class PdfToolkit {
203
208
  ],
204
209
  default: 'jsonSelect',
205
210
  },
211
+ // Operations for Page Resource
212
+ {
213
+ displayName: 'Operation',
214
+ name: 'operation',
215
+ type: 'options',
216
+ noDataExpression: true,
217
+ displayOptions: {
218
+ show: {
219
+ resource: ['page'],
220
+ },
221
+ },
222
+ options: [
223
+ {
224
+ name: 'Get HTML Pages',
225
+ value: 'getAll',
226
+ action: 'Get HTML Pages',
227
+ },
228
+ {
229
+ name: 'Host HTML Page',
230
+ value: 'upload',
231
+ action: 'Upload new HTML Page',
232
+ },
233
+ {
234
+ name: 'Update HTML Page',
235
+ value: 'update',
236
+ action: 'Update existing HTML Page',
237
+ },
238
+ ],
239
+ default: 'upload',
240
+ },
206
241
  // --- Inputs ---
207
242
  // Input Type (Binary/URL)
208
243
  {
@@ -621,6 +656,81 @@ class PdfToolkit {
621
656
  },
622
657
  },
623
658
  },
659
+ // HTML to PDF Properties
660
+ {
661
+ displayName: 'PDF Page Width (mm)',
662
+ name: 'pdfWidthMm',
663
+ type: 'number',
664
+ default: 210,
665
+ required: false,
666
+ displayOptions: {
667
+ show: {
668
+ resource: ['convert'],
669
+ operation: ['htmlToPdf'],
670
+ },
671
+ },
672
+ description: 'Width of the PDF page in millimeters.',
673
+ },
674
+ {
675
+ displayName: 'PDF Page Height (mm)',
676
+ name: 'pdfHeightMm',
677
+ type: 'number',
678
+ default: 297,
679
+ required: false,
680
+ displayOptions: {
681
+ show: {
682
+ resource: ['convert'],
683
+ operation: ['htmlToPdf'],
684
+ },
685
+ },
686
+ description: 'Height of the PDF page in millimeters.',
687
+ },
688
+ // --- Page Properties ---
689
+ {
690
+ displayName: 'Page ID',
691
+ name: 'pageId',
692
+ type: 'string',
693
+ default: '',
694
+ required: true,
695
+ displayOptions: {
696
+ show: {
697
+ resource: ['page'],
698
+ operation: ['update'],
699
+ },
700
+ },
701
+ description: 'The ID of the page to update.',
702
+ },
703
+ {
704
+ displayName: 'Page Name',
705
+ name: 'pageName',
706
+ type: 'string',
707
+ default: '',
708
+ required: false,
709
+ displayOptions: {
710
+ show: {
711
+ resource: ['page'],
712
+ operation: ['upload', 'update'],
713
+ },
714
+ },
715
+ description: 'The name of the page.',
716
+ },
717
+ {
718
+ displayName: 'HTML Content',
719
+ name: 'htmlContent',
720
+ type: 'string',
721
+ typeOptions: {
722
+ rows: 10,
723
+ },
724
+ default: '',
725
+ required: true,
726
+ displayOptions: {
727
+ show: {
728
+ resource: ['page'],
729
+ operation: ['upload', 'update'],
730
+ },
731
+ },
732
+ description: 'HTML content to upload.',
733
+ },
624
734
  // Output Filename (PDF)
625
735
  {
626
736
  displayName: 'Output Filename',
@@ -706,10 +816,18 @@ class PdfToolkit {
706
816
  else if (resource === 'data') {
707
817
  result = await (0, Data_1.executeData)(this, apiHelper, i, operation);
708
818
  }
819
+ else if (resource === 'page') {
820
+ result = await (0, Page_1.executePage)(this, apiHelper, i, operation);
821
+ }
709
822
  else {
710
823
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown resource: ${resource}`, { itemIndex: i });
711
824
  }
712
- returnData.push(result);
825
+ if (Array.isArray(result)) {
826
+ returnData.push(...result);
827
+ }
828
+ else {
829
+ returnData.push(result);
830
+ }
713
831
  }
714
832
  catch (error) {
715
833
  if (this.continueOnFail()) {
@@ -24,5 +24,17 @@ class ApiHelper {
24
24
  }
25
25
  return this.executeFunctions.helpers.httpRequestWithAuthentication.call(this.executeFunctions, 'customJsApi', options);
26
26
  }
27
+ async request(method, url, body, qs, headers = {}, option = {}) {
28
+ const options = {
29
+ url,
30
+ method,
31
+ body,
32
+ qs,
33
+ headers,
34
+ json: true,
35
+ ...option,
36
+ };
37
+ return this.executeFunctions.helpers.httpRequestWithAuthentication.call(this.executeFunctions, 'customJsApi', options);
38
+ }
27
39
  }
28
40
  exports.ApiHelper = ApiHelper;
@@ -4,9 +4,11 @@ exports.executeHtmlToPdf = executeHtmlToPdf;
4
4
  async function executeHtmlToPdf(executeFunctions, apiHelper, itemIndex) {
5
5
  const item = executeFunctions.getInputData()[itemIndex];
6
6
  const html = executeFunctions.getNodeParameter('html', itemIndex);
7
+ const pdfWidthMm = executeFunctions.getNodeParameter('pdfWidthMm', itemIndex, 210);
8
+ const pdfHeightMm = executeFunctions.getNodeParameter('pdfHeightMm', itemIndex, 297);
7
9
  const body = {
8
10
  input: html,
9
- code: "const { HTML2PDF } = require('./utils'); return HTML2PDF(input)",
11
+ code: `const { HTML2PDF } = require('./utils'); return HTML2PDF(input, {"pdfWidthMm": ${pdfWidthMm}, "pdfHeightMm": ${pdfHeightMm} })`,
10
12
  returnBinary: 'true',
11
13
  };
12
14
  const response = await apiHelper.makeRequest('n8n/generatePDF', body, true, itemIndex);
@@ -9,6 +9,6 @@ async function executeJsonToToon(executeFunctions, apiHelper, itemIndex) {
9
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
10
  returnBinary: 'false',
11
11
  };
12
- const response = await apiHelper.makeRequest('make/jsonToToon', body, false, itemIndex);
12
+ const response = await apiHelper.makeRequest('n8n/jsonToToon', body, false, itemIndex);
13
13
  return { json: { toon: response }, pairedItem: { item: itemIndex } };
14
14
  }
@@ -21,5 +21,10 @@ async function executePdfToText(executeFunctions, apiHelper, itemIndex) {
21
21
  body.input = { urls: url };
22
22
  }
23
23
  const response = await apiHelper.makeRequest('n8n/pdfToText', body, false, itemIndex);
24
- return { json: response, pairedItem: { item: itemIndex } };
24
+ return {
25
+ json: {
26
+ output: response.toString(),
27
+ },
28
+ pairedItem: { item: itemIndex }
29
+ };
25
30
  }
@@ -9,6 +9,6 @@ async function executeToonToJson(executeFunctions, apiHelper, itemIndex) {
9
9
  code: "const toon = require('./utils/toon-cjs'); return await toon.decode(input);",
10
10
  returnBinary: 'false',
11
11
  };
12
- const response = await apiHelper.makeRequest('make/toonToJson', body, false, itemIndex);
13
- return { json: response, pairedItem: { item: itemIndex } };
12
+ const response = await apiHelper.makeRequest('n8n/toonToJson', body, false, itemIndex);
13
+ return { json: { json: response }, pairedItem: { item: itemIndex } };
14
14
  }
@@ -10,6 +10,6 @@ async function executeJsonSelect(executeFunctions, apiHelper, itemIndex) {
10
10
  code: "const { JSONPath } = require('jsonpath-plus'); return JSONPath({ path: input.path, json: JSON.parse(input.json) });",
11
11
  returnBinary: 'false',
12
12
  };
13
- const response = await apiHelper.makeRequest('make/jsonSelector', body, false, itemIndex);
13
+ const response = await apiHelper.makeRequest('n8n/jsonSelector', body, false, itemIndex);
14
14
  return { json: { result: response }, pairedItem: { item: itemIndex } };
15
15
  }
@@ -13,6 +13,6 @@ async function executeRegex(executeFunctions, apiHelper, itemIndex) {
13
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
14
  returnBinary: 'false',
15
15
  };
16
- const response = await apiHelper.makeRequest('make/regexTool', body, false, itemIndex);
16
+ const response = await apiHelper.makeRequest('n8n/regexTool', body, false, itemIndex);
17
17
  return { json: { result: response }, pairedItem: { item: itemIndex } };
18
18
  }
@@ -14,5 +14,5 @@ async function executeGetFormFields(executeFunctions, apiHelper, itemIndex) {
14
14
  returnBinary: 'false',
15
15
  };
16
16
  const response = await apiHelper.makeRequest('n8n/getFormFieldNames', body, false, itemIndex);
17
- return { json: response, pairedItem: { item: itemIndex } };
17
+ return { json: { output: response }, pairedItem: { item: itemIndex } };
18
18
  }
@@ -42,7 +42,7 @@ async function executeMerge(executeFunctions, apiHelper, itemIndex) {
42
42
  }
43
43
  const binaryData = await executeFunctions.helpers.prepareBinaryData(response, outputFilename);
44
44
  return {
45
- json: item.json,
45
+ json: {},
46
46
  binary: { data: binaryData },
47
47
  pairedItem: { item: itemIndex }
48
48
  };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeGetAll = executeGetAll;
4
+ async function executeGetAll(executeFunctions, apiHelper, itemIndex) {
5
+ const responseData = await apiHelper.request('GET', 'https://api.app.customjs.io/pages/api/page', undefined, undefined, { 'customjs-origin': 'n8n/htmlPages' });
6
+ return responseData.map((item) => ({
7
+ json: item,
8
+ pairedItem: {
9
+ item: itemIndex,
10
+ },
11
+ }));
12
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeUpdate = executeUpdate;
4
+ async function executeUpdate(executeFunctions, apiHelper, itemIndex) {
5
+ const pageId = executeFunctions.getNodeParameter('pageId', itemIndex);
6
+ const htmlContent = executeFunctions.getNodeParameter('htmlContent', itemIndex);
7
+ const name = executeFunctions.getNodeParameter('pageName', itemIndex);
8
+ const body = {
9
+ htmlContent,
10
+ };
11
+ if (name) {
12
+ body.name = name;
13
+ }
14
+ const responseData = await apiHelper.request('PUT', `https://api.app.customjs.io/pages/api/page/id/${pageId}/update-html`, body, undefined, { 'customjs-origin': 'n8n/updateHtml' });
15
+ return {
16
+ json: responseData,
17
+ pairedItem: {
18
+ item: itemIndex,
19
+ },
20
+ };
21
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeUpload = executeUpload;
4
+ async function executeUpload(executeFunctions, apiHelper, itemIndex) {
5
+ const name = executeFunctions.getNodeParameter('pageName', itemIndex);
6
+ const htmlContent = executeFunctions.getNodeParameter('htmlContent', itemIndex);
7
+ const body = {
8
+ name,
9
+ htmlContent,
10
+ };
11
+ const responseData = await apiHelper.request('POST', 'https://api.app.customjs.io/pages/page/upload-html', body, undefined, { 'customjs-origin': 'n8n/uploadHtml' });
12
+ return {
13
+ json: responseData,
14
+ pairedItem: {
15
+ item: itemIndex,
16
+ },
17
+ };
18
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executePage = executePage;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const Upload_1 = require("./Upload");
6
+ const GetAll_1 = require("./GetAll");
7
+ const Update_1 = require("./Update");
8
+ async function executePage(executeFunctions, apiHelper, itemIndex, operation) {
9
+ switch (operation) {
10
+ case 'upload':
11
+ return (0, Upload_1.executeUpload)(executeFunctions, apiHelper, itemIndex);
12
+ case 'getAll':
13
+ return (0, GetAll_1.executeGetAll)(executeFunctions, apiHelper, itemIndex);
14
+ case 'update':
15
+ return (0, Update_1.executeUpdate)(executeFunctions, apiHelper, itemIndex);
16
+ default:
17
+ throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), `Unknown operation: ${operation}`, { itemIndex });
18
+ }
19
+ }
@@ -10,5 +10,5 @@ async function executeSslCheck(executeFunctions, apiHelper, itemIndex) {
10
10
  returnBinary: 'false',
11
11
  };
12
12
  const response = await apiHelper.makeRequest('n8n/sslchecker', body, false, itemIndex);
13
- return { json: response, pairedItem: { item: itemIndex } };
13
+ return { json: { output: response }, pairedItem: { item: itemIndex } };
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit-v2",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",