From 2c0a65cc65b0a592732c58a363bec64044c4f116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 11 Feb 2026 15:16:58 +0100 Subject: [PATCH 1/3] form-data is no longer needed --- package-lock.json | 243 ---------------------------------------------- package.json | 1 - 2 files changed, 244 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2c80c95f..b151f8e56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@cantoo/pdf-lib": "^2.3.2", "commander": "~9.4.1", "file-type": "^19.6.0", - "form-data": "^3.0.4", "node-poppler": "^7.2.4", "pdf.js-extract": "^0.2.1", "sharp": "~0.34.5", @@ -1842,12 +1841,6 @@ "node": ">=12" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1898,19 +1891,6 @@ "dev": true, "license": "ISC" }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2095,18 +2075,6 @@ "simple-swizzle": "^0.2.2" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "9.4.1", "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz", @@ -2192,15 +2160,6 @@ "dev": true, "license": "MIT" }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -2239,20 +2198,6 @@ "integrity": "sha512-PatEhAW5pIHr28MvFQGV5iiHNloqvecQZlxs7/8s/eulLqZI3uVqPkrO7YDuqsebovr/9mmcWDSWzVG4amEZgQ==", "license": "MIT" }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -2280,51 +2225,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-set-tostringtag": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", - "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.6", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/esbuild": { "version": "0.27.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", @@ -2817,22 +2717,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/form-data": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.4.tgz", - "integrity": "sha512-f0cRzm6dkyVYV3nPoooP8XlccPQukegwhAnpoLcXy+X+A8KfpGOoXwDr9FLZd3wzgLaBGQBE3lY93Zm/i1JvIQ==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.2", - "mime-types": "^2.1.35" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -2848,15 +2732,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -2867,43 +2742,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/get-stream": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", @@ -3011,18 +2849,6 @@ "node": ">= 4" } }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -3033,45 +2859,6 @@ "node": ">=8" } }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", - "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "license": "MIT", - "dependencies": { - "has-symbols": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -3435,15 +3222,6 @@ "markdown-it": "bin/markdown-it.mjs" } }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, "node_modules/mdurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", @@ -3488,27 +3266,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/minimatch": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", diff --git a/package.json b/package.json index 8f6b27283..0aae7698b 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "@cantoo/pdf-lib": "^2.3.2", "commander": "~9.4.1", "file-type": "^19.6.0", - "form-data": "^3.0.4", "node-poppler": "^7.2.4", "pdf.js-extract": "^0.2.1", "sharp": "~0.34.5", From 1e51b96bfc3353349e428368fe56ff3406ac7b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 11 Feb 2026 17:07:46 +0100 Subject: [PATCH 2/3] fix for model id --- .github/workflows/_publish-code.yml | 3 --- .github/workflows/_publish-docs.yml | 3 --- .github/workflows/_static-analysis.yml | 3 --- .github/workflows/_test-integrations.yml | 3 --- .github/workflows/_test-units.yml | 3 --- docs/code_samples/v2_classification.txt | 2 +- docs/code_samples/v2_crop.txt | 2 +- docs/code_samples/v2_ocr.txt | 2 +- docs/code_samples/v2_split.txt | 2 +- tests/test_v1_code_samples.sh | 7 ++++--- tests/test_v2_code_samples.sh | 17 ++++++++--------- 11 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.github/workflows/_publish-code.yml b/.github/workflows/_publish-code.yml index dfa8d8ee1..4abc5d17f 100644 --- a/.github/workflows/_publish-code.yml +++ b/.github/workflows/_publish-code.yml @@ -1,6 +1,3 @@ -# -# Publish releases to NPM -# name: Publish Code on: diff --git a/.github/workflows/_publish-docs.yml b/.github/workflows/_publish-docs.yml index 3fdb325e5..7ff3aeebc 100644 --- a/.github/workflows/_publish-docs.yml +++ b/.github/workflows/_publish-docs.yml @@ -1,6 +1,3 @@ -# -# Publish Documentation to GitHub pages. -# name: Publish Documentation on: diff --git a/.github/workflows/_static-analysis.yml b/.github/workflows/_static-analysis.yml index 831822f24..88f572eff 100644 --- a/.github/workflows/_static-analysis.yml +++ b/.github/workflows/_static-analysis.yml @@ -1,6 +1,3 @@ -# -# Run static code analysis. -# name: Static Analysis on: diff --git a/.github/workflows/_test-integrations.yml b/.github/workflows/_test-integrations.yml index 4d96c0331..558f29202 100644 --- a/.github/workflows/_test-integrations.yml +++ b/.github/workflows/_test-integrations.yml @@ -1,6 +1,3 @@ -# -# Run integration tests. -# name: Integration Test on: diff --git a/.github/workflows/_test-units.yml b/.github/workflows/_test-units.yml index 3639ffee3..785708c3e 100644 --- a/.github/workflows/_test-units.yml +++ b/.github/workflows/_test-units.yml @@ -1,6 +1,3 @@ -# -# Run unit tests. -# name: Test on: diff --git a/docs/code_samples/v2_classification.txt b/docs/code_samples/v2_classification.txt index 938983ea5..4e16a17ba 100644 --- a/docs/code_samples/v2_classification.txt +++ b/docs/code_samples/v2_classification.txt @@ -4,7 +4,7 @@ import * as mindee from "mindee"; const apiKey = "MY_API_KEY"; const filePath = "/path/to/the/file.ext"; -const modelId = "MY_CLASSIFICATION_MODEL_ID"; +const modelId = "MY_MODEL_ID"; // Init a new client const mindeeClient = new mindee.Client( diff --git a/docs/code_samples/v2_crop.txt b/docs/code_samples/v2_crop.txt index 161f9b2f0..1f4b2c4b7 100644 --- a/docs/code_samples/v2_crop.txt +++ b/docs/code_samples/v2_crop.txt @@ -4,7 +4,7 @@ import * as mindee from "mindee"; const apiKey = "MY_API_KEY"; const filePath = "/path/to/the/file.ext"; -const modelId = "MY_CROP_MODEL_ID"; +const modelId = "MY_MODEL_ID"; // Init a new client const mindeeClient = new mindee.Client( diff --git a/docs/code_samples/v2_ocr.txt b/docs/code_samples/v2_ocr.txt index 389c1efd4..5399665eb 100644 --- a/docs/code_samples/v2_ocr.txt +++ b/docs/code_samples/v2_ocr.txt @@ -4,7 +4,7 @@ import * as mindee from "mindee"; const apiKey = "MY_API_KEY"; const filePath = "/path/to/the/file.ext"; -const modelId = "MY_OCR_MODEL_ID"; +const modelId = "MY_MODEL_ID"; // Init a new client const mindeeClient = new mindee.Client( diff --git a/docs/code_samples/v2_split.txt b/docs/code_samples/v2_split.txt index 6445c56ff..1cc964bd1 100644 --- a/docs/code_samples/v2_split.txt +++ b/docs/code_samples/v2_split.txt @@ -4,7 +4,7 @@ import * as mindee from "mindee"; const apiKey = "MY_API_KEY"; const filePath = "/path/to/the/file.ext"; -const modelId = "MY_SPLIT_MODEL_ID"; +const modelId = "MY_MODEL_ID"; // Init a new client const mindeeClient = new mindee.Client( diff --git a/tests/test_v1_code_samples.sh b/tests/test_v1_code_samples.sh index 27884a9aa..944489706 100755 --- a/tests/test_v1_code_samples.sh +++ b/tests/test_v1_code_samples.sh @@ -4,7 +4,6 @@ set -e OUTPUT_FILE='../test_code_samples/_test_v1.js' ACCOUNT=$1 ENDPOINT=$2 -API_KEY=${MINDEE_API_KEY} rm -fr ../test_code_samples mkdir ../test_code_samples @@ -13,14 +12,16 @@ cd ../test_code_samples npm install ../mindee-api-nodejs/dist --ignore-scripts --no-bin-links cd - -for f in $(find docs/code_samples -maxdepth 1 -name "*.txt" -not -name "workflow_*.txt" -not -name "v2_*.txt" | sort -h) +for f in $( + find docs/code_samples -maxdepth 1 -name "*.txt" -not -name "workflow_*.txt" -not -name "v2_*.txt" | sort -h +) do echo "###############################################" echo "${f}" echo "###############################################" echo - sed "s/my-api-key/$API_KEY/" "${f}" > $OUTPUT_FILE + sed "s/my-api-key/${MINDEE_API_KEY}/" "${f}" > $OUTPUT_FILE sed -i "s/\/path\/to\/the\/file.ext/..\/mindee-api-nodejs\/tests\/data\/file_types\/pdf\/blank_1.pdf/" $OUTPUT_FILE if echo "$f" | grep -q "custom_v1.txt" diff --git a/tests/test_v2_code_samples.sh b/tests/test_v2_code_samples.sh index 0703482f2..c12fadc1b 100755 --- a/tests/test_v2_code_samples.sh +++ b/tests/test_v2_code_samples.sh @@ -2,7 +2,6 @@ set -e OUTPUT_FILE='../test_code_samples/_test_v2.mjs' -API_KEY_V2=${MINDEE_V2_API_KEY} rm -fr ../test_code_samples mkdir ../test_code_samples @@ -11,18 +10,18 @@ cd ../test_code_samples npm install ../mindee-api-nodejs/dist --ignore-scripts --no-bin-links cd - -for f in $(find docs/code_samples -maxdepth 1 -name "v2_*.txt" | sort -h) +for f in $( + find docs/code_samples -maxdepth 1 -name "v2_*.txt" | sort -h +) do echo "###############################################" echo "${f}" echo "###############################################" echo - sed "s/my-api-key/$API_KEY/" "${f}" > $OUTPUT_FILE + sed "s/MY_API_KEY/${MINDEE_V2_API_KEY}/" "${f}" > $OUTPUT_FILE sed -i "s/\/path\/to\/the\/file.ext/..\/mindee-api-nodejs\/tests\/data\/file_types\/pdf\/blank_1.pdf/" $OUTPUT_FILE - sed -i "s/MY_API_KEY/$API_KEY_V2/" $OUTPUT_FILE - if echo "${f}" | grep -q "v2_extraction.txt" then sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID}/" $OUTPUT_FILE @@ -30,22 +29,22 @@ do if echo "${f}" | grep -q "v2_classification.txt" then - sed -i "s/MY_CLASSIFICATION_MODEL_ID/${MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID}/" $OUTPUT_FILE + sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID}/" $OUTPUT_FILE fi if echo "${f}" | grep -q "v2_crop.txt" then - sed -i "s/MY_CROP_MODEL_ID/${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}/" $OUTPUT_FILE + sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_CROP_MODEL_ID}/" $OUTPUT_FILE fi if echo "${f}" | grep -q "v2_split.txt" then - sed -i "s/MY_SPLIT_MODEL_ID/${MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID}/" $OUTPUT_FILE + sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID}/" $OUTPUT_FILE fi if echo "${f}" | grep -q "v2_ocr.txt" then - sed -i "s/MY_OCR_MODEL_ID/${MINDEE_V2_SE_TESTS_OCR_MODEL_ID}/" $OUTPUT_FILE + sed -i "s/MY_MODEL_ID/${MINDEE_V2_SE_TESTS_OCR_MODEL_ID}/" $OUTPUT_FILE fi sleep 0.5 # avoid too many request errors From a36e79e9c5282e3d79abe90e35fe43197a63156e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Wed, 11 Feb 2026 18:39:05 +0100 Subject: [PATCH 3/3] rework HTTP calls and slugs --- src/v2/client.ts | 22 +++---- src/v2/http/mindeeApiV2.ts | 59 +++++++++++-------- src/v2/product/baseProduct.ts | 13 ++-- .../product/classification/classification.ts | 11 ++-- src/v2/product/crop/crop.ts | 11 ++-- src/v2/product/extraction/extraction.ts | 11 ++-- src/v2/product/ocr/ocr.ts | 11 ++-- src/v2/product/split/split.ts | 11 ++-- 8 files changed, 70 insertions(+), 79 deletions(-) diff --git a/src/v2/client.ts b/src/v2/client.ts index 01accf0a3..b7c55afbf 100644 --- a/src/v2/client.ts +++ b/src/v2/client.ts @@ -61,16 +61,16 @@ export class Client { async enqueue

( product: P, inputSource: InputSource, - params: InstanceType | ConstructorParameters[0], + params: InstanceType | ConstructorParameters[0], ): Promise { if (inputSource === undefined) { throw new MindeeError("An input document is required."); } - const paramsInstance = params instanceof product.parameters + const paramsInstance = params instanceof product.parametersClass ? params - : new product.parameters(params); + : new product.parametersClass(params); await inputSource.init(); - const jobResponse = await this.mindeeApi.reqPostProductEnqueue( + const jobResponse = await this.mindeeApi.enqueueProduct( product, inputSource, paramsInstance ); if (jobResponse.job.id === undefined || jobResponse.job.id.length === 0) { @@ -95,11 +95,11 @@ export class Client { async getResult

( product: P, inferenceId: string - ): Promise> { + ): Promise> { logger.debug( `Attempting to get inference with ID: ${inferenceId} using response type: ${product.name}` ); - return await this.mindeeApi.reqGetResult(product, inferenceId); + return await this.mindeeApi.getProductResult(product, inferenceId); } /** @@ -113,7 +113,7 @@ export class Client { * parsing is complete. */ async getJob(jobId: string): Promise { - return await this.mindeeApi.reqGetJob(jobId); + return await this.mindeeApi.getJob(jobId); } /** @@ -131,9 +131,9 @@ export class Client { async enqueueAndGetResult

( product: P, inputSource: InputSource, - params: InstanceType | ConstructorParameters[0], - ): Promise> { - const paramsInstance = new product.parameters(params); + params: InstanceType | ConstructorParameters[0], + ): Promise> { + const paramsInstance = new product.parametersClass(params); const pollingOptions = paramsInstance.getValidatedPollingOptions(); @@ -154,7 +154,7 @@ export class Client { product: typeof BaseProduct, pollingOptions: ValidatedPollingOptions, queueId: string, - ): Promise> { + ): Promise> { logger.debug( `Waiting ${pollingOptions.initialDelaySec} seconds before polling.` ); diff --git a/src/v2/http/mindeeApiV2.ts b/src/v2/http/mindeeApiV2.ts index b731a1fc8..f251c7f04 100644 --- a/src/v2/http/mindeeApiV2.ts +++ b/src/v2/http/mindeeApiV2.ts @@ -31,13 +31,13 @@ export class MindeeApiV2 { * @throws Error if the server's response contains one. * @returns a `Promise` containing a job response. */ - async reqPostProductEnqueue( + async enqueueProduct( product: typeof BaseProduct, inputSource: InputSource, params: BaseParameters ): Promise { await inputSource.init(); - const result: BaseHttpResponse = await this.#productEnqueuePost( + const result: BaseHttpResponse = await this.#reqPostProductEnqueue( product, inputSource, params ); if (result.data.error !== undefined) { @@ -46,6 +46,18 @@ export class MindeeApiV2 { return this.#processResponse(result, JobResponse); } + /** + * Requests the results of a queued document from the API. + * Throws an error if the server's response contains one. + * @param jobId The document's ID in the queue. + * @category Asynchronous + * @returns a `Promise` containing information on the queue. + */ + async getJob(jobId: string): Promise { + const response = await this.#reqGetJob(jobId); + return this.#processResponse(response, JobResponse); + } + /** * Requests the job of a queued document from the API. * Throws an error if the server's response contains one. @@ -54,26 +66,14 @@ export class MindeeApiV2 { * @category Asynchronous * @returns a `Promise` containing either the parsed result, or information on the queue. */ - async reqGetResult

( + async getProductResult

( product: P, inferenceId: string, - ): Promise> { - const queueResponse: BaseHttpResponse = await this.#inferenceResultReqGet( - inferenceId, product.getResultSlug + ): Promise> { + const queueResponse: BaseHttpResponse = await this.#reqGetProductResult( + inferenceId, product.slug ); - return this.#processResponse(queueResponse, product.response) as InstanceType; - } - - /** - * Requests the results of a queued document from the API. - * Throws an error if the server's response contains one. - * @param jobId The document's ID in the queue. - * @category Asynchronous - * @returns a `Promise` containing information on the queue. - */ - async reqGetJob(jobId: string): Promise { - const queueResponse: BaseHttpResponse = await this.#inferenceResultReqGet(jobId, "jobs"); - return this.#processResponse(queueResponse, JobResponse); + return this.#processResponse(queueResponse, product.responseClass) as InstanceType; } #processResponse( @@ -110,7 +110,7 @@ export class MindeeApiV2 { * @param inputSource Local or remote file as an input. * @param params {ExtractionParameters} parameters relating to the enqueueing options. */ - async #productEnqueuePost( + async #reqPostProductEnqueue( product: typeof BaseProduct, inputSource: InputSource, params: BaseParameters @@ -121,7 +121,7 @@ export class MindeeApiV2 { } else { form.set("url", (inputSource as UrlInput).url); } - const path = `/v2/${product.enqueueSlug}/enqueue`; + const path = `/v2/products/${product.slug}/enqueue`; const options = { method: "POST", headers: this.settings.baseHeaders, @@ -133,19 +133,30 @@ export class MindeeApiV2 { return await sendRequestAndReadResponse(this.settings.dispatcher, options); } + async #reqGetJob(jobId: string): Promise { + const options = { + method: "GET", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: `/v2/jobs/${jobId}`, + timeout: this.settings.timeout, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); + } + /** * Make a request to GET the status of a document in the queue. - * @param queueId ID of either the job or the inference. + * @param inferenceId ID of the inference. * @param slug "jobs" or "inferences"... * @category Asynchronous * @returns a `Promise` containing either the parsed result, or information on the queue. */ - async #inferenceResultReqGet(queueId: string, slug: string): Promise { + async #reqGetProductResult(inferenceId: string, slug: string): Promise { const options = { method: "GET", headers: this.settings.baseHeaders, hostname: this.settings.hostname, - path: `/v2/${slug}/${queueId}`, + path: `/v2/products/${slug}/results/${inferenceId}`, timeout: this.settings.timeout, }; return await sendRequestAndReadResponse(this.settings.dispatcher, options); diff --git a/src/v2/product/baseProduct.ts b/src/v2/product/baseProduct.ts index 1ae2a68e0..981779cd8 100644 --- a/src/v2/product/baseProduct.ts +++ b/src/v2/product/baseProduct.ts @@ -2,18 +2,13 @@ import { BaseParameters } from "@/v2/client/index.js"; import { ResponseConstructor } from "@/v2/parsing/index.js"; export abstract class BaseProduct { - static get parameters(): new (...args: any[]) => BaseParameters { + static get parametersClass(): new (...args: any[]) => BaseParameters { throw new Error("Must define static parameters property"); } - static get response(): ResponseConstructor { + static get responseClass(): ResponseConstructor { throw new Error("Must define static response property"); } - - static get enqueueSlug(): string { - throw new Error("Must define static enqueueSlug property"); - } - - static get getResultSlug(): string { - throw new Error("Must define static getResultSlug property"); + static get slug(): string { + throw new Error("Must define static slug property"); } } diff --git a/src/v2/product/classification/classification.ts b/src/v2/product/classification/classification.ts index 65f8c85b2..ceafaf077 100644 --- a/src/v2/product/classification/classification.ts +++ b/src/v2/product/classification/classification.ts @@ -3,16 +3,13 @@ import { ClassificationParameters } from "./classificationParameters.js"; import { BaseProduct } from "@/v2/product/baseProduct.js"; export class Classification extends BaseProduct { - static get parameters() { + static get parametersClass() { return ClassificationParameters; } - static get response() { + static get responseClass() { return ClassificationResponse; } - static get enqueueSlug() { - return "utilities/classification"; - } - static get getResultSlug() { - return "utilities/classification"; + static get slug() { + return "classification"; } } diff --git a/src/v2/product/crop/crop.ts b/src/v2/product/crop/crop.ts index 63f8a5d6a..9254409a6 100644 --- a/src/v2/product/crop/crop.ts +++ b/src/v2/product/crop/crop.ts @@ -3,16 +3,13 @@ import { CropParameters } from "./cropParameters.js"; import { BaseProduct } from "@/v2/product/baseProduct.js"; export class Crop extends BaseProduct { - static get parameters() { + static get parametersClass() { return CropParameters; } - static get response() { + static get responseClass() { return CropResponse; } - static get enqueueSlug() { - return "utilities/crop"; - } - static get getResultSlug() { - return "utilities/crop"; + static get slug() { + return "crop"; } } diff --git a/src/v2/product/extraction/extraction.ts b/src/v2/product/extraction/extraction.ts index 39ca39925..15030511a 100644 --- a/src/v2/product/extraction/extraction.ts +++ b/src/v2/product/extraction/extraction.ts @@ -3,16 +3,13 @@ import { ExtractionParameters } from "./extractionParameters.js"; import { BaseProduct } from "@/v2/product/baseProduct.js"; export class Extraction extends BaseProduct { - static get parameters() { + static get parametersClass() { return ExtractionParameters; } - static get response() { + static get responseClass() { return ExtractionResponse; } - static get enqueueSlug() { - return "inferences"; - } - static get getResultSlug() { - return "inferences"; + static get slug() { + return "extraction"; } } diff --git a/src/v2/product/ocr/ocr.ts b/src/v2/product/ocr/ocr.ts index e82945cd6..8f742b091 100644 --- a/src/v2/product/ocr/ocr.ts +++ b/src/v2/product/ocr/ocr.ts @@ -3,16 +3,13 @@ import { OcrParameters } from "./ocrParameters.js"; import { BaseProduct } from "@/v2/product/baseProduct.js"; export class Ocr extends BaseProduct { - static get parameters() { + static get parametersClass() { return OcrParameters; } - static get response() { + static get responseClass() { return OcrResponse; } - static get enqueueSlug() { - return "utilities/ocr"; - } - static get getResultSlug() { - return "utilities/ocr"; + static get slug() { + return "ocr"; } } diff --git a/src/v2/product/split/split.ts b/src/v2/product/split/split.ts index 9b5a47c57..42d217715 100644 --- a/src/v2/product/split/split.ts +++ b/src/v2/product/split/split.ts @@ -3,16 +3,13 @@ import { SplitParameters } from "./splitParameters.js"; import { BaseProduct } from "@/v2/product/baseProduct.js"; export class Split extends BaseProduct { - static get parameters() { + static get parametersClass() { return SplitParameters; } - static get response() { + static get responseClass() { return SplitResponse; } - static get enqueueSlug() { - return "utilities/split"; - } - static get getResultSlug() { - return "utilities/split"; + static get slug() { + return "split"; } }