mindee 5.0.0-alpha1 → 5.0.0-alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/package.json +14 -19
- package/src/geometry/bbox.d.ts +9 -0
- package/src/geometry/bbox.js +13 -0
- package/src/geometry/boundingBox.d.ts +0 -8
- package/src/geometry/boundingBox.js +0 -9
- package/src/geometry/boundingBoxUtils.d.ts +2 -1
- package/src/geometry/boundingBoxUtils.js +2 -1
- package/src/geometry/index.d.ts +2 -1
- package/src/geometry/index.js +2 -1
- package/src/image/extractedImage.js +2 -2
- package/src/index.d.ts +4 -1
- package/src/index.js +6 -1
- package/src/pdf/pdfCompressor.js +3 -3
- package/src/v1/parsing/common/ocrPage.js +5 -4
- package/src/v1/parsing/standard/index.d.ts +1 -1
- package/src/v1/parsing/standard/index.js +1 -0
- package/src/v1/parsing/standard/word.d.ts +6 -4
- package/src/v1/parsing/standard/word.js +9 -1
- package/src/v2/index.d.ts +2 -3
- package/src/v2/index.js +1 -2
- package/src/v2/parsing/inference/baseInference.d.ts +1 -1
- package/src/v2/parsing/inference/baseInference.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha2 - 2026-01-16
|
|
4
|
+
### Changes
|
|
5
|
+
* :recycle: use node test methods
|
|
6
|
+
* :recycle: v1 ocr word should be a class
|
|
7
|
+
* :recycle: make v2 products top level
|
|
8
|
+
* :bug: fix for optional node-poppler
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## 5.0.0-alpha1 - 2026-01-13
|
|
12
|
+
### :boom: :recycle: base for v5
|
|
13
|
+
* :arrow_up: update file-type
|
|
14
|
+
* :recycle: migrate to ES modules (node18)
|
|
15
|
+
* :coffin: remove support for obsolete/unused products:
|
|
16
|
+
* API builder (no longer maintained, use v2)
|
|
17
|
+
* :coffin: remove support for unused products available in v2:
|
|
18
|
+
* nutrition facts
|
|
19
|
+
* business card
|
|
20
|
+
* US healthcare cards
|
|
21
|
+
* bill of lading
|
|
22
|
+
* :coffin: remove support for unused products:
|
|
23
|
+
* delivery note
|
|
24
|
+
* payslip_fra_v2_async
|
|
25
|
+
* idcard_fr_v1
|
|
26
|
+
* ind_passport_v1_async
|
|
27
|
+
* us_mail_v3_async
|
|
28
|
+
* energy_bill_fra_v1_async
|
|
29
|
+
* french_healthcard_v1_async
|
|
30
|
+
* payslip_fra_v3_async
|
|
31
|
+
* :recycle: use undici for HTTP requests and mocking
|
|
32
|
+
* :sparkles: add ability for a user to specify their own undici `Dispatcher` instance
|
|
33
|
+
* :sparkles: add basic V2 CLI
|
|
34
|
+
* :recycle: :boom: rework of directory structure
|
|
35
|
+
* :recycle: :boom: rework input source errors
|
|
36
|
+
* :sparkles: handle abort signal stream inputs
|
|
37
|
+
* :sparkles: add support for all utility products
|
|
38
|
+
* :boom: :sparkles: move PDF and image libraries to optional dependencies
|
|
39
|
+
|
|
40
|
+
|
|
3
41
|
## v4.36.3 - 2026-01-20
|
|
4
42
|
### Fixes
|
|
5
43
|
* :bug: fix streams not loading properly
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-alpha2",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "bin/mindee.js",
|
|
@@ -10,16 +10,13 @@
|
|
|
10
10
|
"build": "tsc --build && tsc-alias",
|
|
11
11
|
"build-for-dist": "tsc --build && tsc-alias && cp LICENSE README.md CHANGELOG.md ./dist",
|
|
12
12
|
"clean": "rm -rf ./dist ./docs/_build",
|
|
13
|
-
"test": "mocha --grep
|
|
14
|
-
"test-light": "mocha --grep
|
|
15
|
-
"test-integration": "mocha --grep
|
|
16
|
-
"test-integration-light": "mocha --grep
|
|
17
|
-
"test-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"test-v2-light": "mocha --grep \"#includeOptionalDeps\" --invert \"tests/v2/**/*.spec.ts\"",
|
|
21
|
-
"lint": "tsc --noEmit && eslint './src/**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'",
|
|
22
|
-
"lint-fix": "eslint './src/**/*.ts' --fix",
|
|
13
|
+
"test": "mocha --grep '#OptionalDepsRemoved' --invert 'tests/**/*.spec.ts'",
|
|
14
|
+
"test-light": "mocha --grep '#OptionalDepsRequired' --invert 'tests/**/*.spec.ts'",
|
|
15
|
+
"test-integration": "mocha --grep '#OptionalDepsRemoved' --invert 'tests/**/*.integration.ts'",
|
|
16
|
+
"test-integration-light": "mocha --grep '#OptionalDepsRequired' --invert 'tests/**/*.integration.ts'",
|
|
17
|
+
"test-v2": "tsc --noEmit && node --import tsx --test 'tests/v2/**/*.spec.ts'",
|
|
18
|
+
"lint": "tsc --noEmit && eslint --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
|
|
19
|
+
"lint-fix": "eslint --fix --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
|
|
23
20
|
"docs": "typedoc --out docs/_build ./src/index.ts",
|
|
24
21
|
"docs-for-dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/"
|
|
25
22
|
},
|
|
@@ -47,25 +44,22 @@
|
|
|
47
44
|
},
|
|
48
45
|
"homepage": "https://mindee.com/",
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"@types/chai": "^5.2.3",
|
|
51
47
|
"@types/mocha": "^10.0.10",
|
|
52
48
|
"@types/node": "^18.19.130",
|
|
53
49
|
"@types/tmp": "^0.2.6",
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
55
|
-
"@typescript-eslint/parser": "^8.
|
|
56
|
-
"chai": "^6.2.2",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
51
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
57
52
|
"eslint": "^9.39.2",
|
|
58
|
-
"eslint-plugin-jsdoc": "^
|
|
53
|
+
"eslint-plugin-jsdoc": "^52.0.4",
|
|
59
54
|
"mocha": "^11.7.5",
|
|
60
55
|
"tsc-alias": "^1.8.16",
|
|
61
56
|
"tsx": "^4.21.0",
|
|
62
|
-
"typedoc": "~0.28.
|
|
57
|
+
"typedoc": "~0.28.16",
|
|
63
58
|
"typescript": "^5.9.3"
|
|
64
59
|
},
|
|
65
60
|
"dependencies": {
|
|
66
61
|
"commander": "~9.4.1",
|
|
67
62
|
"file-type": "^19.6.0",
|
|
68
|
-
"node-poppler": "^7.2.4",
|
|
69
63
|
"tmp": "^0.2.3",
|
|
70
64
|
"tslib": "^2.8.1",
|
|
71
65
|
"undici": "^6.23.0"
|
|
@@ -73,7 +67,8 @@
|
|
|
73
67
|
"optionalDependencies": {
|
|
74
68
|
"sharp": "~0.34.5",
|
|
75
69
|
"@cantoo/pdf-lib": "^2.3.2",
|
|
76
|
-
"pdf.js-extract": "^0.2.1"
|
|
70
|
+
"pdf.js-extract": "^0.2.1",
|
|
71
|
+
"node-poppler": "^7.2.4"
|
|
77
72
|
},
|
|
78
73
|
"keywords": [
|
|
79
74
|
"typescript",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
|
|
2
|
+
export declare class BBox {
|
|
3
|
+
xMin: number;
|
|
4
|
+
yMin: number;
|
|
5
|
+
xMax: number;
|
|
6
|
+
yMax: number;
|
|
7
|
+
constructor(xMin: number, yMin: number, xMax: number, yMax: number);
|
|
8
|
+
mergeBbox(bbox: BBox): BBox;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeBbox } from "../geometry/boundingBoxUtils.js";
|
|
2
|
+
/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
|
|
3
|
+
export class BBox {
|
|
4
|
+
constructor(xMin, yMin, xMax, yMax) {
|
|
5
|
+
this.xMin = xMin;
|
|
6
|
+
this.yMin = yMin;
|
|
7
|
+
this.xMax = xMax;
|
|
8
|
+
this.yMax = yMax;
|
|
9
|
+
}
|
|
10
|
+
mergeBbox(bbox) {
|
|
11
|
+
return mergeBbox(this, bbox);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Point } from "./point.js";
|
|
2
2
|
import { Polygon } from "./polygon.js";
|
|
3
|
-
/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
|
|
4
|
-
export declare class BBox {
|
|
5
|
-
xMin: number;
|
|
6
|
-
yMin: number;
|
|
7
|
-
xMax: number;
|
|
8
|
-
yMax: number;
|
|
9
|
-
constructor(xMin: number, yMin: number, xMax: number, yMax: number);
|
|
10
|
-
}
|
|
11
3
|
/** A bounding box defined by 4 points. */
|
|
12
4
|
export declare class BoundingBox extends Polygon {
|
|
13
5
|
constructor(topLeft: Point, topRight: Point, bottomRight: Point, bottomLeft: Point);
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { Polygon } from "./polygon.js";
|
|
2
|
-
/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
|
|
3
|
-
export class BBox {
|
|
4
|
-
constructor(xMin, yMin, xMax, yMax) {
|
|
5
|
-
this.xMin = xMin;
|
|
6
|
-
this.yMin = yMin;
|
|
7
|
-
this.xMax = xMax;
|
|
8
|
-
this.yMax = yMax;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
2
|
/** A bounding box defined by 4 points. */
|
|
12
3
|
export class BoundingBox extends Polygon {
|
|
13
4
|
constructor(topLeft, topRight, bottomRight, bottomLeft) {
|
package/src/geometry/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Polygon } from "./polygon.js";
|
|
2
2
|
export { compareOnX, compareOnY, getCentroid, isPointInPolygonX, isPointInPolygonY, relativeX, relativeY, getMinMaxX, getMinMaxY, } from "./polygonUtils.js";
|
|
3
|
-
export { BoundingBox
|
|
3
|
+
export { BoundingBox } from "./boundingBox.js";
|
|
4
|
+
export { BBox } from "./bbox.js";
|
|
4
5
|
export { getBbox, getBBoxForPolygons, getBoundingBox, getBoundingBoxFromBBox, mergeBbox, } from "./boundingBoxUtils.js";
|
|
5
6
|
export type { MinMax } from "./minMax.js";
|
|
6
7
|
export type { Point } from "./point.js";
|
package/src/geometry/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Polygon } from "./polygon.js";
|
|
2
2
|
export { compareOnX, compareOnY, getCentroid, isPointInPolygonX, isPointInPolygonY, relativeX, relativeY, getMinMaxX, getMinMaxY, } from "./polygonUtils.js";
|
|
3
|
-
export { BoundingBox
|
|
3
|
+
export { BoundingBox } from "./boundingBox.js";
|
|
4
|
+
export { BBox } from "./bbox.js";
|
|
4
5
|
export { getBbox, getBBoxForPolygons, getBoundingBox, getBoundingBoxFromBBox, mergeBbox, } from "./boundingBoxUtils.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { MindeeError } from "../errors/index.js";
|
|
3
3
|
import { writeFileSync } from "node:fs";
|
|
4
|
+
import { writeFile } from "fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { logger } from "../logger.js";
|
|
6
6
|
import { BufferInput, MIMETYPES } from "../input/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { logger } from "../logger.js";
|
|
8
8
|
import { loadOptionalDependency } from "../dependency/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* Generic class for image extraction
|
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export { InputSource, Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput, PageOptionsOperation, } from "./input/index.js";
|
|
2
2
|
export type { PageOptions } from "./input/index.js";
|
|
3
3
|
export * as image from "./image/index.js";
|
|
4
|
+
export * as pdf from "./pdf/index.js";
|
|
5
|
+
export * as geometry from "./geometry/index.js";
|
|
4
6
|
export * as v1 from "./v1/index.js";
|
|
5
7
|
export * as v2 from "./v2/index.js";
|
|
6
|
-
export
|
|
8
|
+
export * as product from "./v2/product/index.js";
|
|
9
|
+
export { Client, JobResponse, ErrorResponse, } from "./v2/index.js";
|
|
7
10
|
export type { PollingOptions } from "./v2/index.js";
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
// Core
|
|
1
2
|
export { InputSource, Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput, PageOptionsOperation, } from "./input/index.js";
|
|
2
3
|
export * as image from "./image/index.js";
|
|
4
|
+
export * as pdf from "./pdf/index.js";
|
|
5
|
+
export * as geometry from "./geometry/index.js";
|
|
3
6
|
// V1
|
|
4
7
|
export * as v1 from "./v1/index.js";
|
|
5
8
|
// V2
|
|
6
9
|
export * as v2 from "./v2/index.js";
|
|
7
|
-
|
|
10
|
+
// Consider v2 the default
|
|
11
|
+
export * as product from "./v2/product/index.js";
|
|
12
|
+
export { Client, JobResponse, ErrorResponse, } from "./v2/index.js";
|
package/src/pdf/pdfCompressor.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logger } from "../logger.js";
|
|
2
2
|
import tmp from "tmp";
|
|
3
|
-
import { extractTextFromPdf, hasSourceText } from "./pdfUtils.js";
|
|
4
3
|
import * as fs from "node:fs";
|
|
5
4
|
import { compressImage } from "../image/index.js";
|
|
6
5
|
import { loadOptionalDependency } from "../dependency/index.js";
|
|
6
|
+
import { extractTextFromPdf, hasSourceText } from "./pdfUtils.js";
|
|
7
7
|
let pdfLib = null;
|
|
8
8
|
async function getPdfLib() {
|
|
9
9
|
if (!pdfLib) {
|
|
@@ -33,8 +33,8 @@ export async function compressPdf(pdfData, imageQuality = 85, forceSourceTextCom
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
logger.warn("Found text inside of the provided PDF file.
|
|
37
|
-
|
|
36
|
+
logger.warn("Found text inside of the provided PDF file. " +
|
|
37
|
+
"Compression operation aborted since disableSourceText is set to 'true'.");
|
|
38
38
|
return pdfData;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -4,7 +4,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _OcrPage_instances, _OcrPage_areWordsOnSameLine, _OcrPage_toLines;
|
|
7
|
-
import { compareOnX, compareOnY,
|
|
7
|
+
import { compareOnX, compareOnY, isPointInPolygonY, } from "../../../geometry/index.js";
|
|
8
|
+
import { Word } from "../../../v1/parsing/standard/index.js";
|
|
8
9
|
export class OcrPage {
|
|
9
10
|
constructor(rawPrediction) {
|
|
10
11
|
_OcrPage_instances.add(this);
|
|
@@ -15,7 +16,7 @@ export class OcrPage {
|
|
|
15
16
|
const allWords = [];
|
|
16
17
|
if (rawPrediction["all_words"]) {
|
|
17
18
|
rawPrediction["all_words"].forEach((word) => {
|
|
18
|
-
allWords.push(word);
|
|
19
|
+
allWords.push(new Word(word));
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
this.allWords = allWords.sort((word1, word2) => compareOnY(word1.polygon, word2.polygon));
|
|
@@ -40,8 +41,8 @@ export class OcrPage {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
_OcrPage_instances = new WeakSet(), _OcrPage_areWordsOnSameLine = function _OcrPage_areWordsOnSameLine(currentWord, nextWord) {
|
|
43
|
-
const currentInNext = isPointInPolygonY(
|
|
44
|
-
const nextInCurrent = isPointInPolygonY(
|
|
44
|
+
const currentInNext = isPointInPolygonY(currentWord.polygon.getCentroid(), nextWord.polygon);
|
|
45
|
+
const nextInCurrent = isPointInPolygonY(nextWord.polygon.getCentroid(), currentWord.polygon);
|
|
45
46
|
return nextInCurrent || currentInNext;
|
|
46
47
|
}, _OcrPage_toLines = function _OcrPage_toLines() {
|
|
47
48
|
const lines = [];
|
|
@@ -12,4 +12,4 @@ export { Taxes, TaxField } from "./tax.js";
|
|
|
12
12
|
export { StringField } from "./text.js";
|
|
13
13
|
export { PaymentDetailsField } from "./paymentDetails.js";
|
|
14
14
|
export { PositionField } from "./position.js";
|
|
15
|
-
export
|
|
15
|
+
export { Word } from "./word.js";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Polygon } from "../../../geometry/index.js";
|
|
2
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
3
|
+
export declare class Word {
|
|
3
4
|
/**
|
|
4
5
|
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
5
6
|
* the field in the document.
|
|
6
7
|
*/
|
|
7
|
-
polygon:
|
|
8
|
+
polygon: Polygon;
|
|
8
9
|
text: string;
|
|
9
10
|
confidence: number;
|
|
10
|
-
|
|
11
|
+
constructor(rawPrediction: StringDict);
|
|
12
|
+
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { Polygon } from "../../../geometry/index.js";
|
|
2
|
+
export class Word {
|
|
3
|
+
constructor(rawPrediction) {
|
|
4
|
+
this.polygon = new Polygon(...rawPrediction["polygon"]);
|
|
5
|
+
this.text = rawPrediction["text"];
|
|
6
|
+
this.confidence = rawPrediction["confidence"];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
;
|
package/src/v2/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * as http from "./http/index.js";
|
|
2
2
|
export * as parsing from "./parsing/index.js";
|
|
3
3
|
export * as product from "./product/index.js";
|
|
4
|
-
export { LocalResponse } from "./parsing/localResponse.js";
|
|
5
4
|
export { Client } from "./client.js";
|
|
6
|
-
export {
|
|
7
|
-
export type { PollingOptions } from "./client/index.js";
|
|
5
|
+
export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
|
|
6
|
+
export type { PollingOptions, BaseParameters } from "./client/index.js";
|
package/src/v2/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * as http from "./http/index.js";
|
|
2
2
|
export * as parsing from "./parsing/index.js";
|
|
3
3
|
export * as product from "./product/index.js";
|
|
4
|
-
export { LocalResponse } from "./parsing/localResponse.js";
|
|
5
4
|
export { Client } from "./client.js";
|
|
6
|
-
export {
|
|
5
|
+
export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InferenceModel } from "./inferenceModel.js";
|
|
2
|
-
import { InferenceFile } from "
|
|
2
|
+
import { InferenceFile } from "./inferenceFile.js";
|
|
3
3
|
import { StringDict } from "../../../parsing/index.js";
|
|
4
4
|
export declare abstract class BaseInference {
|
|
5
5
|
/**
|