@custom-js/n8n-nodes-pdf-toolkit 1.53.0 → 1.55.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
@@ -23,44 +23,6 @@ Use the package at [here](https://www.npmjs.com/package/@custom-js/n8n-nodes-pdf
23
23
 
24
24
  Add your Api Key and store securely
25
25
 
26
- ## Local Development with Docker
27
-
28
- To test your local changes using Docker:
29
-
30
- ### Prerequisites
31
- - Docker and Docker Compose installed
32
- - Node.js and npm installed
33
-
34
- ### Setup Steps
35
-
36
- 1. **Build the package:**
37
- ```bash
38
- npm run build
39
- ```
40
-
41
- 2. **Start n8n with Docker:**
42
- ```bash
43
- docker compose up -d
44
- ```
45
-
46
- ### Development Workflow
47
-
48
- After making code changes:
49
-
50
- ```bash
51
- npm run build && docker restart n8n-dev
52
- ```
53
-
54
- To view logs:
55
- ```bash
56
- docker logs n8n-dev -f
57
- ```
58
-
59
- To stop the environment:
60
- ```bash
61
- docker compose down
62
- ```
63
-
64
26
 
65
27
  ## Usage
66
28
 
@@ -75,20 +75,19 @@ class CompressPDF {
75
75
  async execute() {
76
76
  const items = this.getInputData();
77
77
  const returnData = [];
78
- const getFile = (field_name, i) => {
78
+ const getFile = async (field_name, i) => {
79
79
  var _a;
80
- const file = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name];
81
- if (!file) {
80
+ if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name])) {
82
81
  throw new Error(`No binary data found in field "${field_name}" for item ${i}`);
83
82
  }
84
- return Buffer.from(file.data, "base64");
83
+ return await this.helpers.getBinaryDataBuffer(i, field_name);
85
84
  };
86
85
  for (let i = 0; i < items.length; i++) {
87
86
  try {
88
87
  const credentials = await this.getCredentials("customJsApi");
89
88
  const field_name = this.getNodeParameter("field_name", i);
90
89
  const isBinary = this.getNodeParameter("resource", i) === "binary";
91
- const file = isBinary ? getFile(field_name, i) : "";
90
+ const file = isBinary ? await getFile(field_name, i) : "";
92
91
  if (!isBinary &&
93
92
  !field_name.startsWith("http://") &&
94
93
  !field_name.startsWith("https://")) {
@@ -82,13 +82,12 @@ class ExtractPages {
82
82
  async execute() {
83
83
  const items = this.getInputData();
84
84
  const returnData = [];
85
- const getFile = (field_name, i) => {
85
+ const getFile = async (field_name, i) => {
86
86
  var _a;
87
- const file = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name];
88
- if (!file) {
87
+ if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name])) {
89
88
  throw new Error(`No binary data found in field "${field_name}" for item ${i}`);
90
89
  }
91
- return Buffer.from(file.data, "base64");
90
+ return await this.helpers.getBinaryDataBuffer(i, field_name);
92
91
  };
93
92
  for (let i = 0; i < items.length; i++) {
94
93
  try {
@@ -96,7 +95,7 @@ class ExtractPages {
96
95
  const field_name = this.getNodeParameter("field_name", i);
97
96
  const pageRange = this.getNodeParameter("pageRange", i);
98
97
  const isBinary = this.getNodeParameter("resource", i) === "binary";
99
- const file = isBinary ? getFile(field_name, i) : "";
98
+ const file = isBinary ? await getFile(field_name, i) : "";
100
99
  if (!isBinary &&
101
100
  !field_name.startsWith("http://") &&
102
101
  !field_name.startsWith("https://")) {
@@ -63,20 +63,19 @@ class GetFormFieldNames {
63
63
  async execute() {
64
64
  const items = this.getInputData();
65
65
  const returnData = [];
66
- const getFile = (field_name, i) => {
66
+ const getFile = async (field_name, i) => {
67
67
  var _a;
68
- const file = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name];
69
- if (!file) {
68
+ if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name])) {
70
69
  throw new Error(`No binary data found in field "${field_name}" for item ${i}`);
71
70
  }
72
- return Buffer.from(file.data, "base64");
71
+ return await this.helpers.getBinaryDataBuffer(i, field_name);
73
72
  };
74
73
  for (let i = 0; i < items.length; i++) {
75
74
  try {
76
75
  const credentials = await this.getCredentials("customJsApi");
77
76
  const field_name = this.getNodeParameter("field_name", i);
78
77
  const isBinary = this.getNodeParameter("resource", i) === "binary";
79
- const file = isBinary ? getFile(field_name, i) : "";
78
+ const file = isBinary ? await getFile(field_name, i) : "";
80
79
  if (!isBinary) {
81
80
  throw new Error(`Invalid binary data`);
82
81
  }
@@ -79,12 +79,16 @@ class MergePdfs {
79
79
  const credentials = await this.getCredentials("customJsApi");
80
80
  const isBinary = this.getNodeParameter("resource", 0) === "binary";
81
81
  const field_name = this.getNodeParameter("field_name", 0);
82
- const files = isBinary ? items.map((item, i) => {
83
- var _a;
84
- if ((_a = item.binary) === null || _a === void 0 ? void 0 : _a.data) {
85
- return Buffer.from(item.binary.data.data, "base64");
86
- }
87
- }) : [];
82
+ let files = [];
83
+ if (isBinary) {
84
+ files = await Promise.all(items.map(async (item, i) => {
85
+ var _a;
86
+ if ((_a = item.binary) === null || _a === void 0 ? void 0 : _a.data) {
87
+ return await this.helpers.getBinaryDataBuffer(i, 'data');
88
+ }
89
+ return undefined;
90
+ }));
91
+ }
88
92
  const urls = !isBinary ? field_name : [];
89
93
  const options = {
90
94
  url: `https://e.customjs.io/__js1-${credentials.apiKey}`,
@@ -104,20 +104,19 @@ class PdfFormFill {
104
104
  var _a;
105
105
  const items = this.getInputData();
106
106
  const returnData = [];
107
- const getFile = (field_name, i) => {
107
+ const getFile = async (field_name, i) => {
108
108
  var _a;
109
- const file = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name];
110
- if (!file) {
109
+ if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name])) {
111
110
  throw new Error(`No binary data found in field "${field_name}" for item ${i}`);
112
111
  }
113
- return Buffer.from(file.data, "base64");
112
+ return await this.helpers.getBinaryDataBuffer(i, field_name);
114
113
  };
115
114
  for (let i = 0; i < items.length; i++) {
116
115
  try {
117
116
  const credentials = await this.getCredentials("customJsApi");
118
117
  const field_name = this.getNodeParameter("field_name", i);
119
118
  const isBinary = this.getNodeParameter("resource", i) === "binary";
120
- const file = isBinary ? getFile(field_name, i) : "";
119
+ const file = isBinary ? await getFile(field_name, i) : "";
121
120
  if (!isBinary) {
122
121
  throw new Error(`Invalid binary data`);
123
122
  }
@@ -75,20 +75,19 @@ class PdfToPng {
75
75
  async execute() {
76
76
  const items = this.getInputData();
77
77
  const returnData = [];
78
- const getFile = (field_name, i) => {
78
+ const getFile = async (field_name, i) => {
79
79
  var _a;
80
- const file = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name];
81
- if (!file) {
80
+ if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name])) {
82
81
  throw new Error(`No binary data found in field "${field_name}" for item ${i}`);
83
82
  }
84
- return Buffer.from(file.data, "base64");
83
+ return await this.helpers.getBinaryDataBuffer(i, field_name);
85
84
  };
86
85
  for (let i = 0; i < items.length; i++) {
87
86
  try {
88
87
  const credentials = await this.getCredentials("customJsApi");
89
88
  const field_name = this.getNodeParameter("field_name", i);
90
89
  const isBinary = this.getNodeParameter("resource", i) === "binary";
91
- const file = isBinary ? getFile(field_name, i) : "";
90
+ const file = isBinary ? await getFile(field_name, i) : "";
92
91
  if (!isBinary &&
93
92
  !field_name.startsWith("http://") &&
94
93
  !field_name.startsWith("https://")) {
@@ -67,20 +67,19 @@ class PdfToText {
67
67
  async execute() {
68
68
  const items = this.getInputData();
69
69
  const returnData = [];
70
- const getFile = (field_name, i) => {
70
+ const getFile = async (field_name, i) => {
71
71
  var _a;
72
- const file = (_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name];
73
- if (!file) {
72
+ if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[field_name])) {
74
73
  throw new Error(`No binary data found in field "${field_name}" for item ${i}`);
75
74
  }
76
- return Buffer.from(file.data, "base64");
75
+ return await this.helpers.getBinaryDataBuffer(i, field_name);
77
76
  };
78
77
  for (let i = 0; i < items.length; i++) {
79
78
  try {
80
79
  const credentials = await this.getCredentials("customJsApi");
81
80
  const field_name = this.getNodeParameter("field_name", i);
82
81
  const isBinary = this.getNodeParameter("resource", i) === "binary";
83
- const file = isBinary ? getFile(field_name, i) : "";
82
+ const file = isBinary ? await getFile(field_name, i) : "";
84
83
  if (!isBinary &&
85
84
  !field_name.startsWith("http://") &&
86
85
  !field_name.startsWith("https://")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@custom-js/n8n-nodes-pdf-toolkit",
3
- "version": "1.53.0",
3
+ "version": "1.55.0",
4
4
  "description": "This is official node for interacting with APIs from customjs.space",
5
5
  "keywords": [
6
6
  "customjs",
@@ -51,7 +51,7 @@
51
51
  "devDependencies": {
52
52
  "@types/node": "^16.11.7",
53
53
  "gulp": "^4.0.2",
54
- "typescript": "~4.8.4"
54
+ "typescript": "^5.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "n8n-workflow": "^1.64.0"