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
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default [{
...globals.mocha,
Promise: true,
},

parser: tsParser,
},

Expand Down Expand Up @@ -78,5 +77,6 @@ export default [{
"no-unexpected-multiline": "error",
indent: ["error", 2],
"eol-last": "error",
"preserve-caught-error": "off",
},
}];
375 changes: 159 additions & 216 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
},
"dependencies": {
"commander": "^14.0.3",
"file-type": "^21.3.0",
"tmp": "^0.2.3",
"tslib": "^2.8.1",
"file-type": "^21.3.1",
"tmp": "^0.2.5",
"undici": ">=6.23.0 <8.0.0"
},
"optionalDependencies": {
Expand All @@ -60,15 +59,19 @@
"sharp": "~0.34.5"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.5",
"@eslint/js": "^10.0.1",
"@types/mocha": "^10.0.10",
"@types/node": "^20.19.35",
"@types/node": "^20.19.37",
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^8.56.1",
"@typescript-eslint/parser": "^8.56.1",
"eslint": "^9.39.3",
"@typescript-eslint/eslint-plugin": "^8.57.0",
"@typescript-eslint/parser": "^8.57.0",
"eslint": "^10.0.3",
"eslint-plugin-jsdoc": "^62.7.1",
"globals": "^17.4.0",
"mocha": "^11.7.5",
"tsc-alias": "^1.8.16",
"tslib": "^2.8.1",
"tsx": "^4.21.0",
"typedoc": "^0.28.17",
"typescript": "^5.9.3"
Expand Down
7 changes: 4 additions & 3 deletions tests/v1/extraction/invoiceSplitter.integration.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import assert from "node:assert/strict";
import { beforeEach, describe, it } from "node:test";
import { promises as fs } from "fs";
import path from "path";
import * as mindee from "@/index.js";
import { InvoiceSplitterV1 } from "@/v1/product/index.js";
import { levenshteinRatio } from "../../testingUtilities.js";
import { V1_PRODUCT_PATH } from "../../index.js";

describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", async () => {
describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", { timeout: 60000 }, () => {
let client: mindee.v1.Client;

beforeEach(() => {
Expand Down Expand Up @@ -44,7 +45,7 @@ describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", asy
testStringRstInvoice.toString()
) >= 0.90
);
}).timeout(60000);
});
});

describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRemoved", function () {
Expand Down Expand Up @@ -79,5 +80,5 @@ describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRemoved", func
throw error;
}
}
}).timeout(60000);
});
});
19 changes: 5 additions & 14 deletions tests/v1/extraction/multiReceipts.integration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { before, describe, it } from "node:test";
import assert from "node:assert/strict";
import * as path from "path";
import { Client } from "@/v1/index.js";
Expand All @@ -10,17 +11,8 @@ import { setTimeout } from "node:timers/promises";
const apiKey = process.env.MINDEE_API_KEY;
let client: Client;
let sourceDoc: LocalInputSource;
describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequired", () => {
describe("A Multi-Receipt Image", () => {
before(async () => {
sourceDoc = new PathInput({
inputPath: path.join(V1_PRODUCT_PATH, "multi_receipts_detector/default_sample.jpg"),
});
await sourceDoc.init();
client = new Client({ apiKey });
});
});

describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequired", { timeout: 60000 }, () =>
{
describe("A Multi-Receipt PDF", () => {
before(async () => {
sourceDoc = new PathInput({
Expand Down Expand Up @@ -74,10 +66,9 @@ describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequire
assert.strictEqual(fifthPrediction.lineItems.length, 1);
assert.strictEqual(fifthPrediction.lineItems[0].totalAmount, 16.5);

}).timeout(60000);
});
});


describe("A Single-Receipt Image", () => {
before(async () => {
sourceDoc = new PathInput({
Expand All @@ -97,6 +88,6 @@ describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequire
assert.strictEqual(receiptResult.document.inference.prediction.lineItems[0].totalAmount, 10.2);
assert.strictEqual(receiptResult.document.inference.prediction.taxes.length, 1);
assert.strictEqual(receiptResult.document.inference.prediction.taxes[0].value, 1.7);
}).timeout(60000);
});
});
});
14 changes: 6 additions & 8 deletions tests/v1/extras/extras.integration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { beforeEach, describe, it } from "node:test";
import assert from "node:assert/strict";
import * as mindee from "@/index.js";
import path from "path";
import { V1_PRODUCT_PATH } from "../../index.js";


describe("MindeeV1 - Integration - Extras", async () => {
describe("MindeeV1 - Integration - Extras", { timeout: 70000 }, () => {
let client: mindee.v1.Client;

beforeEach(() => {
Expand All @@ -20,7 +21,7 @@ describe("MindeeV1 - Integration - Extras", async () => {
mindee.v1.product.InvoiceV4, sample, { cropper: true }
);
assert.ok(response.document.inference.pages[0]?.extras?.cropper);
}).timeout(70000);
});

it("should send full text OCR extra", async () => {
const sample = new mindee.PathInput({
Expand All @@ -31,8 +32,7 @@ describe("MindeeV1 - Integration - Extras", async () => {
mindee.v1.product.InternationalIdV2, sample, { fullText: true }
);
assert.ok(response.document?.extras?.fullTextOcr);

}).timeout(70000);
});

it("should send OCR words synchronously", async () => {
const sample = new mindee.PathInput({
Expand All @@ -44,8 +44,7 @@ describe("MindeeV1 - Integration - Extras", async () => {
);
assert.ok(response.document?.ocr);
assert.ok(response.document?.ocr?.toString());

}).timeout(70000);
});

it("should send OCR words asynchronously", async () => {
const sample = new mindee.PathInput({
Expand All @@ -57,6 +56,5 @@ describe("MindeeV1 - Integration - Extras", async () => {
);
assert.ok(response.document?.ocr);
assert.ok(response.document?.ocr?.toString());

}).timeout(70000);
});
});
23 changes: 12 additions & 11 deletions tests/v1/input/sources.integration.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as mindee from "@/index.js";
import { InvoiceV4 } from "@/v1/product/index.js";
import { beforeEach, describe, it } from "node:test";
import assert from "node:assert";
import path from "path";
import { promises as fs } from "fs";
import { createReadStream } from "node:fs";
import path from "path";
import * as mindee from "@/index.js";
import { InvoiceV4 } from "@/v1/product/index.js";
import { V1_PRODUCT_PATH } from "../../index.js";
import { PathInput, Base64Input, BufferInput, BytesInput, UrlInput } from "@/index.js";

describe("MindeeV1 - Integration - File Input", async () => {
describe("MindeeV1 - Integration - File Input", { timeout: 60000 }, () => {
let client: mindee.v1.Client;
let filePath: string;

Expand All @@ -21,15 +22,15 @@ describe("MindeeV1 - Integration - File Input", async () => {
await pathInput.init();
const result = await client.parse(InvoiceV4, pathInput);
assert.strictEqual(typeof result.document.id, "string");
}).timeout(60000);
});

it("should send a base64 document", async () => {
const content = await fs.readFile(filePath);
const base64Content = content.toString("base64");
const base64Input = new Base64Input({ inputString: base64Content, filename: "testFile.jpg" });
const result = await client.parse(InvoiceV4, base64Input);
assert.strictEqual(typeof result.document.id, "string");
}).timeout(60000);
});

it("should send a document from a readable stream", async () => {
const fileStream = createReadStream(filePath);
Expand All @@ -41,23 +42,23 @@ describe("MindeeV1 - Integration - File Input", async () => {
const streamInput = new BufferInput({ buffer: buffer, filename: "testFile.jpg" });
const result = await client.parse(InvoiceV4, streamInput);
assert.strictEqual(typeof result.document.id, "string");
}).timeout(60000);
});


it("should send a document from bytes", async () => {
const inputBytes = await fs.readFile(filePath);
const bytesInput = new BytesInput({ inputBytes: inputBytes, filename: "testFile.jpg" });
const result = await client.parse(InvoiceV4, bytesInput);
assert.strictEqual(typeof result.document.id, "string");
}).timeout(60000);
});

it("should send a document from buffer", async () => {
const buffer = await fs.readFile(filePath);
const bufferInput = new BufferInput({ buffer: buffer, filename: "testFile.jpg" });
await bufferInput.init();
const result = await client.parse(InvoiceV4, bufferInput);
assert.strictEqual(typeof result.document.id, "string");
}).timeout(60000);
});

it("should send a document from a URL", async () => {
const url = "https://raw.githubusercontent.com/mindee/client-lib-test-data/" +
Expand All @@ -66,5 +67,5 @@ describe("MindeeV1 - Integration - File Input", async () => {
await urlInput.init();
const result = await client.parse(InvoiceV4, urlInput);
assert.strictEqual(typeof result.document.id, "string");
}).timeout(60000);
}).timeout(60000);
});
});
5 changes: 3 additions & 2 deletions tests/v1/input/urlInputSource.integration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { describe, it } from "node:test";
import assert from "node:assert";
import { UrlInput } from "@/index.js";
import { Client } from "@/v1/index.js";
import { InvoiceV4 } from "@/v1/product/index.js";

describe("MindeeV1 - Integration - URL Input", async () => {
describe("MindeeV1 - Integration - URL Input", { timeout: 60000 }, () => {
it("should retrieve and parse a remote file with redirection", async () => {
const apiKey = process.env.MINDEE_API_KEY;
if (!apiKey) {
Expand All @@ -20,5 +21,5 @@ describe("MindeeV1 - Integration - URL Input", async () => {
assert.strictEqual(localInput.filename, "invoice_5p.pdf");
const result = await client.parse(InvoiceV4, localInput);
assert.strictEqual(result.document.nPages, 5);
}).timeout(60000);
});
});
18 changes: 9 additions & 9 deletions tests/v1/workflows/workflow.integration.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { beforeEach, describe, it } from "node:test";
import assert from "node:assert";
import path from "path";
import * as mindee from "@/index.js";
import { ExecutionPriority } from "@/v1/parsing/common/index.js";
import assert from "node:assert";
import { LocalInputSource } from "@/input/index.js";
import { OptionalAsyncOptions } from "@/v1/index.js";
import { FinancialDocumentV1 } from "@/v1/product/index.js";
import { RAGExtra } from "@/v1/parsing/common/extras/ragExtra.js";
import path from "path";
import { V1_PRODUCT_PATH } from "../../index.js";

describe("MindeeV1 - Integration - Workflow calls", () => {
describe("MindeeV1 - Integration - Workflow calls", { timeout: 60000 }, () => {
let client: mindee.v1.Client;
let sample: LocalInputSource;
let workflowId: string;
Expand All @@ -33,7 +34,7 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
{ alias: `node-${currentDateTime}`, priority: ExecutionPriority.low, rag: true });
assert.strictEqual(response.execution.priority, ExecutionPriority.low);
assert.strictEqual(response.execution.file.alias, `node-${currentDateTime}`);
}).timeout(60000);
});

it("should poll with RAG disabled", async () => {
const asyncParams: OptionalAsyncOptions = {
Expand All @@ -46,7 +47,7 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
);
assert.ok(response.document?.toString());
assert.strictEqual(response.document?.inference.extras?.rag, undefined);
}).timeout(60000);
});

it("should poll with RAG disabled and OCR words", async () => {
const asyncParams: OptionalAsyncOptions = {
Expand All @@ -62,7 +63,7 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
assert.strictEqual(response.document?.inference.extras?.rag, undefined);
assert.ok(response.document?.ocr);
assert.ok(response.document?.ocr?.toString());
}).timeout(60000);
});

it("should poll with RAG enabled", async () => {
const asyncParams: OptionalAsyncOptions = {
Expand All @@ -74,10 +75,9 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
sample,
asyncParams
);

assert.ok(response.document?.toString());
assert.ok(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId);
}).timeout(60000);
});

it("should poll with RAG enabled and OCR words", async () => {
const asyncParams: OptionalAsyncOptions = {
Expand All @@ -94,5 +94,5 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
assert.ok(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId);
assert.ok(response.document?.ocr);
assert.ok(response.document?.ocr?.toString());
}).timeout(60000);
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"baseUrl": "./",
"declaration": true,
"importHelpers": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
Expand Down