From f6fffc5c7cc86d1a65051b2cf0601548c3329110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 18 Feb 2026 12:14:53 +0100 Subject: [PATCH 1/4] :arrow_up: bump commander and file-type --- CHANGELOG.md | 8 ++-- package-lock.json | 115 +++++++++++++++++++--------------------------- package.json | 4 +- src/v2/cli.ts | 30 ++++++------ 4 files changed, 69 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7afa9594..a22ffa98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,19 @@ # CHANGELOG -## 5.0.0-rc2 - 2026-01-18 +## v5.0.0-rc2 - 2026-01-18 ### Changes * :sparkles: add Job to inference responses ### Fixes * :bug: fix for bin scripts -## 5.0.0-rc1 - 2026-01-17 +## v5.0.0-rc1 - 2026-01-17 ### Changes * :boom: drop support for node.js 18 * :boom: :recycle: separate polling options -## 5.0.0-alpha2 - 2026-01-16 +## v5.0.0-alpha2 - 2026-01-16 ### Changes * :recycle: use node test methods * :recycle: v1 ocr word should be a class @@ -21,7 +21,7 @@ * :bug: fix for optional node-poppler -## 5.0.0-alpha1 - 2026-01-13 +## v5.0.0-alpha1 - 2026-01-13 ### :boom: :recycle: base for v5 * :arrow_up: update file-type * :recycle: migrate to ES modules (node18) diff --git a/package-lock.json b/package-lock.json index 804d68a3..d45fff82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "5.0.0-rc2", "license": "MIT", "dependencies": { - "commander": "~9.4.1", - "file-type": "^19.6.0", + "commander": "^14.0.3", + "file-type": "^21.3.0", "tmp": "^0.2.3", "tslib": "^2.8.1", "undici": "^6.23.0" @@ -1356,12 +1356,6 @@ "node": ">=14" } }, - "node_modules/@sec-ant/readable-stream": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", - "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==", - "license": "MIT" - }, "node_modules/@shikijs/engine-oniguruma": { "version": "3.22.0", "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.22.0.tgz", @@ -1424,6 +1418,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@tokenizer/inflate": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@tokenizer/inflate/-/inflate-0.4.1.tgz", + "integrity": "sha512-2mAv+8pkG6GIZiF1kNg1jAjh27IDxEPKwdGul3snfztFerfPGI1LjDezZp3i7BElXompqEtPmoPx6c2wgtWsOA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "token-types": "^6.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, "node_modules/@tokenizer/token": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", @@ -2071,12 +2082,12 @@ } }, "node_modules/commander": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz", - "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", "license": "MIT", "engines": { - "node": "^12.20.0 || >=14" + "node": ">=20" } }, "node_modules/comment-parser": { @@ -2122,7 +2133,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -2655,18 +2665,18 @@ } }, "node_modules/file-type": { - "version": "19.6.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-19.6.0.tgz", - "integrity": "sha512-VZR5I7k5wkD0HgFnMsq5hOsSc710MJMu5Nc5QYsbe38NN5iPV/XTObYLc/cpttRTf6lX538+5uO1ZQRhYibiZQ==", + "version": "21.3.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-21.3.0.tgz", + "integrity": "sha512-8kPJMIGz1Yt/aPEwOsrR97ZyZaD1Iqm8PClb1nYFclUCkBi0Ma5IsYNQzvSFS9ib51lWyIw5mIT9rWzI/xjpzA==", "license": "MIT", "dependencies": { - "get-stream": "^9.0.1", - "strtok3": "^9.0.1", - "token-types": "^6.0.0", - "uint8array-extras": "^1.3.0" + "@tokenizer/inflate": "^0.4.1", + "strtok3": "^10.3.4", + "token-types": "^6.1.1", + "uint8array-extras": "^1.4.0" }, "engines": { - "node": ">=18" + "node": ">=20" }, "funding": { "url": "https://github.com/sindresorhus/file-type?sponsor=1" @@ -2775,22 +2785,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-stream": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", - "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==", - "license": "MIT", - "dependencies": { - "@sec-ant/readable-stream": "^0.4.1", - "is-stream": "^4.0.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/get-tsconfig": { "version": "4.13.6", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.6.tgz", @@ -3060,18 +3054,6 @@ "node": ">=8" } }, - "node_modules/is-stream": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz", - "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", @@ -3385,7 +3367,6 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/mylas": { @@ -3608,19 +3589,6 @@ "node": ">=12.0.0" } }, - "node_modules/peek-readable": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.4.2.tgz", - "integrity": "sha512-peBp3qZyuS6cNIJ2akRNG1uo1WJ1d0wTxg/fxMdZ0BqCVhx242bSFHM9eNqflfJVS9SsgkzgT/1UgnsurBOTMg==", - "license": "MIT", - "engines": { - "node": ">=14.16" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Borewit" - } - }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -4105,16 +4073,15 @@ } }, "node_modules/strtok3": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-9.1.1.tgz", - "integrity": "sha512-FhwotcEqjr241ZbjFzjlIYg6c5/L/s4yBGWSMvJ9UoExiSqL+FnFA/CaeZx17WGaZMS/4SOZp8wH18jSS4R4lw==", + "version": "10.3.4", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-10.3.4.tgz", + "integrity": "sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg==", "license": "MIT", "dependencies": { - "@tokenizer/token": "^0.3.0", - "peek-readable": "^5.3.1" + "@tokenizer/token": "^0.3.0" }, "engines": { - "node": ">=16" + "node": ">=18" }, "funding": { "type": "github", @@ -4268,6 +4235,16 @@ "fsevents": "~2.3.2" } }, + "node_modules/tsc-alias/node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/tsc-alias/node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", diff --git a/package.json b/package.json index 98b5f500..7a2245ad 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "node": ">= 20.1" }, "dependencies": { - "commander": "~9.4.1", - "file-type": "^19.6.0", + "commander": "^14.0.3", + "file-type": "^21.3.0", "tmp": "^0.2.3", "tslib": "^2.8.1", "undici": "^6.23.0" diff --git a/src/v2/cli.ts b/src/v2/cli.ts index fc7fa8fd..22e69f8c 100644 --- a/src/v2/cli.ts +++ b/src/v2/cli.ts @@ -12,6 +12,12 @@ import { Split, } from "@/v2/product/index.js"; +interface CliProduct { + name: string; + description: string; + productClass: typeof BaseProduct; +} + const program = new Command(); // @@ -35,13 +41,11 @@ async function enqueueAndGetInference( const response = await mindeeClient.enqueueAndGetResult( product, inputSource, + { modelId: options.model }, { - modelId: options.model, - pollingOptions: { - initialDelaySec: 2, - delaySec: 1.5, - maxRetries: 80, - } + initialDelaySec: 2, + delaySec: 1.5, + maxRetries: 80, } ); if (!response.inference) { @@ -76,12 +80,12 @@ export function cli() { .option("-d, --debug", "high verbosity mode") .option("-k, --api-key ", "your Mindee API key"); - const inferenceTypes = [ - { name: "extraction", description: "Extract data from a document.", product: Extraction }, - { name: "crop", description: "Crop a document.", product: Crop }, - { name: "split", description: "Split a document into pages.", product: Split }, - { name: "ocr", description: "Read text from a document.", product: Ocr }, - { name: "classification", description: "Classify a document.", product: Classification }, + const inferenceTypes: CliProduct[] = [ + { name: "extraction", description: "Extract data from a document.", productClass: Extraction }, + { name: "crop", description: "Crop a document.", productClass: Crop }, + { name: "split", description: "Split a document into pages.", productClass: Split }, + { name: "ocr", description: "Read text from a document.", productClass: Ocr }, + { name: "classification", description: "Classify a document.", productClass: Classification }, ]; for (const inference of inferenceTypes) { @@ -95,7 +99,7 @@ export function cli() { options: OptionValues, ) { const allOptions = { ...program.opts(), ...options }; - return enqueueAndGetInference(inference.product, inputPath, allOptions); + return enqueueAndGetInference(inference.productClass, inputPath, allOptions); }); } From 423681aba2d0b397840b43ba27a76a4cf48a4621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 18 Feb 2026 13:38:50 +0100 Subject: [PATCH 2/4] :bug: fix for seconds vs milliseconds in request options --- src/http/apiCore.ts | 6 +++--- src/http/baseSettings.ts | 8 +++++--- src/v1/http/endpoint.ts | 8 ++++---- src/v1/http/workflowEndpoint.ts | 2 +- src/v2/http/mindeeApiV2.ts | 6 +++--- tests/v1/api/endpoint.spec.ts | 4 ++-- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/http/apiCore.ts b/src/http/apiCore.ts index 98819997..45b740a8 100644 --- a/src/http/apiCore.ts +++ b/src/http/apiCore.ts @@ -2,13 +2,13 @@ import { logger } from "@/logger.js"; import { request, Dispatcher } from "undici"; import { InputSource, PageOptions, LocalInputSource } from "@/input/index.js"; -export const TIMEOUT_DEFAULT: number = 120; +export const TIMEOUT_SECS_DEFAULT: number = 120; export interface RequestOptions { hostname: string; path: string; method: any; - timeout: number; + timeoutSecs: number; headers: any; body?: any; } @@ -47,7 +47,7 @@ export async function sendRequestAndReadResponse( { method: options.method, headers: options.headers, - bodyTimeout: options.timeout, + headersTimeout: options.timeoutSecs * 1000, body: options.body, throwOnError: false, dispatcher: dispatcher diff --git a/src/http/baseSettings.ts b/src/http/baseSettings.ts index ba275b36..5a922435 100644 --- a/src/http/baseSettings.ts +++ b/src/http/baseSettings.ts @@ -1,7 +1,7 @@ import { Dispatcher, getGlobalDispatcher } from "undici"; import packageJson from "../../package.json" with { type: "json" }; import * as os from "os"; -import { TIMEOUT_DEFAULT } from "./apiCore.js"; +import { TIMEOUT_SECS_DEFAULT } from "./apiCore.js"; export interface MindeeApiConstructorProps { apiKey?: string; @@ -11,7 +11,7 @@ export interface MindeeApiConstructorProps { export abstract class BaseSettings { apiKey: string; hostname: string; - timeout: number; + timeoutSecs: number; dispatcher: Dispatcher; protected constructor(apiKey?: string, dispatcher?: Dispatcher) { @@ -22,7 +22,9 @@ export abstract class BaseSettings { } this.dispatcher = dispatcher ?? getGlobalDispatcher(); this.hostname = this.hostnameFromEnv(); - this.timeout = process.env.MINDEE_REQUEST_TIMEOUT ? parseInt(process.env.MINDEE_REQUEST_TIMEOUT) : TIMEOUT_DEFAULT; + this.timeoutSecs = process.env.MINDEE_REQUEST_TIMEOUT + ? parseInt(process.env.MINDEE_REQUEST_TIMEOUT) + : TIMEOUT_SECS_DEFAULT; } protected getUserAgent(): string { diff --git a/src/v1/http/endpoint.ts b/src/v1/http/endpoint.ts index d74cf2ca..97add294 100644 --- a/src/v1/http/endpoint.ts +++ b/src/v1/http/endpoint.ts @@ -213,7 +213,7 @@ export class Endpoint { headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: path, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, body: form, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); @@ -273,7 +273,7 @@ export class Endpoint { headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: `${this.urlRoot}/documents/queue/${queueId}`, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); } @@ -288,7 +288,7 @@ export class Endpoint { headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: `${this.urlRoot}/documents/${documentId}`, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); } @@ -305,7 +305,7 @@ export class Endpoint { hostname: this.settings.hostname, path: `/v1/documents/${documentId}/feedback`, body: JSON.stringify(feedback), - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); } diff --git a/src/v1/http/workflowEndpoint.ts b/src/v1/http/workflowEndpoint.ts index 7a4b5959..d0ba1aa4 100644 --- a/src/v1/http/workflowEndpoint.ts +++ b/src/v1/http/workflowEndpoint.ts @@ -110,7 +110,7 @@ export class WorkflowEndpoint { headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: path, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, body: form, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); diff --git a/src/v2/http/mindeeApiV2.ts b/src/v2/http/mindeeApiV2.ts index db75a16b..a44a08be 100644 --- a/src/v2/http/mindeeApiV2.ts +++ b/src/v2/http/mindeeApiV2.ts @@ -133,7 +133,7 @@ export class MindeeApiV2 { hostname: this.settings.hostname, path: path, body: form, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); } @@ -144,7 +144,7 @@ export class MindeeApiV2 { headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: `/v2/jobs/${jobId}`, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); } @@ -162,7 +162,7 @@ export class MindeeApiV2 { headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: `/v2/products/${slug}/results/${inferenceId}`, - timeout: this.settings.timeout, + timeoutSecs: this.settings.timeoutSecs, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); } diff --git a/tests/v1/api/endpoint.spec.ts b/tests/v1/api/endpoint.spec.ts index 666a66d3..88b73e3f 100644 --- a/tests/v1/api/endpoint.spec.ts +++ b/tests/v1/api/endpoint.spec.ts @@ -118,7 +118,7 @@ describe ("Endpoint parameters" , () => { "dummy-account" ); assert.strictEqual(customEndpoint.version, "1"); - assert.strictEqual(customEndpoint.settings.timeout, 120); + assert.strictEqual(customEndpoint.settings.timeoutSecs, 120); assert.strictEqual(customEndpoint.settings.hostname, "api.mindee.net"); assert.strictEqual(customEndpoint.settings.apiKey, "dummy-api-key"); }); @@ -134,7 +134,7 @@ describe ("Endpoint parameters" , () => { "dummy-account" ); assert.strictEqual(customEndpoint.version, "1"); - assert.strictEqual(customEndpoint.settings.timeout, 30); + assert.strictEqual(customEndpoint.settings.timeoutSecs, 30); assert.strictEqual(customEndpoint.settings.hostname, "v1-endpoint-host"); assert.strictEqual(customEndpoint.settings.apiKey, "dummy-key"); From 3b2cb33a9f4a4f57da3e1c319b9ca76598b0aca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 18 Feb 2026 13:54:20 +0100 Subject: [PATCH 3/4] :arrow_up: bump PDF libs --- package-lock.json | 50 ++++++++++++++++++++++++++++++++++++++++------- package.json | 6 +++--- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index d45fff82..e7556c96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,8 +37,8 @@ "node": ">= 20.1" }, "optionalDependencies": { - "@cantoo/pdf-lib": "^2.3.2", - "node-poppler": "^7.2.4", + "@cantoo/pdf-lib": "^2.5.3", + "node-poppler": "^9.1.1", "pdf.js-extract": "^0.2.1", "sharp": "~0.34.5" } @@ -2914,6 +2914,19 @@ ], "license": "MIT" }, + "node_modules/ice-barrage": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ice-barrage/-/ice-barrage-1.0.0.tgz", + "integrity": "sha512-xdp/aktysCDxBasbht01dMC2oSgmM4PrQITSCFdBjsxop4ZO1FwNIEEb+wGNSCUp/+8mz/lnkLR2pc4F9ubgIw==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/Fdawgs" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -3401,17 +3414,40 @@ } }, "node_modules/node-poppler": { - "version": "7.2.4", - "resolved": "https://registry.npmjs.org/node-poppler/-/node-poppler-7.2.4.tgz", - "integrity": "sha512-+YvPbEQ2uxsUVBXDIZiUEu0C3wMOo37D+cIqzWu5gZra3p6MHhBFJtZ/2slzj+5QPmWcHd9SAEjXk2ogBSHg9Q==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/node-poppler/-/node-poppler-9.1.1.tgz", + "integrity": "sha512-uT/WxcJjwsDElPJoZ9HftRpGg6V1QjAsKpTDZHpJbl53EkaemzuNBisxsFMc5h98eZETMqpsziZCczcNkCCa7Q==", "license": "MIT", "optional": true, "dependencies": { "camelcase": "^6.3.0", - "semver": "^7.6.3" + "ice-barrage": "^1.0.0", + "semver": "^7.7.2" }, "engines": { - "node": ">=18" + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/Fdawgs" + }, + "optionalDependencies": { + "node-poppler-win32": "^1.0.1" + } + }, + "node_modules/node-poppler-win32": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/node-poppler-win32/-/node-poppler-win32-1.0.2.tgz", + "integrity": "sha512-U2YVdM7EEXNE21TD4ajJxfd1pKx7yEF2tcuHc4eCa7uxmw+mfSNPB+yHRtNrdxJqV6dKoz4Rvhuyy5rn6mg3ZA==", + "cpu": [ + "x64" + ], + "license": "GPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20" }, "funding": { "url": "https://github.com/sponsors/Fdawgs" diff --git a/package.json b/package.json index 7a2245ad..13e45bcf 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "CHANGELOG.md" ], "engines": { - "node": ">= 20.1" + "node": ">= 20.9" }, "dependencies": { "commander": "^14.0.3", @@ -54,8 +54,8 @@ "undici": "^6.23.0" }, "optionalDependencies": { - "@cantoo/pdf-lib": "^2.3.2", - "node-poppler": "^7.2.4", + "@cantoo/pdf-lib": "^2.5.3", + "node-poppler": "^9.1.1", "pdf.js-extract": "^0.2.1", "sharp": "~0.34.5" }, From e08c9ae62270734875527b52cc0cb0a0886d8f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 18 Feb 2026 15:37:50 +0100 Subject: [PATCH 4/4] :arrow_up: Add compatibility with undici 7.x --- package-lock.json | 2 +- package.json | 6 +++--- src/http/apiCore.ts | 9 ++++----- src/v1/http/endpoint.ts | 16 +++++++++++----- src/v1/http/workflowEndpoint.ts | 10 ++++++++-- src/v2/client/baseParameters.ts | 1 + src/v2/http/mindeeApiV2.ts | 12 ++++++++---- .../extraction/params/extractionParameters.ts | 1 + 8 files changed, 37 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index e7556c96..e5972851 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "typescript": "^5.9.3" }, "engines": { - "node": ">= 20.1" + "node": ">= 20.9" }, "optionalDependencies": { "@cantoo/pdf-lib": "^2.5.3", diff --git a/package.json b/package.json index 13e45bcf..7888ee7e 100644 --- a/package.json +++ b/package.json @@ -44,19 +44,19 @@ "CHANGELOG.md" ], "engines": { - "node": ">= 20.9" + "node": ">= 20.1" }, "dependencies": { "commander": "^14.0.3", "file-type": "^21.3.0", "tmp": "^0.2.3", "tslib": "^2.8.1", - "undici": "^6.23.0" + "undici": ">=6.23.0 <8.0.0" }, "optionalDependencies": { "@cantoo/pdf-lib": "^2.5.3", "node-poppler": "^9.1.1", - "pdf.js-extract": "^0.2.1", + "pdf.js-extract": "~0.2.1", "sharp": "~0.34.5" }, "devDependencies": { diff --git a/src/http/apiCore.ts b/src/http/apiCore.ts index 45b740a8..9b0057c6 100644 --- a/src/http/apiCore.ts +++ b/src/http/apiCore.ts @@ -1,5 +1,5 @@ import { logger } from "@/logger.js"; -import { request, Dispatcher } from "undici"; +import { request, Dispatcher, FormData } from "undici"; import { InputSource, PageOptions, LocalInputSource } from "@/input/index.js"; export const TIMEOUT_SECS_DEFAULT: number = 120; @@ -10,7 +10,7 @@ export interface RequestOptions { method: any; timeoutSecs: number; headers: any; - body?: any; + body?: FormData | string; } export interface BaseHttpResponse { @@ -40,8 +40,8 @@ export async function sendRequestAndReadResponse( options: RequestOptions, ): Promise { const url: string = `https://${options.hostname}${options.path}`; - logger.debug(`${options.method}: ${url}`); + logger.debug(`${options.method}: ${url}`); const response = await request( url, { @@ -49,8 +49,7 @@ export async function sendRequestAndReadResponse( headers: options.headers, headersTimeout: options.timeoutSecs * 1000, body: options.body, - throwOnError: false, - dispatcher: dispatcher + dispatcher: dispatcher, } ); logger.debug("Parsing the response ..."); diff --git a/src/v1/http/endpoint.ts b/src/v1/http/endpoint.ts index 97add294..79fa0910 100644 --- a/src/v1/http/endpoint.ts +++ b/src/v1/http/endpoint.ts @@ -1,7 +1,13 @@ import { URLSearchParams } from "url"; +import { FormData } from "undici"; import { InputSource, LocalInputSource } from "@/input/index.js"; import { StringDict } from "@/parsing/stringDict.js"; -import { cutDocPages, sendRequestAndReadResponse, BaseHttpResponse } from "@/http/apiCore.js"; +import { + cutDocPages, + sendRequestAndReadResponse, + BaseHttpResponse, + RequestOptions, +} from "@/http/apiCore.js"; import { ApiSettingsV1 } from "./apiSettingsV1.js"; import { handleError } from "./errors.js"; import { PredictParams } from "./httpParams.js"; @@ -208,7 +214,7 @@ export class Endpoint { path += `?${searchParams}`; } - const options = { + const options: RequestOptions = { method: "POST", headers: this.settings.baseHeaders, hostname: this.settings.hostname, @@ -268,7 +274,7 @@ export class Endpoint { * @param queueId */ async #documentQueueReqGet(queueId: string): Promise { - const options = { + const options: RequestOptions = { method: "GET", headers: this.settings.baseHeaders, hostname: this.settings.hostname, @@ -283,7 +289,7 @@ export class Endpoint { * @param documentId */ async #documentGetReq(documentId: string): Promise { - const options = { + const options: RequestOptions = { method: "GET", headers: this.settings.baseHeaders, hostname: this.settings.hostname, @@ -299,7 +305,7 @@ export class Endpoint { * @param feedback */ async #documentFeedbackPutReq(documentId: string, feedback: StringDict): Promise { - const options = { + const options: RequestOptions = { method: "PUT", headers: this.settings.baseHeaders, hostname: this.settings.hostname, diff --git a/src/v1/http/workflowEndpoint.ts b/src/v1/http/workflowEndpoint.ts index d0ba1aa4..6a32daee 100644 --- a/src/v1/http/workflowEndpoint.ts +++ b/src/v1/http/workflowEndpoint.ts @@ -1,7 +1,13 @@ import { URLSearchParams } from "url"; +import { FormData } from "undici"; import { InputSource, LocalInputSource } from "@/input/index.js"; import { ExecutionPriority } from "@/v1/parsing/common/index.js"; -import { cutDocPages, sendRequestAndReadResponse, BaseHttpResponse } from "../../http/apiCore.js"; +import { + cutDocPages, + sendRequestAndReadResponse, + BaseHttpResponse, + RequestOptions, +} from "@/http/apiCore.js"; import { ApiSettingsV1 } from "./apiSettingsV1.js"; import { handleError } from "./errors.js"; import { WorkflowParams } from "./httpParams.js"; @@ -105,7 +111,7 @@ export class WorkflowEndpoint { path += `?${searchParams}`; } - const options = { + const options: RequestOptions = { method: "POST", headers: this.settings.baseHeaders, hostname: this.settings.hostname, diff --git a/src/v2/client/baseParameters.ts b/src/v2/client/baseParameters.ts index 5d75a8f0..b4c9952d 100644 --- a/src/v2/client/baseParameters.ts +++ b/src/v2/client/baseParameters.ts @@ -1,3 +1,4 @@ +import { FormData } from "undici"; import { MindeeConfigurationError } from "@/errors/index.js"; /** diff --git a/src/v2/http/mindeeApiV2.ts b/src/v2/http/mindeeApiV2.ts index a44a08be..aeb35df7 100644 --- a/src/v2/http/mindeeApiV2.ts +++ b/src/v2/http/mindeeApiV2.ts @@ -7,7 +7,11 @@ import { ResponseConstructor, JobResponse, } from "@/v2/parsing/index.js"; -import { sendRequestAndReadResponse, BaseHttpResponse } from "@/http/apiCore.js"; +import { + sendRequestAndReadResponse, + BaseHttpResponse, + RequestOptions +} from "@/http/apiCore.js"; import { InputSource, LocalInputSource, UrlInput } from "@/input/index.js"; import { MindeeDeserializationError } from "@/errors/index.js"; import { MindeeHttpErrorV2 } from "./errors.js"; @@ -127,7 +131,7 @@ export class MindeeApiV2 { form.set("url", (inputSource as UrlInput).url); } const path = `/v2/products/${product.slug}/enqueue`; - const options = { + const options: RequestOptions = { method: "POST", headers: this.settings.baseHeaders, hostname: this.settings.hostname, @@ -139,7 +143,7 @@ export class MindeeApiV2 { } async #reqGetJob(jobId: string): Promise { - const options = { + const options: RequestOptions = { method: "GET", headers: this.settings.baseHeaders, hostname: this.settings.hostname, @@ -157,7 +161,7 @@ export class MindeeApiV2 { * @returns a `Promise` containing either the parsed result, or information on the queue. */ async #reqGetProductResult(inferenceId: string, slug: string): Promise { - const options = { + const options: RequestOptions = { method: "GET", headers: this.settings.baseHeaders, hostname: this.settings.hostname, diff --git a/src/v2/product/extraction/params/extractionParameters.ts b/src/v2/product/extraction/params/extractionParameters.ts index fe3b8f1c..552791b5 100644 --- a/src/v2/product/extraction/params/extractionParameters.ts +++ b/src/v2/product/extraction/params/extractionParameters.ts @@ -1,3 +1,4 @@ +import { FormData } from "undici"; import { StringDict } from "@/parsing/stringDict.js"; import { DataSchema } from "./dataSchema.js"; import { BaseParameters, BaseParametersConstructor } from "@/v2/client/baseParameters.js";