diff --git a/src/v2/parsing/inference/index.ts b/src/v2/parsing/inference/index.ts index df0e9b36..4a2044c5 100644 --- a/src/v2/parsing/inference/index.ts +++ b/src/v2/parsing/inference/index.ts @@ -1,7 +1,4 @@ -// Inference +export { BaseInference } from "./baseInference.js"; export { InferenceFile } from "./inferenceFile.js"; export { InferenceModel } from "./inferenceModel.js"; -export { BaseInference } from "./baseInference.js"; - -// Fields export * as field from "./field/index.js"; diff --git a/tests/data b/tests/data index ed58a9d5..37f2e3de 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit ed58a9d57a31294fef0b8554388db287335e3b79 +Subproject commit 37f2e3de48918e3b1a0e4604a9292aaeae05c637 diff --git a/tests/v2/client.integration.ts b/tests/v2/client.integration.ts index fd5c7c8f..e98d7f3c 100644 --- a/tests/v2/client.integration.ts +++ b/tests/v2/client.integration.ts @@ -15,7 +15,7 @@ import { import { SimpleField } from "@/v2/parsing/inference/field/index.js"; import { MindeeHttpErrorV2 } from "@/v2/http/index.js"; import * as fs from "node:fs"; -import { RESOURCE_PATH, V2_PRODUCT_PATH, V2_RESOURCE_PATH } from "../index.js"; +import { RESOURCE_PATH, V2_PRODUCT_PATH } from "../index.js"; import { Extraction } from "@/v2/product/index.js"; function check422(err: unknown) { @@ -49,6 +49,7 @@ describe("MindeeV2 – Client Integration Tests", () => { ); const sampleImagePath = path.join( V2_PRODUCT_PATH, + "extraction", "financial_document", "default_sample.jpg", ); @@ -58,7 +59,7 @@ describe("MindeeV2 – Client Integration Tests", () => { "receipt.txt", ); const dataSchemaReplacePath = path.join( - V2_RESOURCE_PATH, "inference/data_schema_replace_param.json" + V2_PRODUCT_PATH, "extraction/data_schema_replace_param.json" ); let dataSchemaReplace: string; @@ -72,7 +73,7 @@ describe("MindeeV2 – Client Integration Tests", () => { dataSchemaReplace = fs.readFileSync(dataSchemaReplacePath).toString(); }); - it("Empty, multi-page PDF – PathInput - enqueueAndGetInference must succeed", async () => { + it("Empty, multi-page PDF – PathInput - enqueueAndGetResult must succeed", async () => { const source = new PathInput({ inputPath: emptyPdfPath }); const params = { modelId, @@ -99,7 +100,7 @@ describe("MindeeV2 – Client Integration Tests", () => { checkEmptyActiveOptions(inference); }).timeout(60000); - it("Filled, single-page image – PathInput - enqueueAndGetInference must succeed", async () => { + it("Filled, single-page image – PathInput - enqueueAndGetResult must succeed", async () => { const source = new PathInput({ inputPath: sampleImagePath }); const params = { modelId, @@ -138,7 +139,7 @@ describe("MindeeV2 – Client Integration Tests", () => { expect(inference.result.rawText?.pages).to.have.lengthOf(1); }).timeout(120000); - it("Filled, single-page image – Base64Input - enqueueAndGetInference must succeed", async () => { + it("Filled, single-page image – Base64Input - enqueueAndGetResult must succeed", async () => { const data = fs.readFileSync(sampleBase64Path, "utf8"); const source = new Base64Input({ inputString: data, filename: "receipt.jpg" }); const params = { @@ -193,7 +194,7 @@ describe("MindeeV2 – Client Integration Tests", () => { } }).timeout(60000); - it("HTTPS URL – enqueue & get inference must succeed", async () => { + it("HTTPS URL – enqueueAndGetResult must succeed", async () => { const url = process.env.MINDEE_V2_SE_TESTS_BLANK_PDF_URL ?? "error-no-url-found"; const source = new UrlInput({ url }); const params = new ExtractionParameters({ diff --git a/tests/v2/client.spec.ts b/tests/v2/client.spec.ts index 31d7ca61..9db91a6a 100644 --- a/tests/v2/client.spec.ts +++ b/tests/v2/client.spec.ts @@ -119,6 +119,7 @@ describe("MindeeV2 - ClientV2", () => { inputPath: path.join( V2_RESOURCE_PATH, "products", + "extraction", "financial_document", "default_sample.jpg" ), diff --git a/tests/v2/client/inferenceParameter.spec.ts b/tests/v2/client/inferenceParameter.spec.ts index 00907884..85c5ee7b 100644 --- a/tests/v2/client/inferenceParameter.spec.ts +++ b/tests/v2/client/inferenceParameter.spec.ts @@ -1,6 +1,6 @@ import { StringDict } from "@/parsing/index.js"; import path from "path"; -import { V2_RESOURCE_PATH } from "../../index.js"; +import { V2_PRODUCT_PATH } from "../../index.js"; import { expect } from "chai"; import { promises as fs } from "fs"; import { ExtractionParameters, DataSchema } from "@/v2/product/extraction/index.js"; @@ -30,7 +30,7 @@ describe("MindeeV2 - Inference Parameter", () => { describe("Data Schema", () => { before(async () => { const fileContents = await fs.readFile( - path.join(V2_RESOURCE_PATH, "inference/data_schema_replace_param.json") + path.join(V2_PRODUCT_PATH, "extraction/data_schema_replace_param.json") ); expectedDataSchemaDict = JSON.parse(fileContents.toString()); expectedDataSchemaString = JSON.stringify(expectedDataSchemaDict); diff --git a/tests/v2/parsing/inference.spec.ts b/tests/v2/parsing/extraction.spec.ts similarity index 90% rename from tests/v2/parsing/inference.spec.ts rename to tests/v2/parsing/extraction.spec.ts index a9ec5234..74c4eddc 100644 --- a/tests/v2/parsing/inference.spec.ts +++ b/tests/v2/parsing/extraction.spec.ts @@ -13,26 +13,26 @@ import { RagMetadata, RawText, } from "@/v2/parsing/index.js"; -import { V2_RESOURCE_PATH } from "../../index.js"; +import { V2_PRODUCT_PATH } from "../../index.js"; import { ExtractionResponse } from "@/v2/product/index.js"; -const findocPath = path.join(V2_RESOURCE_PATH, "products", "financial_document"); -const inferencePath = path.join(V2_RESOURCE_PATH, "inference"); -const deepNestedFieldPath = path.join(inferencePath, "deep_nested_fields.json"); -const standardFieldPath = path.join(inferencePath, "standard_field_types.json"); -const standardFieldRstPath = path.join(inferencePath, "standard_field_types.rst"); +const findocPath = path.join(V2_PRODUCT_PATH, "extraction", "financial_document"); +const extractionPath = path.join(V2_PRODUCT_PATH, "extraction"); +const deepNestedFieldPath = path.join(extractionPath, "deep_nested_fields.json"); +const standardFieldPath = path.join(extractionPath, "standard_field_types.json"); +const standardFieldRstPath = path.join(extractionPath, "standard_field_types.rst"); const locationFieldPath = path.join(findocPath, "complete_with_coordinates.json"); -async function loadV2Inference(resourcePath: string): Promise { +async function loadV2Extraction(resourcePath: string): Promise { const localResponse = new LocalResponse(resourcePath); await localResponse.init(); return localResponse.deserializeResponse(ExtractionResponse); } -describe("MindeeV2 - Inference Response", async () => { +describe("MindeeV2 - Extraction Response", async () => { describe("Financial Document", async () => { it("should load a blank inference with valid properties", async () => { - const response = await loadV2Inference( + const response = await loadV2Extraction( path.join(findocPath, "blank.json") ); const fields = response.inference.result.fields; @@ -64,7 +64,7 @@ describe("MindeeV2 - Inference Response", async () => { }); it("should load a complete inference with valid properties", async () => { - const response = await loadV2Inference( + const response = await loadV2Extraction( path.join(findocPath, "complete.json") ); const inference = response.inference; @@ -129,7 +129,7 @@ describe("MindeeV2 - Inference Response", async () => { describe("Deeply Nested", async () => { it("should load a deep nested object", async () => { - const response = await loadV2Inference(deepNestedFieldPath); + const response = await loadV2Extraction(deepNestedFieldPath); const fields = response.inference.result.fields; expect(fields.get("field_simple")).to.be.an.instanceof(SimpleField); expect(fields.get("field_object")).to.be.an.instanceof(ObjectField); @@ -165,7 +165,7 @@ describe("MindeeV2 - Inference Response", async () => { describe("Standard Field Types", async () => { it("should recognize simple fields", async () => { - const response = await loadV2Inference(standardFieldPath); + const response = await loadV2Extraction(standardFieldPath); const fields = response.inference.result.fields; expect(fields.get("field_simple_string")).to.be.instanceOf(SimpleField); @@ -211,7 +211,7 @@ describe("MindeeV2 - Inference Response", async () => { }); it("should recognize simple list fields", async () => { - const response = await loadV2Inference(standardFieldPath); + const response = await loadV2Extraction(standardFieldPath); const fields = response.inference.result.fields; expect(fields.get("field_simple_list")).to.be.instanceOf(ListField); @@ -226,7 +226,7 @@ describe("MindeeV2 - Inference Response", async () => { }); it("should recognize object fields", async () => { - const response = await loadV2Inference(standardFieldPath); + const response = await loadV2Extraction(standardFieldPath); const fields = response.inference.result.fields; expect(fields.get("field_object")).to.be.instanceOf(ObjectField); @@ -246,7 +246,7 @@ describe("MindeeV2 - Inference Response", async () => { }); it("should recognize object list fields", async () => { - const response = await loadV2Inference(standardFieldPath); + const response = await loadV2Extraction(standardFieldPath); const fields = response.inference.result.fields; expect(fields.get("field_object_list")).to.be.instanceOf(ListField); @@ -272,8 +272,8 @@ describe("MindeeV2 - Inference Response", async () => { describe("Raw Text", async () => { it("raw text should be exposed", async () => { - const response = await loadV2Inference( - path.join(inferencePath, "raw_texts.json") + const response = await loadV2Extraction( + path.join(extractionPath, "raw_texts.json") ); expect(response.inference.result.rag).to.be.undefined; @@ -291,8 +291,8 @@ describe("MindeeV2 - Inference Response", async () => { describe("RAG Metadata", async () => { it("RAG metadata when matched", async () => { - const response = await loadV2Inference( - path.join(inferencePath, "rag_matched.json") + const response = await loadV2Extraction( + path.join(extractionPath, "rag_matched.json") ); const rag = response.inference.result.rag; expect(rag).to.be.instanceOf(RagMetadata); @@ -300,8 +300,8 @@ describe("MindeeV2 - Inference Response", async () => { }); it("RAG metadata when not matched", async () => { - const response = await loadV2Inference( - path.join(inferencePath, "rag_not_matched.json") + const response = await loadV2Extraction( + path.join(extractionPath, "rag_not_matched.json") ); const rag = response.inference.result.rag; expect(rag).to.be.instanceOf(RagMetadata); @@ -311,7 +311,7 @@ describe("MindeeV2 - Inference Response", async () => { describe("RST Display", async () => { it("to be properly exposed", async () => { - const response = await loadV2Inference(standardFieldPath); + const response = await loadV2Extraction(standardFieldPath); const rstString = await fs.readFile(standardFieldRstPath, "utf8"); expect(response.inference).to.not.be.null; @@ -321,7 +321,7 @@ describe("MindeeV2 - Inference Response", async () => { describe("Field Locations and Confidence", async () => { it("to be properly exposed", async () => { - const response = await loadV2Inference(locationFieldPath); + const response = await loadV2Extraction(locationFieldPath); expect(response.inference).to.not.be.null; diff --git a/tests/v2/parsing/localResponse.spec.ts b/tests/v2/parsing/localResponse.spec.ts index 2fda9a8c..fd618468 100644 --- a/tests/v2/parsing/localResponse.spec.ts +++ b/tests/v2/parsing/localResponse.spec.ts @@ -3,13 +3,13 @@ import { expect } from "chai"; import { LocalResponse } from "@/v2/index.js"; import path from "path"; -import { V2_RESOURCE_PATH } from "../../index.js"; +import { V2_PRODUCT_PATH } from "../../index.js"; import { Buffer } from "node:buffer"; import { ExtractionResponse } from "@/v2/product/index.js"; const signature: string = "e51bdf80f1a08ed44ee161100fc30a25cb35b4ede671b0a575dc9064a3f5dbf1"; const dummySecretKey: string = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"; -const filePath: string = path.join(V2_RESOURCE_PATH, "inference/standard_field_types.json"); +const filePath: string = path.join(V2_PRODUCT_PATH, "extraction/standard_field_types.json"); async function assertLocalResponse(localResponse: LocalResponse) { await localResponse.init(); @@ -49,8 +49,8 @@ describe("MindeeV2 - Load Local Response", () => { it("loading an inference works on catalog model", async () => { const jsonPath = path.join( - V2_RESOURCE_PATH, - "products", + V2_PRODUCT_PATH, + "extraction", "financial_document", "complete.json" );