Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/parsing/v2/inferenceActiveOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions tests/v2/clientV2.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 () => {
Expand Down
32 changes: 13 additions & 19 deletions tests/v2/input/localResponse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down