From 5e122d66b29da9fa6767aa52008fce123e423c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Fri, 29 Aug 2025 15:58:35 +0200 Subject: [PATCH] :coffin: remove obsolete options classes --- src/parsing/v2/index.ts | 1 - src/parsing/v2/inferenceResult.ts | 17 +++-------------- src/parsing/v2/inferenceResultOptions.ts | 15 --------------- src/parsing/v2/rawText.ts | 3 +++ tests/parsing/v2/inference.spec.ts | 2 +- tests/v2/clientV2.integration.ts | 23 +++++++++++++---------- 6 files changed, 20 insertions(+), 41 deletions(-) delete mode 100644 src/parsing/v2/inferenceResultOptions.ts diff --git a/src/parsing/v2/index.ts b/src/parsing/v2/index.ts index dc796a040..654d5bcfa 100644 --- a/src/parsing/v2/index.ts +++ b/src/parsing/v2/index.ts @@ -3,7 +3,6 @@ export { ErrorResponse } from "./errorResponse"; export { Inference } from "./inference"; export { InferenceFile } from "./inferenceFile"; export { InferenceModel } from "./inferenceModel"; -export { InferenceResultOptions } from "./inferenceResultOptions"; export { InferenceResponse } from "./inferenceResponse"; export { InferenceResult } from "./inferenceResult"; export { Job } from "./job"; diff --git a/src/parsing/v2/inferenceResult.ts b/src/parsing/v2/inferenceResult.ts index 26a2528eb..48c6f31f3 100644 --- a/src/parsing/v2/inferenceResult.ts +++ b/src/parsing/v2/inferenceResult.ts @@ -1,5 +1,4 @@ -import { InferenceFields } from "./field/inferenceFields"; -import { InferenceResultOptions } from "./inferenceResultOptions"; +import { InferenceFields } from "./field"; import { StringDict } from "../common"; import { RawText } from "./rawText"; @@ -8,12 +7,11 @@ export class InferenceResult { * Fields contained in the inference. */ public fields: InferenceFields; - public rawText?: RawText; /** - * Potential options retrieved alongside the inference. + * Raw text extracted from all pages. */ - public options?: InferenceResultOptions; + public rawText?: RawText; constructor(serverResponse: StringDict) { this.fields = new InferenceFields(serverResponse["fields"]); @@ -28,15 +26,6 @@ export class InferenceResult { "======", this.fields.toString(), ]; - - if (this.options) { - parts.push( - "Options", - "=======", - this.options.toString() - ); - } - return parts.join("\n"); } } diff --git a/src/parsing/v2/inferenceResultOptions.ts b/src/parsing/v2/inferenceResultOptions.ts deleted file mode 100644 index 09d66c86d..000000000 --- a/src/parsing/v2/inferenceResultOptions.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { StringDict } from "../common"; -import { RawText } from "./rawText"; - -export class InferenceResultOptions { - /** - * List of texts found per page. - */ - public rawTexts: Array; - - constructor(serverResponse: StringDict) { - this.rawTexts = serverResponse["raw_texts"] ? serverResponse["raw_texts"].map( - (rawText: StringDict) => new RawText(rawText) - ) : []; - } -} diff --git a/src/parsing/v2/rawText.ts b/src/parsing/v2/rawText.ts index a804834fc..626d0769d 100644 --- a/src/parsing/v2/rawText.ts +++ b/src/parsing/v2/rawText.ts @@ -2,6 +2,9 @@ import { StringDict } from "../common"; import { RawTextPage } from "./rawTextPage"; export class RawText { + /** + * List of pages with their extracted text content. + */ pages: Array; constructor(serverResponse: StringDict) { diff --git a/tests/parsing/v2/inference.spec.ts b/tests/parsing/v2/inference.spec.ts index 039314250..91953c865 100644 --- a/tests/parsing/v2/inference.spec.ts +++ b/tests/parsing/v2/inference.spec.ts @@ -112,7 +112,7 @@ describe("inference", async () => { const cityField = customerAddr.fields.getSimpleField("city"); expect(cityField.value).to.eq("New York"); - expect(inference.result.options).to.be.undefined; + expect(inference.result.rawText).to.be.undefined; }); }); diff --git a/tests/v2/clientV2.integration.ts b/tests/v2/clientV2.integration.ts index b8394e3d7..352dff022 100644 --- a/tests/v2/clientV2.integration.ts +++ b/tests/v2/clientV2.integration.ts @@ -37,14 +37,14 @@ describe("MindeeClientV2 – integration tests (V2)", () => { const response = await client.enqueueAndGetInference(source, params); expect(response).to.exist; - const inf = response.inference; - expect(inf).to.exist; + const inference = response.inference; + expect(inference).to.exist; - expect(inf.file?.name).to.equal("multipage_cut-2.pdf"); - expect(inf.model?.id).to.equal(modelId); + expect(inference.file?.name).to.equal("multipage_cut-2.pdf"); + expect(inference.model?.id).to.equal(modelId); - expect(inf.result).to.exist; - expect(inf.result.options).to.be.undefined; + expect(inference.result).to.exist; + expect(inference.result.rawText).to.be.undefined; }).timeout(60000); it("Filled, single-page image – enqueue & parse must succeed", async () => { @@ -53,11 +53,14 @@ describe("MindeeClientV2 – integration tests (V2)", () => { const response = await client.enqueueAndGetInference(source, params); - const inf = response.inference; - expect(inf.file?.name).to.equal("default_sample.jpg"); - expect(inf.model?.id).to.equal(modelId); + const inference = response.inference; + expect(inference.file?.name).to.equal("default_sample.jpg"); + expect(inference.model?.id).to.equal(modelId); - const supplierField = inf.result.fields.get("supplier_name") as SimpleField; + expect(inference.result).to.exist; + expect(inference.result.rawText).to.be.undefined; + + const supplierField = inference.result.fields.get("supplier_name") as SimpleField; expect(supplierField).to.be.instanceOf(SimpleField); expect(supplierField.value).to.equal("John Smith"); }).timeout(60000);