mindee 5.2.0 → 5.3.1
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 +11 -0
- package/package.json +3 -3
- package/src/v2/client.d.ts +10 -0
- package/src/v2/client.js +14 -1
- package/src/v2/fileOperations/crop.js +1 -0
- package/src/v2/fileOperations/split.js +1 -0
- package/src/v2/parsing/inference/field/simpleField.d.ts +8 -0
- package/src/v2/parsing/localResponse.d.ts +17 -5
- package/src/v2/parsing/localResponse.js +17 -5
- package/src/v2/product/classification/classificationClassifier.d.ts +8 -0
- package/src/v2/product/classification/classificationClassifier.js +4 -0
- package/src/v2/product/crop/cropItem.d.ts +11 -0
- package/src/v2/product/crop/cropItem.js +4 -0
- package/src/v2/product/split/splitRange.d.ts +5 -0
- package/src/v2/product/split/splitRange.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Mindee Node.js API Library Changelog
|
|
2
2
|
|
|
3
|
+
## v5.3.1 - 2026-06-11
|
|
4
|
+
### Fixes
|
|
5
|
+
* :arrow_up: bump 'tmp' and 'file-type'
|
|
6
|
+
* :bug: :sparkles: get results by URL directly
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## v5.3.0 - 2026-05-07
|
|
10
|
+
### Changes
|
|
11
|
+
* :sparkles: Add support for extraction in crop, split, and classify products
|
|
12
|
+
|
|
13
|
+
|
|
3
14
|
## v5.2.0 - 2026-04-14
|
|
4
15
|
### Changes
|
|
5
16
|
* :sparkles: add support for crop operation for V2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mindee",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"commander": "^14.0.3",
|
|
51
|
-
"file-type": "^21.3.
|
|
52
|
-
"tmp": "^0.2.
|
|
51
|
+
"file-type": "^21.3.4",
|
|
52
|
+
"tmp": "^0.2.7",
|
|
53
53
|
"undici": ">=6.24.0 <7.0.0 || >=7.24.0 <8.0.0"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
package/src/v2/client.d.ts
CHANGED
|
@@ -41,6 +41,16 @@ export declare class Client {
|
|
|
41
41
|
* @returns a `Promise` containing the inference.
|
|
42
42
|
*/
|
|
43
43
|
getResult<P extends typeof BaseProduct>(product: P, inferenceId: string): Promise<InstanceType<P["responseClass"]>>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the result of a previously enqueued request.
|
|
46
|
+
* This method is used when manually polling the server for the result URL.
|
|
47
|
+
*
|
|
48
|
+
* @param product the product to retrieve.
|
|
49
|
+
* @param url URL as given in the `getJob()` response.
|
|
50
|
+
* @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
|
|
51
|
+
* @returns a `Promise` containing the inference.
|
|
52
|
+
*/
|
|
53
|
+
getResultByUrl<P extends typeof BaseProduct>(product: P, url: string): Promise<InstanceType<P["responseClass"]>>;
|
|
44
54
|
/**
|
|
45
55
|
* Get the processing status of a previously enqueued request.
|
|
46
56
|
* Can be used for polling.
|
package/src/v2/client.js
CHANGED
|
@@ -53,6 +53,19 @@ export class Client {
|
|
|
53
53
|
logger.debug(`Attempting to get inference with ID: ${inferenceId} using response type: ${product.name}`);
|
|
54
54
|
return await this.mindeeApi.getProductResultById(product, inferenceId);
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves the result of a previously enqueued request.
|
|
58
|
+
* This method is used when manually polling the server for the result URL.
|
|
59
|
+
*
|
|
60
|
+
* @param product the product to retrieve.
|
|
61
|
+
* @param url URL as given in the `getJob()` response.
|
|
62
|
+
* @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
|
|
63
|
+
* @returns a `Promise` containing the inference.
|
|
64
|
+
*/
|
|
65
|
+
async getResultByUrl(product, url) {
|
|
66
|
+
logger.debug(`Attempting to get inference from: ${url} using response type: ${product.name}`);
|
|
67
|
+
return await this.mindeeApi.getProductResultByUrl(product, url);
|
|
68
|
+
}
|
|
56
69
|
/**
|
|
57
70
|
* Get the processing status of a previously enqueued request.
|
|
58
71
|
* Can be used for polling.
|
|
@@ -109,7 +122,7 @@ export class Client {
|
|
|
109
122
|
if (!pollResults.job.resultUrl) {
|
|
110
123
|
throw new MindeeError("The result URL is undefined. This is a server error, try again later or contact support.");
|
|
111
124
|
}
|
|
112
|
-
return this.
|
|
125
|
+
return this.getResultByUrl(product, pollResults.job.resultUrl);
|
|
113
126
|
}
|
|
114
127
|
await setTimeout(pollingOptions.delaySec * 1000, undefined, pollingOptions.recurringTimerOptions);
|
|
115
128
|
retryCounter++;
|
|
@@ -21,6 +21,7 @@ export async function extractCrops(inputSource, crops, quality) {
|
|
|
21
21
|
if (crops.length === 0) {
|
|
22
22
|
throw new MindeeError("No crop indexes provided.");
|
|
23
23
|
}
|
|
24
|
+
await inputSource.init();
|
|
24
25
|
logger.debug("Extracting crops: " + crops.join(", "));
|
|
25
26
|
const polygonsByPage = new Map();
|
|
26
27
|
for (const crop of crops) {
|
|
@@ -23,6 +23,7 @@ export async function extractSplits(inputSource, splits) {
|
|
|
23
23
|
if (pageGroups.length === 0) {
|
|
24
24
|
throw new MindeeError("No valid split indexes provided.");
|
|
25
25
|
}
|
|
26
|
+
await inputSource.init();
|
|
26
27
|
logger.debug("Extracting splits: " + splits.join(", "));
|
|
27
28
|
const pdfExtractor = new PdfExtractor(inputSource);
|
|
28
29
|
await pdfExtractor.init();
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { StringDict } from "../../../../parsing/stringDict.js";
|
|
2
2
|
import { BaseField } from "./baseField.js";
|
|
3
3
|
export declare class SimpleField extends BaseField {
|
|
4
|
+
/**
|
|
5
|
+
* The untyped value of the field.
|
|
6
|
+
*
|
|
7
|
+
* This is usually not what you want, look at the typed accessors instead:
|
|
8
|
+
* - stringValue
|
|
9
|
+
* - numberValue
|
|
10
|
+
* - booleanValue
|
|
11
|
+
*/
|
|
4
12
|
readonly value: string | number | boolean | null;
|
|
5
13
|
constructor(serverResponse: StringDict, indentLevel?: number);
|
|
6
14
|
/**
|
|
@@ -7,13 +7,25 @@ import { BaseResponse } from "./baseResponse.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class LocalResponse extends LocalResponseBase {
|
|
9
9
|
/**
|
|
10
|
-
* Deserialize the loaded local response into
|
|
10
|
+
* Deserialize the loaded local response into a product response class.
|
|
11
11
|
*
|
|
12
|
-
* Typically used when dealing with V2 webhook callbacks
|
|
12
|
+
* Typically used when dealing with V2 webhook callbacks to parse the raw
|
|
13
|
+
* JSON payload pushed to your endpoint into a typed response object.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Pass the response class that matches the product you used when enqueuing
|
|
16
|
+
* the document. All product response classes are exported from the `mindee`
|
|
17
|
+
* package and can be used here:
|
|
18
|
+
*
|
|
19
|
+
* - `mindee.product.ExtractionResponse`
|
|
20
|
+
* - `mindee.product.ClassificationResponse`
|
|
21
|
+
* - `mindee.product.OcrResponse`
|
|
22
|
+
* - `mindee.product.CropResponse`
|
|
23
|
+
* - `mindee.product.SplitResponse`
|
|
24
|
+
*
|
|
25
|
+
* @typeParam ResponseT - A class that extends `BaseResponse`.
|
|
26
|
+
* @param responseClass - The constructor of the product response class into
|
|
27
|
+
* which the payload should be deserialized.
|
|
28
|
+
* @returns An instance of `responseClass` populated with the webhook payload.
|
|
17
29
|
* @throws MindeeError If the provided class cannot be instantiated.
|
|
18
30
|
*/
|
|
19
31
|
deserializeResponse<ResponseT extends BaseResponse>(responseClass: new (serverResponse: StringDict) => ResponseT): Promise<ResponseT>;
|
|
@@ -6,13 +6,25 @@ import { LocalResponseBase } from "../../parsing/localResponseBase.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export class LocalResponse extends LocalResponseBase {
|
|
8
8
|
/**
|
|
9
|
-
* Deserialize the loaded local response into
|
|
9
|
+
* Deserialize the loaded local response into a product response class.
|
|
10
10
|
*
|
|
11
|
-
* Typically used when dealing with V2 webhook callbacks
|
|
11
|
+
* Typically used when dealing with V2 webhook callbacks to parse the raw
|
|
12
|
+
* JSON payload pushed to your endpoint into a typed response object.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Pass the response class that matches the product you used when enqueuing
|
|
15
|
+
* the document. All product response classes are exported from the `mindee`
|
|
16
|
+
* package and can be used here:
|
|
17
|
+
*
|
|
18
|
+
* - `mindee.product.ExtractionResponse`
|
|
19
|
+
* - `mindee.product.ClassificationResponse`
|
|
20
|
+
* - `mindee.product.OcrResponse`
|
|
21
|
+
* - `mindee.product.CropResponse`
|
|
22
|
+
* - `mindee.product.SplitResponse`
|
|
23
|
+
*
|
|
24
|
+
* @typeParam ResponseT - A class that extends `BaseResponse`.
|
|
25
|
+
* @param responseClass - The constructor of the product response class into
|
|
26
|
+
* which the payload should be deserialized.
|
|
27
|
+
* @returns An instance of `responseClass` populated with the webhook payload.
|
|
16
28
|
* @throws MindeeError If the provided class cannot be instantiated.
|
|
17
29
|
*/
|
|
18
30
|
async deserializeResponse(responseClass) {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Document level classification.
|
|
4
5
|
*/
|
|
5
6
|
export declare class ClassificationClassifier {
|
|
7
|
+
/**
|
|
8
|
+
* The document type, as identified on given classification values.
|
|
9
|
+
*/
|
|
6
10
|
documentType: string;
|
|
11
|
+
/**
|
|
12
|
+
* The extraction response associated with the classification.
|
|
13
|
+
*/
|
|
14
|
+
extractionResponse?: ExtractionResponse;
|
|
7
15
|
constructor(serverResponse: StringDict);
|
|
8
16
|
toString(): string;
|
|
9
17
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
1
2
|
/**
|
|
2
3
|
* Document level classification.
|
|
3
4
|
*/
|
|
4
5
|
export class ClassificationClassifier {
|
|
5
6
|
constructor(serverResponse) {
|
|
6
7
|
this.documentType = serverResponse["document_type"];
|
|
8
|
+
this.extractionResponse = serverResponse["extraction_response"]
|
|
9
|
+
? new ExtractionResponse(serverResponse["extraction_response"])
|
|
10
|
+
: undefined;
|
|
7
11
|
}
|
|
8
12
|
toString() {
|
|
9
13
|
return `Document Type: ${this.documentType}`;
|
|
@@ -2,9 +2,20 @@ import { FieldLocation } from "../../../v2/parsing/inference/field/index.js";
|
|
|
2
2
|
import { StringDict } from "../../../parsing/index.js";
|
|
3
3
|
import { LocalInputSource } from "../../../input/index.js";
|
|
4
4
|
import { ExtractedImage } from "../../../image/index.js";
|
|
5
|
+
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
5
6
|
export declare class CropItem {
|
|
7
|
+
/**
|
|
8
|
+
* Type or classification of the detected object.
|
|
9
|
+
*/
|
|
6
10
|
objectType: string;
|
|
11
|
+
/**
|
|
12
|
+
* Location that includes cropping coordinates for the detected object, within the source document.
|
|
13
|
+
*/
|
|
7
14
|
location: FieldLocation;
|
|
15
|
+
/**
|
|
16
|
+
* The extraction response associated with the crop.
|
|
17
|
+
*/
|
|
18
|
+
extractionResponse?: ExtractionResponse;
|
|
8
19
|
constructor(serverResponse: StringDict);
|
|
9
20
|
toString(): string;
|
|
10
21
|
/**
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { FieldLocation } from "../../../v2/parsing/inference/field/index.js";
|
|
2
2
|
import { extractCrops } from "../../../v2/fileOperations/crop.js";
|
|
3
|
+
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
3
4
|
export class CropItem {
|
|
4
5
|
constructor(serverResponse) {
|
|
5
6
|
this.objectType = serverResponse["object_type"];
|
|
6
7
|
this.location = new FieldLocation(serverResponse["location"]);
|
|
8
|
+
this.extractionResponse = serverResponse["extraction_response"]
|
|
9
|
+
? new ExtractionResponse(serverResponse["extraction_response"])
|
|
10
|
+
: undefined;
|
|
7
11
|
}
|
|
8
12
|
toString() {
|
|
9
13
|
return `* :Location: ${this.location}\n :Object Type: ${this.objectType}`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/index.js";
|
|
2
2
|
import { LocalInputSource } from "../../../input/index.js";
|
|
3
|
+
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* Split inference result.
|
|
5
6
|
*/
|
|
@@ -13,6 +14,10 @@ export declare class SplitRange {
|
|
|
13
14
|
* The document type, as identified on given classification values.
|
|
14
15
|
*/
|
|
15
16
|
documentType: string;
|
|
17
|
+
/**
|
|
18
|
+
* The extraction response associated with the split.
|
|
19
|
+
*/
|
|
20
|
+
extractionResponse?: ExtractionResponse;
|
|
16
21
|
constructor(serverResponse: StringDict);
|
|
17
22
|
toString(): string;
|
|
18
23
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { expandRange, extractSplits } from "../../../v2/fileOperations/split.js";
|
|
2
|
+
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Split inference result.
|
|
4
5
|
*/
|
|
@@ -6,6 +7,9 @@ export class SplitRange {
|
|
|
6
7
|
constructor(serverResponse) {
|
|
7
8
|
this.pageRange = serverResponse["page_range"];
|
|
8
9
|
this.documentType = serverResponse["document_type"];
|
|
10
|
+
this.extractionResponse = serverResponse["extraction_response"]
|
|
11
|
+
? new ExtractionResponse(serverResponse["extraction_response"])
|
|
12
|
+
: undefined;
|
|
9
13
|
}
|
|
10
14
|
toString() {
|
|
11
15
|
const pageRange = this.pageRange.join(",");
|