n8n-nodes-uvpdftool 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 UV ResearchLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # n8n-nodes-uvpdftool
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [n8n](https://n8n.io) community node for the [UV pdfTool API](https://uvpdftool.com/developers):
4
+ compress, convert, OCR and check PDFs in a workflow, on UV pdfTool's servers. It needs nothing at
5
+ run time but n8n itself.
6
+
7
+ ## Install
8
+
9
+ In n8n: **Settings → Community nodes → Install**, and enter `n8n-nodes-uvpdftool`. On a
10
+ self-hosted n8n you can also run `npm install n8n-nodes-uvpdftool` in `~/.n8n/nodes`.
11
+
12
+ Then add a **UV pdfTool API** credential with a key from the
13
+ [API keys page](https://uvpdftool.com/developers/keys); a test key is free and marks its results.
14
+
15
+ ## The node
16
+
17
+ **UV pdfTool** runs one tool for each incoming item:
18
+
19
+ | Field | What it is |
20
+ | -------------------- | ----------------------------------------------------------------------------------------------- |
21
+ | Tool | Compress PDF, Office to PDF, PDF to Word or PowerPoint, OCR, PDF to PDF/A, and seven more. |
22
+ | Input Binary Field | The binary field of the item that holds the file (`data` by default). Not asked for a web page. |
23
+ | Options | The tool's options as JSON, such as `{"method": "ghostscript", "preset": "ebook"}`. |
24
+ | Output Binary Field | Where each result goes (`data`); a second result gets a number after the name. |
25
+ | Wait Up To (Seconds) | How long to wait for the job (600). It goes on after that; the error gives its ID. |
26
+
27
+ Each result comes out as a binary field of a new item, with `jobId`, `tool`, `mode` (`live` or
28
+ `test`) and the outputs' names and sizes in its JSON. A failed job stops the workflow with the
29
+ API's reason, such as `PASSWORD_REQUIRED: The file is locked.`, unless the node is set to
30
+ continue on failure, when the item carries `error` instead. A job whose upload failed is
31
+ cancelled at once, so its task comes back.
32
+
33
+ The tools and their options are listed at <https://uvpdftool.com/developers/tools>.
@@ -0,0 +1,31 @@
1
+ /** The API key, sent as a bearer token; n8n checks it by asking for the account. */
2
+ export declare class UvPdfToolApi {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: {
7
+ displayName: string;
8
+ name: string;
9
+ type: string;
10
+ typeOptions: {
11
+ password: boolean;
12
+ };
13
+ default: string;
14
+ required: boolean;
15
+ description: string;
16
+ }[];
17
+ authenticate: {
18
+ readonly type: "generic";
19
+ readonly properties: {
20
+ readonly headers: {
21
+ readonly Authorization: "=Bearer {{$credentials.apiKey}}";
22
+ };
23
+ };
24
+ };
25
+ test: {
26
+ request: {
27
+ baseURL: string;
28
+ url: string;
29
+ };
30
+ };
31
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UvPdfToolApi = void 0;
4
+ const run_job_1 = require("../run-job");
5
+ /** The API key, sent as a bearer token; n8n checks it by asking for the account. */
6
+ class UvPdfToolApi {
7
+ name = 'uvPdfToolApi';
8
+ displayName = 'UV pdfTool API';
9
+ documentationUrl = 'https://uvpdftool.com/developers';
10
+ properties = [
11
+ {
12
+ displayName: 'API Key',
13
+ name: 'apiKey',
14
+ type: 'string',
15
+ typeOptions: { password: true },
16
+ default: '',
17
+ required: true,
18
+ description: 'A live key (uvp_live_…) or a test key (uvp_test_…), from https://uvpdftool.com/developers/keys',
19
+ },
20
+ ];
21
+ authenticate = {
22
+ type: 'generic',
23
+ properties: { headers: { Authorization: '=Bearer {{$credentials.apiKey}}' } },
24
+ };
25
+ test = { request: { baseURL: run_job_1.API_BASE, url: '/account' } };
26
+ }
27
+ exports.UvPdfToolApi = UvPdfToolApi;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The shapes of n8n's node interface that this package uses, written out here so that the
3
+ * package needs nothing of n8n's at run time and only these few types to build: n8n passes
4
+ * objects of these shapes in, and reads the classes' fields as it does any node's.
5
+ */
6
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
7
+ [key: string]: JsonValue;
8
+ };
9
+ export interface IBinaryData {
10
+ data: string;
11
+ mimeType: string;
12
+ fileName?: string;
13
+ fileExtension?: string;
14
+ }
15
+ export interface INodeExecutionData {
16
+ json: Record<string, unknown>;
17
+ binary?: Record<string, IBinaryData>;
18
+ pairedItem?: {
19
+ item: number;
20
+ };
21
+ }
22
+ export interface IHttpRequestOptions {
23
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
24
+ url: string;
25
+ headers?: Record<string, string>;
26
+ body?: unknown;
27
+ json?: boolean;
28
+ encoding?: 'arraybuffer';
29
+ returnFullResponse?: boolean;
30
+ timeout?: number;
31
+ }
32
+ export interface IExecuteFunctions {
33
+ getInputData: () => INodeExecutionData[];
34
+ getNodeParameter: (name: string, itemIndex: number, fallback?: unknown) => unknown;
35
+ continueOnFail: () => boolean;
36
+ helpers: {
37
+ httpRequest: (options: IHttpRequestOptions) => Promise<unknown>;
38
+ httpRequestWithAuthentication: (this: IExecuteFunctions, credentialsType: string, options: IHttpRequestOptions) => Promise<unknown>;
39
+ assertBinaryData: (itemIndex: number, propertyName: string) => IBinaryData;
40
+ getBinaryDataBuffer: (itemIndex: number, propertyName: string) => Promise<Buffer>;
41
+ prepareBinaryData: (data: Buffer, fileName?: string, mimeType?: string) => Promise<IBinaryData>;
42
+ };
43
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * The shapes of n8n's node interface that this package uses, written out here so that the
4
+ * package needs nothing of n8n's at run time and only these few types to build: n8n passes
5
+ * objects of these shapes in, and reads the classes' fields as it does any node's.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,87 @@
1
+ import type { IExecuteFunctions, INodeExecutionData } from '../../n8n-types';
2
+ /**
3
+ * Runs one UV pdfTool tool for each item: the file in its binary field goes up, the job runs
4
+ * on UV pdfTool's servers, and each result comes back as a binary field of a new item, with
5
+ * the job's id, tool and mode beside it.
6
+ */
7
+ export declare class UvPdfTool {
8
+ description: {
9
+ displayName: string;
10
+ name: string;
11
+ icon: string;
12
+ group: string[];
13
+ version: number;
14
+ subtitle: string;
15
+ description: string;
16
+ defaults: {
17
+ name: string;
18
+ };
19
+ inputs: string[];
20
+ outputs: string[];
21
+ usableAsTool: boolean;
22
+ credentials: {
23
+ name: string;
24
+ required: boolean;
25
+ }[];
26
+ requestDefaults: {
27
+ baseURL: string;
28
+ };
29
+ properties: ({
30
+ displayName: string;
31
+ name: string;
32
+ type: string;
33
+ noDataExpression: boolean;
34
+ options: {
35
+ name: "Compress PDF" | "Office to PDF" | "PDF to Word or PowerPoint" | "OCR (make a scan searchable)" | "PDF to PDF/A" | "Check PDF/A and PDF/UA" | "Repair PDF" | "HTML to PDF" | "Markdown to PDF" | "EPUB to PDF" | "PDF to SVG" | "Web page to PDF";
36
+ value: "compress" | "office-to-pdf" | "pdf-to-office" | "ocr" | "pdf-to-pdfa" | "pdfa-check" | "repair" | "html-to-pdf" | "markdown-to-pdf" | "epub-to-pdf" | "pdf-to-svg" | "web-to-pdf";
37
+ description: string;
38
+ }[];
39
+ default: string;
40
+ required?: undefined;
41
+ description?: undefined;
42
+ displayOptions?: undefined;
43
+ typeOptions?: undefined;
44
+ } | {
45
+ displayName: string;
46
+ name: string;
47
+ type: string;
48
+ default: string;
49
+ required: boolean;
50
+ description: string;
51
+ displayOptions: {
52
+ hide: {
53
+ tool: string[];
54
+ };
55
+ };
56
+ noDataExpression?: undefined;
57
+ options?: undefined;
58
+ typeOptions?: undefined;
59
+ } | {
60
+ displayName: string;
61
+ name: string;
62
+ type: string;
63
+ default: string;
64
+ description: string;
65
+ noDataExpression?: undefined;
66
+ options?: undefined;
67
+ required?: undefined;
68
+ displayOptions?: undefined;
69
+ typeOptions?: undefined;
70
+ } | {
71
+ displayName: string;
72
+ name: string;
73
+ type: string;
74
+ typeOptions: {
75
+ minValue: number;
76
+ maxValue: number;
77
+ };
78
+ default: number;
79
+ description: string;
80
+ noDataExpression?: undefined;
81
+ options?: undefined;
82
+ required?: undefined;
83
+ displayOptions?: undefined;
84
+ })[];
85
+ };
86
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
87
+ }
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UvPdfTool = void 0;
4
+ const run_job_1 = require("../../run-job");
5
+ const sleep = (ms) => new Promise((resolve) => {
6
+ setTimeout(resolve, ms);
7
+ });
8
+ /** The node's options, as JSON text or an object (an expression gives either). */
9
+ function optionsOf(value) {
10
+ const parsed = typeof value === 'string' ? (value.trim() === '' ? {} : JSON.parse(value)) : value;
11
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
12
+ throw new run_job_1.JobError('Options must be a JSON object, as https://uvpdftool.com/developers/tools lists them.');
13
+ }
14
+ return parsed;
15
+ }
16
+ /**
17
+ * Runs one UV pdfTool tool for each item: the file in its binary field goes up, the job runs
18
+ * on UV pdfTool's servers, and each result comes back as a binary field of a new item, with
19
+ * the job's id, tool and mode beside it.
20
+ */
21
+ class UvPdfTool {
22
+ description = {
23
+ displayName: 'UV pdfTool',
24
+ name: 'uvPdfTool',
25
+ icon: 'file:uvpdftool.png',
26
+ group: ['transform'],
27
+ version: 1,
28
+ subtitle: '={{$parameter["tool"]}}',
29
+ description: 'Compress, convert, OCR and check PDFs on UV pdfTool’s servers',
30
+ defaults: { name: 'UV pdfTool' },
31
+ inputs: ['main'],
32
+ outputs: ['main'],
33
+ usableAsTool: true,
34
+ credentials: [{ name: 'uvPdfToolApi', required: true }],
35
+ requestDefaults: { baseURL: run_job_1.API_BASE },
36
+ properties: [
37
+ {
38
+ displayName: 'Tool',
39
+ name: 'tool',
40
+ type: 'options',
41
+ noDataExpression: true,
42
+ options: run_job_1.TOOLS.map((tool) => ({
43
+ name: tool.name,
44
+ value: tool.id,
45
+ description: `Takes ${tool.takes}`,
46
+ })),
47
+ default: 'compress',
48
+ },
49
+ {
50
+ displayName: 'Input Binary Field',
51
+ name: 'binaryPropertyName',
52
+ type: 'string',
53
+ default: 'data',
54
+ required: true,
55
+ description: 'The binary field of the incoming item that holds the file',
56
+ displayOptions: { hide: { tool: ['web-to-pdf'] } },
57
+ },
58
+ {
59
+ displayName: 'Options',
60
+ name: 'options',
61
+ type: 'json',
62
+ default: '{}',
63
+ description: 'The tool’s options as JSON, for example {"method": "ghostscript", "preset": "ebook"}; each tool’s are listed at https://uvpdftool.com/developers/tools',
64
+ },
65
+ {
66
+ displayName: 'Output Binary Field',
67
+ name: 'outputPropertyName',
68
+ type: 'string',
69
+ default: 'data',
70
+ description: 'The binary field each result is put in; a second result gets a number after it',
71
+ },
72
+ {
73
+ displayName: 'Wait Up To (Seconds)',
74
+ name: 'waitSeconds',
75
+ type: 'number',
76
+ typeOptions: { minValue: 10, maxValue: 3600 },
77
+ default: 600,
78
+ description: 'How long to wait for the job; it goes on after, and the error gives its ID',
79
+ },
80
+ ],
81
+ };
82
+ async execute() {
83
+ const items = this.getInputData();
84
+ const results = [];
85
+ const http = {
86
+ api: (method, path, body) => this.helpers.httpRequestWithAuthentication.call(this, 'uvPdfToolApi', {
87
+ method,
88
+ url: `${run_job_1.API_BASE}${path}`,
89
+ json: true,
90
+ ...(body === undefined ? {} : { body }),
91
+ }),
92
+ upload: async (url, headers, data) => {
93
+ await this.helpers.httpRequest({ method: 'PUT', url, headers, body: data });
94
+ },
95
+ download: async (url) => Buffer.from((await this.helpers.httpRequest({ url, encoding: 'arraybuffer' }))),
96
+ sleep,
97
+ now: () => Date.now(),
98
+ };
99
+ for (let index = 0; index < items.length; index += 1) {
100
+ try {
101
+ const tool = this.getNodeParameter('tool', index);
102
+ const options = optionsOf(this.getNodeParameter('options', index, '{}'));
103
+ const files = [];
104
+ if ((0, run_job_1.takesFile)(tool)) {
105
+ const field = this.getNodeParameter('binaryPropertyName', index);
106
+ const binary = this.helpers.assertBinaryData(index, field);
107
+ files.push({
108
+ name: binary.fileName ?? 'document',
109
+ contentType: binary.mimeType,
110
+ data: await this.helpers.getBinaryDataBuffer(index, field),
111
+ });
112
+ }
113
+ const waitSeconds = this.getNodeParameter('waitSeconds', index, 600);
114
+ const { job, outputs } = await (0, run_job_1.runJob)(http, { tool, options, files }, waitSeconds);
115
+ const outputField = this.getNodeParameter('outputPropertyName', index, 'data');
116
+ const binary = {};
117
+ for (const [number, output] of outputs.entries()) {
118
+ binary[number === 0 ? outputField : `${outputField}${String(number + 1)}`] =
119
+ await this.helpers.prepareBinaryData(output.data, output.name, output.contentType);
120
+ }
121
+ results.push({
122
+ json: {
123
+ jobId: job.id,
124
+ tool: job.tool,
125
+ mode: job.mode,
126
+ outputs: job.outputs.map((output) => ({
127
+ name: output.name,
128
+ size: output.size,
129
+ contentType: output.contentType,
130
+ })),
131
+ },
132
+ binary,
133
+ pairedItem: { item: index },
134
+ });
135
+ }
136
+ catch (error) {
137
+ if (this.continueOnFail()) {
138
+ results.push({
139
+ json: { error: error instanceof Error ? error.message : String(error) },
140
+ pairedItem: { item: index },
141
+ });
142
+ continue;
143
+ }
144
+ throw error;
145
+ }
146
+ }
147
+ return [results];
148
+ }
149
+ }
150
+ exports.UvPdfTool = UvPdfTool;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * One job of the UV pdfTool API, from files to results: create it with the files declared,
3
+ * upload each to the link it gave, start it, wait for it to end, and fetch what it made. The
4
+ * HTTP comes from the caller, so n8n's own helpers (with its credentials) carry it.
5
+ */
6
+ export declare const API_BASE = "https://uvpdftool.com/api/v1";
7
+ /** The tools the API runs, by id, with what each takes. */
8
+ export declare const TOOLS: readonly [{
9
+ readonly id: "compress";
10
+ readonly name: "Compress PDF";
11
+ readonly takes: "PDF";
12
+ }, {
13
+ readonly id: "office-to-pdf";
14
+ readonly name: "Office to PDF";
15
+ readonly takes: "Word, Excel, PowerPoint or OpenDocument";
16
+ }, {
17
+ readonly id: "pdf-to-office";
18
+ readonly name: "PDF to Word or PowerPoint";
19
+ readonly takes: "PDF";
20
+ }, {
21
+ readonly id: "ocr";
22
+ readonly name: "OCR (make a scan searchable)";
23
+ readonly takes: "PDF";
24
+ }, {
25
+ readonly id: "pdf-to-pdfa";
26
+ readonly name: "PDF to PDF/A";
27
+ readonly takes: "PDF";
28
+ }, {
29
+ readonly id: "pdfa-check";
30
+ readonly name: "Check PDF/A and PDF/UA";
31
+ readonly takes: "PDF";
32
+ }, {
33
+ readonly id: "repair";
34
+ readonly name: "Repair PDF";
35
+ readonly takes: "PDF";
36
+ }, {
37
+ readonly id: "html-to-pdf";
38
+ readonly name: "HTML to PDF";
39
+ readonly takes: "HTML";
40
+ }, {
41
+ readonly id: "markdown-to-pdf";
42
+ readonly name: "Markdown to PDF";
43
+ readonly takes: "Markdown";
44
+ }, {
45
+ readonly id: "epub-to-pdf";
46
+ readonly name: "EPUB to PDF";
47
+ readonly takes: "EPUB";
48
+ }, {
49
+ readonly id: "pdf-to-svg";
50
+ readonly name: "PDF to SVG";
51
+ readonly takes: "PDF";
52
+ }, {
53
+ readonly id: "web-to-pdf";
54
+ readonly name: "Web page to PDF";
55
+ readonly takes: "nothing: the url option names the page";
56
+ }];
57
+ /** The one tool that takes no file: it fetches the page its options name. */
58
+ export declare const takesFile: (tool: string) => boolean;
59
+ export interface JobFile {
60
+ name: string;
61
+ contentType: string;
62
+ data: Buffer;
63
+ }
64
+ export interface ApiJob {
65
+ id: string;
66
+ tool: string;
67
+ mode: 'live' | 'test';
68
+ state: 'created' | 'queued' | 'running' | 'done' | 'failed' | 'cancelled';
69
+ error: {
70
+ code: string;
71
+ message: string;
72
+ } | null;
73
+ outputs: {
74
+ name: string;
75
+ size: number;
76
+ contentType: string;
77
+ url?: string;
78
+ }[];
79
+ }
80
+ export interface Http {
81
+ /** A call to the API with the key, JSON in and out. */
82
+ api: (method: 'GET' | 'POST' | 'DELETE', path: string, body?: unknown) => Promise<unknown>;
83
+ /** A PUT of the bytes to an upload link, with its headers and no key. */
84
+ upload: (url: string, headers: Record<string, string>, data: Buffer) => Promise<void>;
85
+ download: (url: string) => Promise<Buffer>;
86
+ sleep: (ms: number) => Promise<void>;
87
+ now: () => number;
88
+ }
89
+ /** A job that ended without a result, or a wait that ran out. */
90
+ export declare class JobError extends Error {
91
+ readonly job?: ApiJob | undefined;
92
+ constructor(message: string, job?: ApiJob | undefined);
93
+ }
94
+ export declare function runJob(http: Http, request: {
95
+ tool: string;
96
+ options: Record<string, unknown>;
97
+ files: JobFile[];
98
+ }, waitSeconds: number): Promise<{
99
+ job: ApiJob;
100
+ outputs: JobFile[];
101
+ }>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * One job of the UV pdfTool API, from files to results: create it with the files declared,
4
+ * upload each to the link it gave, start it, wait for it to end, and fetch what it made. The
5
+ * HTTP comes from the caller, so n8n's own helpers (with its credentials) carry it.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.JobError = exports.takesFile = exports.TOOLS = exports.API_BASE = void 0;
9
+ exports.runJob = runJob;
10
+ exports.API_BASE = 'https://uvpdftool.com/api/v1';
11
+ /** The tools the API runs, by id, with what each takes. */
12
+ exports.TOOLS = [
13
+ { id: 'compress', name: 'Compress PDF', takes: 'PDF' },
14
+ { id: 'office-to-pdf', name: 'Office to PDF', takes: 'Word, Excel, PowerPoint or OpenDocument' },
15
+ { id: 'pdf-to-office', name: 'PDF to Word or PowerPoint', takes: 'PDF' },
16
+ { id: 'ocr', name: 'OCR (make a scan searchable)', takes: 'PDF' },
17
+ { id: 'pdf-to-pdfa', name: 'PDF to PDF/A', takes: 'PDF' },
18
+ { id: 'pdfa-check', name: 'Check PDF/A and PDF/UA', takes: 'PDF' },
19
+ { id: 'repair', name: 'Repair PDF', takes: 'PDF' },
20
+ { id: 'html-to-pdf', name: 'HTML to PDF', takes: 'HTML' },
21
+ { id: 'markdown-to-pdf', name: 'Markdown to PDF', takes: 'Markdown' },
22
+ { id: 'epub-to-pdf', name: 'EPUB to PDF', takes: 'EPUB' },
23
+ { id: 'pdf-to-svg', name: 'PDF to SVG', takes: 'PDF' },
24
+ { id: 'web-to-pdf', name: 'Web page to PDF', takes: 'nothing: the url option names the page' },
25
+ ];
26
+ /** The one tool that takes no file: it fetches the page its options name. */
27
+ const takesFile = (tool) => tool !== 'web-to-pdf';
28
+ exports.takesFile = takesFile;
29
+ /** A job that ended without a result, or a wait that ran out. */
30
+ class JobError extends Error {
31
+ job;
32
+ constructor(message, job) {
33
+ super(message);
34
+ this.job = job;
35
+ this.name = 'JobError';
36
+ }
37
+ }
38
+ exports.JobError = JobError;
39
+ async function runJob(http, request, waitSeconds) {
40
+ const created = (await http.api('POST', '/jobs', {
41
+ tool: request.tool,
42
+ ...(Object.keys(request.options).length > 0 ? { options: request.options } : {}),
43
+ files: request.files.map((file) => ({
44
+ name: file.name,
45
+ size: file.data.length,
46
+ contentType: file.contentType,
47
+ })),
48
+ }));
49
+ const id = created.job.id;
50
+ try {
51
+ for (const [index, upload] of created.uploads.entries()) {
52
+ const file = request.files[index];
53
+ if (!file)
54
+ throw new JobError(`No file for upload ${String(index + 1)}.`);
55
+ await http.upload(upload.url, upload.headers, file.data);
56
+ }
57
+ await http.api('POST', `/jobs/${id}/start`);
58
+ }
59
+ catch (error) {
60
+ // A job without its files would wait twenty minutes for them: end it, and its task returns.
61
+ await http.api('DELETE', `/jobs/${id}`).catch(() => undefined);
62
+ throw error;
63
+ }
64
+ const deadline = http.now() + waitSeconds * 1000;
65
+ for (;;) {
66
+ const { job } = (await http.api('GET', `/jobs/${id}`));
67
+ if (job.state === 'done') {
68
+ const outputs = [];
69
+ for (const output of job.outputs) {
70
+ if (!output.url)
71
+ throw new JobError(`${output.name} has no download link.`, job);
72
+ outputs.push({
73
+ name: output.name,
74
+ contentType: output.contentType,
75
+ data: await http.download(output.url),
76
+ });
77
+ }
78
+ return { job, outputs };
79
+ }
80
+ if (job.state === 'failed' || job.state === 'cancelled') {
81
+ throw new JobError(job.error ? `${job.error.code}: ${job.error.message}` : `The job ended ${job.state}.`, job);
82
+ }
83
+ if (http.now() > deadline) {
84
+ throw new JobError(`Job ${id} was still ${job.state} after ${String(waitSeconds)} seconds; it goes on, and GET /jobs/${id} has its result.`, job);
85
+ }
86
+ await http.sleep(2_000);
87
+ }
88
+ }
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "n8n-nodes-uvpdftool",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "An n8n node for the UV pdfTool API: compress, convert, OCR and check PDFs in a workflow, on UV pdfTool's servers.",
5
+ "license": "MIT",
6
+ "author": "UV ResearchLabs",
7
+ "homepage": "https://uvpdftool.com/developers",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/uvresearchlab/UV-pdfTool",
11
+ "directory": "packages/n8n"
12
+ },
13
+ "keywords": [
14
+ "n8n-community-node-package",
15
+ "pdf",
16
+ "compress",
17
+ "ocr",
18
+ "convert",
19
+ "pdfa",
20
+ "uvpdftool"
21
+ ],
22
+ "engines": {
23
+ "node": ">=18.3"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "n8n": {
31
+ "n8nNodesApiVersion": 1,
32
+ "credentials": [
33
+ "dist/credentials/UvPdfToolApi.credentials.js"
34
+ ],
35
+ "nodes": [
36
+ "dist/nodes/UvPdfTool/UvPdfTool.node.js"
37
+ ]
38
+ },
39
+ "devDependencies": {
40
+ "@eslint/js": "^10.0.1",
41
+ "@types/node": "^24.13.6",
42
+ "eslint": "^10.11.0",
43
+ "typescript": "~6.0.3",
44
+ "typescript-eslint": "^8.70.0",
45
+ "vitest": "^4.1.12"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-icons.mjs",
49
+ "test": "vitest run",
50
+ "lint": "eslint .",
51
+ "typecheck": "tsc -p tsconfig.json"
52
+ }
6
53
  }