n8n-nodes-compdf 0.1.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 ADDED
@@ -0,0 +1,165 @@
1
+ # n8n-nodes-compdf
2
+
3
+ An **n8n community node** for integrating with the **ComPDF API**, allowing you to upload PDF files for asynchronous processing and query task status directly within n8n workflows.
4
+
5
+ This node is designed according to the official n8n Community Node guidelines and fully supports n8n binary data storage (`filesystem-v2`) without file corruption.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - ✅ Asynchronous PDF file processing via ComPDF API
12
+ - ✅ Task status polling until completion
13
+ - ✅ Correct handling of n8n binary data (filesystem-v2)
14
+ - ✅ Safe multipart/form-data file uploads
15
+ - ✅ Supports large files
16
+ - ✅ Compatible with n8n Community Nodes Registry
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ### Community Nodes (Recommended)
23
+
24
+ Once the node is available in the n8n Community Nodes registry:
25
+
26
+ 1. Open **n8n**
27
+ 2. Go to **Settings → Community Nodes**
28
+ 3. Search for **ComPDF**
29
+ 4. Install and restart n8n
30
+
31
+ ### Manual Installation
32
+
33
+ ```bash
34
+ npm install n8n-nodes-compdf
35
+ ```
36
+
37
+ Restart n8n after installation.
38
+
39
+ ---
40
+
41
+ ## Credentials
42
+
43
+ This node requires a **ComPDF API Key**.
44
+
45
+ ### Create Credentials
46
+
47
+ 1. Open **n8n → Credentials**
48
+ 2. Create a new credential of type **ComPDF API**
49
+ 3. Enter your API Key
50
+
51
+ The API key is securely stored by n8n and is never logged or exposed.
52
+
53
+ ---
54
+
55
+ ## Nodes
56
+
57
+ ### ComPDF
58
+
59
+ The ComPDF node supports two operations.
60
+
61
+ ---
62
+
63
+ ### Operation: File Processing (Async)
64
+
65
+ Uploads a PDF file to the ComPDF API for asynchronous processing.
66
+
67
+ #### Inputs
68
+
69
+ - **Binary file**
70
+ - Common source nodes:
71
+ - HTTP Request (Download, Response Format: File)
72
+ - Webhook
73
+ - Read Binary File
74
+
75
+ #### Parameters
76
+
77
+ - **Execute Type URL**
78
+ The specific ComPDF processing type appended to the API endpoint.
79
+
80
+ - **Parameter**
81
+ Processing parameters required by the ComPDF API.
82
+
83
+ - **Language**
84
+ Language code used by ComPDF (default: `2`).
85
+
86
+ - **Binary Property Name**
87
+ The name of the binary property containing the file (default: `data`).
88
+
89
+ #### Output
90
+
91
+ Returns a JSON response containing a `taskId` for asynchronous processing.
92
+
93
+ ---
94
+
95
+ ### Operation: Get Task Information
96
+
97
+ Queries the ComPDF API to retrieve the execution status of a previously submitted task.
98
+
99
+ #### Parameters
100
+
101
+ - **Task ID**
102
+ The task ID returned from the File Processing operation.
103
+
104
+ - **Max Wait Time (Seconds)**
105
+ Maximum time to wait for task completion before timing out (default: `600` seconds).
106
+
107
+ #### Output
108
+
109
+ Returns task status information when the task reaches one of the final states:
110
+ - `TaskFinish`
111
+ - `TaskError`
112
+ - `TaskCancel`
113
+ - `Timeout`
114
+
115
+ ---
116
+
117
+ ## Example Workflow
118
+
119
+ A typical asynchronous PDF processing workflow:
120
+
121
+ 1. **HTTP Request**
122
+ - Method: GET
123
+ - URL: PDF file URL
124
+ - Response Format: File
125
+
126
+ 2. **ComPDF – File Processing (Async)**
127
+ - Upload the PDF file to ComPDF
128
+
129
+ 3. **ComPDF – Get Task Information**
130
+ - Poll the task status until completion
131
+
132
+ 4. **HTTP Request / Write Binary File**
133
+ - Download or store the processed file
134
+
135
+ ---
136
+
137
+ ## Binary File Handling
138
+
139
+ This node uses n8n’s built-in binary data helpers and correctly supports:
140
+
141
+ - `filesystem-v2`
142
+ - Large files
143
+ - Multipart uploads without manual base64 conversion
144
+
145
+ No additional binary configuration is required.
146
+
147
+ ---
148
+
149
+ ## Compatibility
150
+
151
+ - **n8n**: >= 1.0
152
+ - **Node.js**: >= 20.19
153
+ - **Operating Systems**: Windows, macOS, Linux
154
+
155
+ ---
156
+
157
+ ## License
158
+
159
+ MIT
160
+
161
+ ---
162
+
163
+ ## Support
164
+
165
+ For bug reports or feature requests, please open an issue in the project repository.
@@ -0,0 +1,6 @@
1
+ import { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class CompdfApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ properties: INodeProperties[];
6
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompdfApi = void 0;
4
+ class CompdfApi {
5
+ constructor() {
6
+ this.name = 'compdfApi';
7
+ this.displayName = 'ComPDF API';
8
+ this.properties = [
9
+ {
10
+ displayName: 'Public API Key',
11
+ name: 'apiKey',
12
+ type: 'string',
13
+ default: '',
14
+ required: true,
15
+ },
16
+ ];
17
+ }
18
+ }
19
+ exports.CompdfApi = CompdfApi;
@@ -0,0 +1,4 @@
1
+ import { Compdf } from './nodes/Compdf/Compdf.node';
2
+ import { CompdfApi } from './credentials/CompdfApi.credentials';
3
+ export declare const nodes: (typeof Compdf)[];
4
+ export declare const credentials: (typeof CompdfApi)[];
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.credentials = exports.nodes = void 0;
4
+ const Compdf_node_1 = require("./nodes/Compdf/Compdf.node");
5
+ const CompdfApi_credentials_1 = require("./credentials/CompdfApi.credentials");
6
+ exports.nodes = [
7
+ Compdf_node_1.Compdf,
8
+ ];
9
+ exports.credentials = [
10
+ CompdfApi_credentials_1.CompdfApi,
11
+ ];
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Compdf implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Compdf = void 0;
7
+ const form_data_1 = __importDefault(require("form-data"));
8
+ class Compdf {
9
+ constructor() {
10
+ this.description = {
11
+ displayName: 'ComPDF API Integration',
12
+ name: 'ComPDF API Integration',
13
+ icon: 'file:compdf.svg',
14
+ group: ['transform'],
15
+ version: 1,
16
+ subtitle: '={{$parameter.operation}}',
17
+ description: 'Integrates with the ComPDF API to automate PDF processing tasks such as generation, editing, annotations, conversion, merging, and intelligent document extraction and parsing.',
18
+ defaults: {
19
+ name: 'ComPDF API Integration',
20
+ },
21
+ inputs: ['main'],
22
+ outputs: ['main'],
23
+ credentials: [
24
+ {
25
+ name: 'compdfApi',
26
+ required: true,
27
+ },
28
+ ],
29
+ properties: [
30
+ {
31
+ displayName: 'Operation',
32
+ name: 'operation',
33
+ type: 'options',
34
+ options: [
35
+ {
36
+ name: 'File Processing (Async)',
37
+ value: 'fileProcessing',
38
+ },
39
+ {
40
+ name: 'Get Task Information',
41
+ value: 'getTaskInfo',
42
+ },
43
+ ],
44
+ default: 'fileProcessing',
45
+ },
46
+ {
47
+ displayName: 'Execute Type URL',
48
+ name: 'executeTypeUrl',
49
+ type: 'string',
50
+ required: true,
51
+ displayOptions: {
52
+ show: {
53
+ operation: ['fileProcessing'],
54
+ },
55
+ },
56
+ default: '',
57
+ },
58
+ {
59
+ displayName: 'Binary Property',
60
+ name: 'binaryPropertyName',
61
+ type: 'string',
62
+ default: 'data',
63
+ description: 'Binary property name that contains the file',
64
+ displayOptions: {
65
+ show: {
66
+ operation: ['fileProcessing'],
67
+ },
68
+ },
69
+ },
70
+ {
71
+ displayName: 'Parameter',
72
+ name: 'parameter',
73
+ type: 'string',
74
+ required: true,
75
+ displayOptions: {
76
+ show: {
77
+ operation: ['fileProcessing'],
78
+ },
79
+ },
80
+ default: '',
81
+ },
82
+ {
83
+ displayName: 'Language',
84
+ name: 'language',
85
+ type: 'string',
86
+ default: '2',
87
+ displayOptions: {
88
+ show: {
89
+ operation: ['fileProcessing'],
90
+ },
91
+ },
92
+ },
93
+ {
94
+ displayName: 'Task ID',
95
+ name: 'taskId',
96
+ type: 'string',
97
+ required: true,
98
+ displayOptions: {
99
+ show: {
100
+ operation: ['getTaskInfo'],
101
+ },
102
+ },
103
+ default: '',
104
+ },
105
+ {
106
+ displayName: 'Max Wait Time (Seconds)',
107
+ name: 'maxWaitTime',
108
+ type: 'string',
109
+ displayOptions: {
110
+ show: {
111
+ operation: ['getTaskInfo'],
112
+ },
113
+ },
114
+ default: '600',
115
+ },
116
+ ],
117
+ };
118
+ }
119
+ async execute() {
120
+ var _a, _b, _c;
121
+ const operation = this.getNodeParameter('operation', 0);
122
+ const credentials = await this.getCredentials('compdfApi');
123
+ const apiKey = credentials.apiKey;
124
+ if (operation === 'fileProcessing') {
125
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
126
+ const binaryData = this.helpers.assertBinaryData(0, binaryPropertyName);
127
+ const fileBuffer = await this.helpers.getBinaryDataBuffer(0, binaryPropertyName);
128
+ const form = new form_data_1.default();
129
+ form.append('file', fileBuffer, {
130
+ filename: (_a = binaryData.fileName) !== null && _a !== void 0 ? _a : 'input.pdf',
131
+ contentType: (_b = binaryData.mimeType) !== null && _b !== void 0 ? _b : 'application/octet-stream',
132
+ });
133
+ form.append('parameter', this.getNodeParameter('parameter', 0));
134
+ form.append('language', this.getNodeParameter('language', 0));
135
+ const executeTypeUrl = this.getNodeParameter('executeTypeUrl', 0);
136
+ const response = await this.helpers.httpRequest({
137
+ method: 'POST',
138
+ url: `https://api-server.compdf.com/server/v2/processAsync/${executeTypeUrl}`,
139
+ headers: {
140
+ 'x-api-key': apiKey,
141
+ ...form.getHeaders(),
142
+ },
143
+ body: form,
144
+ encoding: null,
145
+ });
146
+ return [[{ json: response }]];
147
+ }
148
+ if (operation === 'getTaskInfo') {
149
+ const taskId = this.getNodeParameter('taskId', 0);
150
+ const maxWaitTime = this.getNodeParameter('maxWaitTime', 0);
151
+ const startTime = Date.now();
152
+ while (true) {
153
+ const res = await this.helpers.httpRequest({
154
+ method: 'GET',
155
+ url: 'https://api-server.compdf.com/server/v2/task/taskInfo',
156
+ headers: {
157
+ 'x-api-key': apiKey,
158
+ },
159
+ qs: { taskId },
160
+ });
161
+ const status = (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.taskStatus;
162
+ if (status === 'TaskFinish') {
163
+ return [[{ json: res.data }]];
164
+ }
165
+ if ((Date.now() - startTime) / 1000 > maxWaitTime) {
166
+ return [[{
167
+ json: {
168
+ taskId,
169
+ finalStatus: 'Timeout',
170
+ waitedSeconds: Math.floor((Date.now() - startTime) / 1000),
171
+ },
172
+ }]];
173
+ }
174
+ await new Promise((resolve) => setTimeout(resolve, 5000));
175
+ }
176
+ }
177
+ return [[]];
178
+ }
179
+ }
180
+ exports.Compdf = Compdf;
@@ -0,0 +1,14 @@
1
+ <svg width="230" height="230" viewBox="0 0 230 230" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <mask id="mask0_1_4476" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="230" height="230">
3
+ <path d="M0 6.10352e-05H229.333V229.333H0V6.10352e-05Z" fill="white"/>
4
+ </mask>
5
+ <g mask="url(#mask0_1_4476)">
6
+ <path d="M161.946 78.867C167.349 78.867 171.729 83.263 171.729 88.6843V162.319C171.729 167.74 167.349 172.136 161.946 172.136H93.4731C88.0704 172.136 83.6904 167.74 83.6904 162.319V150.864H145.644V127.956H119.558C112.354 127.956 106.516 122.095 106.516 114.866C106.516 107.636 112.354 101.775 119.558 101.775H145.644V78.867H161.946Z" fill="#03C29F"/>
7
+ </g>
8
+ <mask id="mask1_1_4476" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="230" height="230">
9
+ <path d="M0 -3.05176e-05H229.333V229.333H0V-3.05176e-05Z" fill="white"/>
10
+ </mask>
11
+ <g mask="url(#mask1_1_4476)">
12
+ <path d="M135.861 57.5949H67.3863C61.985 57.5949 57.605 61.9909 57.605 67.4123V141.047C57.605 146.47 61.985 150.864 67.3863 150.864H119.557C99.749 150.864 83.6903 134.747 83.6903 114.866C83.6903 94.9843 99.749 78.8669 119.557 78.8669H145.642V67.4123C145.642 61.9909 141.264 57.5949 135.861 57.5949Z" fill="#0471F3"/>
13
+ </g>
14
+ </svg>
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "n8n-nodes-compdf",
3
+ "version": "0.1.0",
4
+ "description": "n8n community node for ComPDF API",
5
+ "author": "ComPDF",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "n8n-community-node-package",
9
+ "n8n",
10
+ "compdf",
11
+ "pdf"
12
+ ],
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ]
18
+ }