diff --git a/docs/code_samples/bank_account_details_v1.txt b/docs/code_samples/bank_account_details_v1.txt deleted file mode 100644 index 3c9eb26f4..000000000 --- a/docs/code_samples/bank_account_details_v1.txt +++ /dev/null @@ -1,27 +0,0 @@ -// If you're on CommonJS: -const mindee = require("mindee"); - -// ESM or TypeScript (Recommended) -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.v1.product.fr.BankAccountDetailsV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/bank_check_v1.txt b/docs/code_samples/bank_check_v1.txt deleted file mode 100644 index 7b44b87b8..000000000 --- a/docs/code_samples/bank_check_v1.txt +++ /dev/null @@ -1,27 +0,0 @@ -// ESM or TypeScript (Recommended) -import * as mindee from "mindee"; - -// If you're on CommonJS: -// const mindee = require("mindee"); - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.v1.product.us.BankCheckV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/barcode_reader_v1.txt b/docs/code_samples/barcode_reader_v1.txt deleted file mode 100644 index 6977129f5..000000000 --- a/docs/code_samples/barcode_reader_v1.txt +++ /dev/null @@ -1,27 +0,0 @@ -// ESM or TypeScript (Recommended) -import * as mindee from "mindee"; - -// If you're on CommonJS: -// const mindee = require("mindee"); - -// Init a new client -const mindeeClient = new mindee.v1.Client( - { apiKey: "my-api-key" } -); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.parse( - mindee.v1.product.BarcodeReaderV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/src/v1/product/barcodeReader/barcodeReaderV1.ts b/src/v1/product/barcodeReader/barcodeReaderV1.ts deleted file mode 100644 index 6a6ae7112..000000000 --- a/src/v1/product/barcodeReader/barcodeReaderV1.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { BarcodeReaderV1Document } from "./barcodeReaderV1Document.js"; - -/** - * Barcode Reader API version 1 inference prediction. - */ -export class BarcodeReaderV1 extends Inference { - /** - * The endpoint's name. - */ - endpointName = "barcode_reader"; - /** - * The endpoint's version. - */ - endpointVersion = "1"; - /** - * The document-level prediction. - */ - prediction: BarcodeReaderV1Document; - /** - * The document's pages. - */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new BarcodeReaderV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - BarcodeReaderV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/barcodeReader/barcodeReaderV1Document.ts b/src/v1/product/barcodeReader/barcodeReaderV1Document.ts deleted file mode 100644 index 4e7acde43..000000000 --- a/src/v1/product/barcodeReader/barcodeReaderV1Document.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "@/v1/parsing/common/index.js"; -import { StringField } from "@/v1/parsing/standard/index.js"; - -/** - * Barcode Reader API version 1.0 document data. - */ -export class BarcodeReaderV1Document implements Prediction { - /** - * List of decoded 1D barcodes. - */ - codes1D: StringField[] = []; - /** - * List of decoded 2D barcodes. - */ - codes2D: StringField[] = []; - - constructor(rawPrediction: StringDict, pageId?: number) { - if (rawPrediction["codes_1d"]) { - rawPrediction["codes_1d"].map( - (itemPrediction: StringDict) => - this.codes1D.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - } - if (rawPrediction["codes_2d"]) { - rawPrediction["codes_2d"].map( - (itemPrediction: StringDict) => - this.codes2D.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - } - } - - /** - * Default string representation. - */ - toString(): string { - const codes1D = this.codes1D.join("\n "); - const codes2D = this.codes2D.join("\n "); - const outStr = `:Barcodes 1D: ${codes1D} -:Barcodes 2D: ${codes2D}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/barcodeReader/index.ts b/src/v1/product/barcodeReader/index.ts deleted file mode 100644 index 5917e1487..000000000 --- a/src/v1/product/barcodeReader/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { BarcodeReaderV1 } from "./barcodeReaderV1.js"; -export { BarcodeReaderV1Document } from "./barcodeReaderV1Document.js"; diff --git a/src/v1/product/cliProducts.ts b/src/v1/product/cliProducts.ts index fb7d82fc7..193feaeef 100644 --- a/src/v1/product/cliProducts.ts +++ b/src/v1/product/cliProducts.ts @@ -28,16 +28,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "barcode-reader", - { - displayName: "Barcode Reader", - docClass: product.BarcodeReaderV1, - allWords: false, - async: false, - sync: true, - }, - ], [ "cropper", { @@ -158,14 +148,4 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: false, }, ], - [ - "us-bank-check", - { - displayName: "US Bank Check", - docClass: product.us.BankCheckV1, - allWords: false, - async: false, - sync: true, - }, - ], ]); diff --git a/src/v1/product/index.ts b/src/v1/product/index.ts index 32313f020..8179db7c8 100644 --- a/src/v1/product/index.ts +++ b/src/v1/product/index.ts @@ -1,6 +1,4 @@ export * as fr from "./fr/index.js"; -export * as us from "./us/index.js"; -export { BarcodeReaderV1 } from "./barcodeReader/index.js"; export { CropperV1 } from "./cropper/index.js"; export { DriverLicenseV1 } from "./driverLicense/index.js"; export { FinancialDocumentV1 } from "./financialDocument/index.js"; @@ -14,7 +12,6 @@ export { ReceiptV5 } from "./receipt/index.js"; export { ResumeV1 } from "./resume/index.js"; // not sure if we want to export these -- advanced users can import them directly -export * as barcodeReader from "./barcodeReader/index.js"; export * as cropper from "./cropper/index.js"; export * as driverLicense from "./driverLicense/index.js"; export * as financialDocument from "./financialDocument/index.js"; diff --git a/src/v1/product/us/bankCheck/bankCheckV1.ts b/src/v1/product/us/bankCheck/bankCheckV1.ts deleted file mode 100644 index 4e26babef..000000000 --- a/src/v1/product/us/bankCheck/bankCheckV1.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; -import { BankCheckV1Document } from "./bankCheckV1Document.js"; -import { BankCheckV1Page } from "./bankCheckV1Page.js"; - -/** - * Bank Check API version 1 inference prediction. - */ -export class BankCheckV1 extends Inference { - /** - * The endpoint's name. - */ - endpointName = "bank_check"; - /** - * The endpoint's version. - */ - endpointVersion = "1"; - /** - * The document-level prediction. - */ - prediction: BankCheckV1Document; - /** - * The document's pages. - */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new BankCheckV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - BankCheckV1Page, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/v1/product/us/bankCheck/bankCheckV1Document.ts b/src/v1/product/us/bankCheck/bankCheckV1Document.ts deleted file mode 100644 index e35665412..000000000 --- a/src/v1/product/us/bankCheck/bankCheckV1Document.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "@/v1/parsing/common/index.js"; -import { - AmountField, - DateField, - StringField, -} from "@/v1/parsing/standard/index.js"; - -/** - * Bank Check API version 1.1 document data. - */ -export class BankCheckV1Document implements Prediction { - /** - * The check payer's account number. - */ - accountNumber: StringField; - /** - * The amount of the check. - */ - amount: AmountField; - /** - * The issuer's check number. - */ - checkNumber: StringField; - /** - * The date the check was issued. - */ - date: DateField; - /** - * List of the check's payees (recipients). - */ - payees: StringField[] = []; - /** - * The check issuer's routing number. - */ - routingNumber: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.accountNumber = new StringField({ - prediction: rawPrediction["account_number"], - pageId: pageId, - }); - this.amount = new AmountField({ - prediction: rawPrediction["amount"], - pageId: pageId, - }); - this.checkNumber = new StringField({ - prediction: rawPrediction["check_number"], - pageId: pageId, - }); - this.date = new DateField({ - prediction: rawPrediction["date"], - pageId: pageId, - }); - if (rawPrediction["payees"]) { - rawPrediction["payees"].map( - (itemPrediction: StringDict) => - this.payees.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - } - this.routingNumber = new StringField({ - prediction: rawPrediction["routing_number"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const payees = this.payees.join("\n "); - const outStr = `:Check Issue Date: ${this.date} -:Amount: ${this.amount} -:Payees: ${payees} -:Routing Number: ${this.routingNumber} -:Account Number: ${this.accountNumber} -:Check Number: ${this.checkNumber}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/us/bankCheck/bankCheckV1Page.ts b/src/v1/product/us/bankCheck/bankCheckV1Page.ts deleted file mode 100644 index 359d7e2ab..000000000 --- a/src/v1/product/us/bankCheck/bankCheckV1Page.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { StringDict, cleanOutString } from "@/v1/parsing/common/index.js"; -import { PositionField } from "@/v1/parsing/standard/index.js"; -import { BankCheckV1Document } from "./bankCheckV1Document.js"; - -/** - * Bank Check API version 1.1 page data. - */ -export class BankCheckV1Page extends BankCheckV1Document { - /** - * The position of the check on the document. - */ - checkPosition: PositionField; - /** - * List of signature positions - */ - signaturesPositions: PositionField[] = []; - - constructor(rawPrediction: StringDict, pageId?: number) { - super(rawPrediction, pageId); - - this.checkPosition = new PositionField({ - prediction: rawPrediction["check_position"], - pageId: pageId, - }); - rawPrediction["signatures_positions"].map( - (itemPrediction: StringDict) => - this.signaturesPositions.push( - new PositionField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - } - - toString(): string { - const signaturesPositions = this.signaturesPositions.join("\n "); - let outStr = `:Check Position: ${this.checkPosition} -:Signature Positions: ${signaturesPositions}`.trimEnd(); - outStr += "\n" + super.toString(); - return cleanOutString(outStr); - } -} diff --git a/src/v1/product/us/bankCheck/index.ts b/src/v1/product/us/bankCheck/index.ts deleted file mode 100644 index 094ec0075..000000000 --- a/src/v1/product/us/bankCheck/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { BankCheckV1 } from "./bankCheckV1.js"; -export { BankCheckV1Document } from "./bankCheckV1Document.js"; -export { BankCheckV1Page } from "./bankCheckV1Page.js"; diff --git a/src/v1/product/us/index.ts b/src/v1/product/us/index.ts deleted file mode 100644 index 8eff96dc3..000000000 --- a/src/v1/product/us/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { BankCheckV1 } from "./bankCheck/index.js"; -export * as bankCheck from "./bankCheck/index.js"; diff --git a/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts b/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts deleted file mode 100644 index 80353c252..000000000 --- a/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import path from "node:path"; -import assert from "node:assert/strict"; -import { describe, it } from "node:test"; -import { promises as fs } from "node:fs"; -import * as mindee from "@/index.js"; -import { V1_PRODUCT_PATH } from "../../../index.js"; - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "barcode_reader/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "barcode_reader/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "barcode_reader/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "barcode_reader/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - BarcodeReaderV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.v1.Document(mindee.v1.product.BarcodeReaderV1, response.document); - const docPrediction = doc.inference.prediction; - assert.strictEqual(docPrediction.codes1D.length, 0); - assert.strictEqual(docPrediction.codes2D.length, 0); - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.v1.Document(mindee.v1.product.BarcodeReaderV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - assert.strictEqual(doc.toString(), docString.toString()); - }); -}); diff --git a/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts b/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts deleted file mode 100644 index dfcd74eb8..000000000 --- a/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -import path from "node:path"; -import assert from "node:assert/strict"; -import { describe, it } from "node:test"; -import { promises as fs } from "node:fs"; -import * as mindee from "@/index.js"; -import { V1_PRODUCT_PATH } from "../../../../index.js"; - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "bank_check/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "bank_check/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "bank_check/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "bank_check/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - BankCheckV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.v1.Document(mindee.v1.product.us.BankCheckV1, response.document); - const docPrediction = doc.inference.prediction; - assert.strictEqual(docPrediction.date.value, undefined); - assert.strictEqual(docPrediction.amount.value, undefined); - assert.strictEqual(docPrediction.payees.length, 0); - assert.strictEqual(docPrediction.routingNumber.value, undefined); - assert.strictEqual(docPrediction.accountNumber.value, undefined); - assert.strictEqual(docPrediction.checkNumber.value, undefined); - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.v1.Document(mindee.v1.product.us.BankCheckV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - assert.strictEqual(doc.toString(), docString.toString()); - }); - it("should load a complete page 0 prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.v1.Document(mindee.v1.product.us.BankCheckV1, response.document); - const page0 = doc.inference.pages[0]; - const docString = await fs.readFile(path.join(dataPath.page0String)); - assert.strictEqual(page0.toString(), docString.toString()); - }); -}); diff --git a/tests/v2/product/extraction/extractionParameter.spec.ts b/tests/v2/product/extraction/extractionParameters.spec.ts similarity index 78% rename from tests/v2/product/extraction/extractionParameter.spec.ts rename to tests/v2/product/extraction/extractionParameters.spec.ts index 8411b17ca..c20911498 100644 --- a/tests/v2/product/extraction/extractionParameter.spec.ts +++ b/tests/v2/product/extraction/extractionParameters.spec.ts @@ -10,16 +10,16 @@ let expectedDataSchemaDict: StringDict; let expectedDataSchemaString: string; let expectedDataSchemaObject: extraction.params.DataSchema; -describe("MindeeV2 - Extraction Parameter", () => { - const modelIdValue = "test-model-id"; +describe("MindeeV2 - Extraction Parameters", () => { + const modelId = "test-model-id"; describe("Polling Options", () => { it("should provide sensible defaults", () => { const paramsInstance = new extraction.ExtractionParameters({ - modelId: modelIdValue, + modelId: modelId, }); - assert.strictEqual(paramsInstance.modelId, modelIdValue); + assert.strictEqual(paramsInstance.modelId, modelId); }); }); @@ -33,30 +33,35 @@ describe("MindeeV2 - Extraction Parameter", () => { expectedDataSchemaObject = new extraction.params.DataSchema(expectedDataSchemaDict); }); - it("shouldn't replace when unset", () => { + it("should leave unset when not provided", () => { const params = new extraction.ExtractionParameters({ - modelId: modelIdValue, + modelId: modelId, }); assert.strictEqual(params.dataSchema, undefined); }); - it("should equate no matter the type", () => { - const paramsDict = new extraction.ExtractionParameters({ - modelId: modelIdValue, - dataSchema: expectedDataSchemaDict, - }); + it("should initialize from a string", () => { const paramsString = new extraction.ExtractionParameters({ - modelId: modelIdValue, + modelId: modelId, dataSchema: expectedDataSchemaString, }); + assert.strictEqual(paramsString.dataSchema?.toString(), expectedDataSchemaString); + }); + + it("should initialize from a dictionary", () => { + const paramsDict = new extraction.ExtractionParameters({ + modelId: modelId, + dataSchema: expectedDataSchemaDict, + }); + assert.strictEqual(JSON.stringify(paramsDict.dataSchema), expectedDataSchemaString); + }); + + it("should initialize from an object instance", () => { const paramsObject = new extraction.ExtractionParameters({ - modelId: modelIdValue, + modelId: modelId, dataSchema: expectedDataSchemaObject, }); - - assert.strictEqual(JSON.stringify(paramsDict.dataSchema), expectedDataSchemaString); assert.strictEqual(paramsObject.dataSchema?.toString(), expectedDataSchemaString); - assert.strictEqual(paramsString.dataSchema?.toString(), expectedDataSchemaString); }); }); });