From 953e41cf065dc8fb22ceb9bfbf52499fd13e4dbf Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 2 Dec 2025 11:16:12 +0100 Subject: [PATCH 1/2] bump dependencies --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ec0497e..12eef64f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2407,9 +2407,9 @@ } }, "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", "dev": true, "license": "ISC", "dependencies": { @@ -2710,9 +2710,9 @@ } }, "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, "license": "MIT", "dependencies": { From 83aa1d91d1612b0f5702aa6e6a19b9c2a937bb8a Mon Sep 17 00:00:00 2001 From: sebastianMindee <130448732+sebastianMindee@users.noreply.github.com> Date: Tue, 2 Dec 2025 11:21:57 +0100 Subject: [PATCH 2/2] :sparkles: add text context option return param --- src/parsing/v2/inferenceActiveOptions.ts | 6 +++++ tests/data | 2 +- tests/v2/clientV2.integration.ts | 3 +++ tests/v2/input/localResponse.spec.ts | 32 ++++++++++-------------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/parsing/v2/inferenceActiveOptions.ts b/src/parsing/v2/inferenceActiveOptions.ts index 0dacc98c..34099b55 100644 --- a/src/parsing/v2/inferenceActiveOptions.ts +++ b/src/parsing/v2/inferenceActiveOptions.ts @@ -18,11 +18,17 @@ export class InferenceActiveOptions { */ public confidence: boolean; + /** + * Whether the text context feature was activated. + */ + public textContext: boolean; + constructor(serverResponse: StringDict) { this.rag = serverResponse["rag"]; this.rawText = serverResponse["raw_text"]; this.polygon = serverResponse["polygon"]; this.confidence = serverResponse["confidence"]; + this.textContext = serverResponse["text_context"]; } toString(): string { diff --git a/tests/data b/tests/data index 7d843db0..f86f3eaf 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 7d843db01df952740d0f2d39f62fc3efb86f92bb +Subproject commit f86f3eaf540f0babeb3d4f1a458d764856a2170b diff --git a/tests/v2/clientV2.integration.ts b/tests/v2/clientV2.integration.ts index 59891bb6..4cacae59 100644 --- a/tests/v2/clientV2.integration.ts +++ b/tests/v2/clientV2.integration.ts @@ -72,6 +72,7 @@ describe("MindeeV2 – Client Integration Tests", () => { expect(inference.activeOptions?.rawText).to.be.false; expect(inference.activeOptions?.polygon).to.be.false; expect(inference.activeOptions?.confidence).to.be.false; + expect(inference.activeOptions?.textContext).to.be.false; }).timeout(60000); it("Filled, single-page image – PathInput - enqueueAndGetInference must succeed", async () => { @@ -107,6 +108,7 @@ describe("MindeeV2 – Client Integration Tests", () => { expect(inference.activeOptions?.rawText).to.be.true; expect(inference.activeOptions?.polygon).to.be.true; expect(inference.activeOptions?.confidence).to.be.false; + expect(inference.activeOptions?.textContext).to.be.true; expect(inference.result.rawText?.pages).to.have.lengthOf(1); }).timeout(120000); @@ -143,6 +145,7 @@ describe("MindeeV2 – Client Integration Tests", () => { expect(inference.activeOptions?.rawText).to.be.false; expect(inference.activeOptions?.polygon).to.be.false; expect(inference.activeOptions?.confidence).to.be.false; + expect(inference.activeOptions?.textContext).to.be.false; }).timeout(120000); it("Invalid model ID – enqueue must raise 422", async () => { diff --git a/tests/v2/input/localResponse.spec.ts b/tests/v2/input/localResponse.spec.ts index 92596289..60690ee5 100644 --- a/tests/v2/input/localResponse.spec.ts +++ b/tests/v2/input/localResponse.spec.ts @@ -4,40 +4,34 @@ import { InferenceResponse, LocalResponse } from "../../../src"; import path from "path"; import { V2_RESOURCE_PATH } from "../../index"; +import { Buffer } from "node:buffer"; -const signature: string = "a1bc9012fa63539d602f163d8980604a0cf2b2ae88e56009cfa1db33382736cf"; +const signature: string = "b82a515c832fd2c4f4ce3a7e6f53c12e8d10e19223f6cf0e3a9809a7a3da26be"; const dummySecretKey: string = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"; const filePath: string = path.join(V2_RESOURCE_PATH, "inference/standard_field_types.json"); +async function assertLocalResponse(localResponse: LocalResponse) { + await localResponse.init(); + expect(localResponse.asDict()).to.not.be.null; + expect(localResponse.isValidHmacSignature(dummySecretKey, "invalid signature")).to.be.false; + expect(localResponse.getHmacSignature(dummySecretKey)).to.eq(signature); + expect(localResponse.isValidHmacSignature(dummySecretKey, signature)).to.be.true; +} + describe("MindeeV2 - Load Local Response", () => { it("should load a string properly.", async () => { const fileObj = await fs.readFile(filePath, { encoding: "utf-8" }); - const localResponse = new LocalResponse(fileObj); - await localResponse.init(); - expect(localResponse.asDict()).to.not.be.null; - expect(localResponse.isValidHmacSignature(dummySecretKey, "invalid signature")).to.be.false; - expect(localResponse.getHmacSignature(dummySecretKey)).to.eq(signature); - expect(localResponse.isValidHmacSignature(dummySecretKey, signature)).to.be.true; + await assertLocalResponse(new LocalResponse(fileObj)); }); it("should load a file properly.", async () => { - const localResponse = new LocalResponse(filePath); - await localResponse.init(); - expect(localResponse.asDict()).to.not.be.null; - expect(localResponse.isValidHmacSignature(dummySecretKey, "invalid signature")).to.be.false; - expect(localResponse.getHmacSignature(dummySecretKey)).to.eq(signature); - expect(localResponse.isValidHmacSignature(dummySecretKey, signature)).to.be.true; + await assertLocalResponse(new LocalResponse(filePath)); }); it("should load a buffer properly.", async () => { const fileStr = (await fs.readFile(filePath, { encoding: "utf-8" })).replace(/\r/g, "").replace(/\n/g, ""); const fileBuffer = Buffer.from(fileStr, "utf-8"); - const localResponse = new LocalResponse(fileBuffer); - await localResponse.init(); - expect(localResponse.asDict()).to.not.be.null; - expect(localResponse.isValidHmacSignature(dummySecretKey, "invalid signature")).to.be.false; - expect(localResponse.getHmacSignature(dummySecretKey)).to.eq(signature); - expect(localResponse.isValidHmacSignature(dummySecretKey, signature)).to.be.true; + await assertLocalResponse(new LocalResponse(fileBuffer)); }); it("should deserialize a prediction.", async () => {