@custom-js/n8n-nodes-pdf-toolkit-v2 0.6.0 → 0.8.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
@@ -1,6 +1,6 @@
1
1
  ![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)
2
2
 
3
- # @custom-js/n8n-nodes-pdf-toolkit
3
+ # @custom-js/n8n-nodes-pdf-toolkit-v2
4
4
 
5
5
  This is an n8n community node. It lets interact with official API of [customJS API](https://www.customjs.space/)
6
6
 
@@ -235,6 +235,11 @@ class PdfToolkit {
235
235
  value: 'update',
236
236
  action: 'Update existing HTML Page',
237
237
  },
238
+ {
239
+ name: 'Upsert HTML Page',
240
+ value: 'upsert',
241
+ action: 'Upsert HTML Page',
242
+ },
238
243
  ],
239
244
  default: 'upload',
240
245
  },
@@ -709,7 +714,7 @@ class PdfToolkit {
709
714
  displayOptions: {
710
715
  show: {
711
716
  resource: ['page'],
712
- operation: ['upload', 'update'],
717
+ operation: ['upload', 'update', 'upsert'],
713
718
  },
714
719
  },
715
720
  description: 'The name of the page.',
@@ -726,7 +731,7 @@ class PdfToolkit {
726
731
  displayOptions: {
727
732
  show: {
728
733
  resource: ['page'],
729
- operation: ['upload', 'update'],
734
+ operation: ['upload', 'update', 'upsert'],
730
735
  },
731
736
  },
732
737
  description: 'HTML content to upload.',
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeUpsert = executeUpsert;
4
+ async function executeUpsert(executeFunctions, apiHelper, itemIndex) {
5
+ const name = executeFunctions.getNodeParameter('pageName', itemIndex);
6
+ const htmlContent = executeFunctions.getNodeParameter('htmlContent', itemIndex);
7
+ const pages = await apiHelper.request('GET', 'https://api.app.customjs.io/pages/api/page', undefined, undefined, { 'customjs-origin': 'n8n/htmlPages' });
8
+ const existingPage = pages.find((p) => p.name === name);
9
+ let responseData;
10
+ if (existingPage) {
11
+ const body = {
12
+ htmlContent,
13
+ name,
14
+ };
15
+ responseData = await apiHelper.request('PUT', `https://api.app.customjs.io/pages/api/page/id/${existingPage.pageId}/update-html`, body, undefined, { 'customjs-origin': 'n8n/updateHtml' });
16
+ }
17
+ else {
18
+ const body = {
19
+ name,
20
+ htmlContent,
21
+ };
22
+ responseData = await apiHelper.request('POST', 'https://api.app.customjs.io/pages/page/upload-html', body, undefined, { 'customjs-origin': 'n8n/uploadHtml' });
23
+ }
24
+ return {
25
+ json: responseData,
26
+ pairedItem: {
27
+ item: itemIndex,
28
+ },
29
+ };
30
+ }
@@ -5,6 +5,7 @@ const n8n_workflow_1 = require("n8n-workflow");
5
5
  const Upload_1 = require("./Upload");
6
6
  const GetAll_1 = require("./GetAll");
7
7
  const Update_1 = require("./Update");
8
+ const Upsert_1 = require("./Upsert");
8
9
  async function executePage(executeFunctions, apiHelper, itemIndex, operation) {
9
10
  switch (operation) {
10
11
  case 'upload':
@@ -13,6 +14,8 @@ async function executePage(executeFunctions, apiHelper, itemIndex, operation) {
13
14
  return (0, GetAll_1.executeGetAll)(executeFunctions, apiHelper, itemIndex);
14
15
  case 'update':
15
16
  return (0, Update_1.executeUpdate)(executeFunctions, apiHelper, itemIndex);
17
+ case 'upsert':
18
+ return (0, Upsert_1.executeUpsert)(executeFunctions, apiHelper, itemIndex);
16
19
  default:
17
20
  throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), `Unknown operation: ${operation}`, { itemIndex });
18
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit-v2",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",