mindee 5.0.0-rc2 → 5.0.0
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 +23 -4
- package/package.json +7 -7
- package/src/geometry/polygon.d.ts +1 -0
- package/src/geometry/polygon.js +3 -0
- package/src/http/apiCore.d.ts +4 -4
- package/src/http/apiCore.js +3 -4
- package/src/http/baseSettings.d.ts +1 -1
- package/src/http/baseSettings.js +4 -2
- package/src/v1/http/endpoint.js +6 -5
- package/src/v1/http/workflowEndpoint.js +3 -2
- package/src/v2/cli.js +10 -13
- package/src/v2/client/baseParameters.d.ts +1 -0
- package/src/v2/client/baseParameters.js +1 -0
- package/src/v2/http/mindeeApiV2.js +3 -3
- package/src/v2/parsing/inference/baseInference.js +1 -0
- package/src/v2/product/extraction/params/extractionParameters.d.ts +1 -0
- package/src/v2/product/extraction/params/extractionParameters.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## v5.0.0 - 2026-02-19
|
|
4
|
+
### ¡Breaking Changes!
|
|
5
|
+
* :boom: :sparkles: move PDF and image libraries to optional dependencies (resolves #388)
|
|
6
|
+
* :recycle: :boom: rework of directory structure and exports (resolves #276)
|
|
7
|
+
* :boom: drop support for node.js 18
|
|
8
|
+
* :boom: :recycle: separate polling options
|
|
9
|
+
* :coffin: remove support for API builder (no longer maintained, use v2)
|
|
10
|
+
* :coffin: remove support for v1 products available in v2
|
|
11
|
+
* :coffin: remove support for unused products
|
|
12
|
+
### Changes
|
|
13
|
+
* :sparkles: add support for all utility products
|
|
14
|
+
* :sparkles: add V2 CLI
|
|
15
|
+
* :sparkles: add Job to inference responses
|
|
16
|
+
* :sparkles: handle abort signal stream inputs
|
|
17
|
+
* :recycle: use undici (compatible with v6 or v7) for HTTP requests and mocking
|
|
18
|
+
* :sparkles: add ability for a user to specify their own undici `Dispatcher` instance
|
|
19
|
+
* :recycle: migrate to ES modules
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## v5.0.0-rc2 - 2026-02-18
|
|
4
23
|
### Changes
|
|
5
24
|
* :sparkles: add Job to inference responses
|
|
6
25
|
### Fixes
|
|
7
26
|
* :bug: fix for bin scripts
|
|
8
27
|
|
|
9
28
|
|
|
10
|
-
##
|
|
29
|
+
## v5.0.0-rc1 - 2026-02-17
|
|
11
30
|
### Changes
|
|
12
31
|
* :boom: drop support for node.js 18
|
|
13
32
|
* :boom: :recycle: separate polling options
|
|
14
33
|
|
|
15
34
|
|
|
16
|
-
##
|
|
35
|
+
## v5.0.0-alpha2 - 2026-02-16
|
|
17
36
|
### Changes
|
|
18
37
|
* :recycle: use node test methods
|
|
19
38
|
* :recycle: v1 ocr word should be a class
|
|
@@ -21,7 +40,7 @@
|
|
|
21
40
|
* :bug: fix for optional node-poppler
|
|
22
41
|
|
|
23
42
|
|
|
24
|
-
##
|
|
43
|
+
## v5.0.0-alpha1 - 2026-02-13
|
|
25
44
|
### :boom: :recycle: base for v5
|
|
26
45
|
* :arrow_up: update file-type
|
|
27
46
|
* :recycle: migrate to ES modules (node18)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mindee",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"node": ">= 20.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"commander": "
|
|
51
|
-
"file-type": "^
|
|
50
|
+
"commander": "^14.0.3",
|
|
51
|
+
"file-type": "^21.3.0",
|
|
52
52
|
"tmp": "^0.2.3",
|
|
53
53
|
"tslib": "^2.8.1",
|
|
54
|
-
"undici": "
|
|
54
|
+
"undici": ">=6.23.0 <8.0.0"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@cantoo/pdf-lib": "^2.3
|
|
58
|
-
"node-poppler": "^
|
|
59
|
-
"pdf.js-extract": "
|
|
57
|
+
"@cantoo/pdf-lib": "^2.5.3",
|
|
58
|
+
"node-poppler": "^9.1.1",
|
|
59
|
+
"pdf.js-extract": "~0.2.1",
|
|
60
60
|
"sharp": "~0.34.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
package/src/geometry/polygon.js
CHANGED
package/src/http/apiCore.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Dispatcher } from "undici";
|
|
1
|
+
import { Dispatcher, FormData } from "undici";
|
|
2
2
|
import { InputSource, PageOptions } from "../input/index.js";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const TIMEOUT_SECS_DEFAULT: number;
|
|
4
4
|
export interface RequestOptions {
|
|
5
5
|
hostname: string;
|
|
6
6
|
path: string;
|
|
7
7
|
method: any;
|
|
8
|
-
|
|
8
|
+
timeoutSecs: number;
|
|
9
9
|
headers: any;
|
|
10
|
-
body?:
|
|
10
|
+
body?: FormData | string;
|
|
11
11
|
}
|
|
12
12
|
export interface BaseHttpResponse {
|
|
13
13
|
messageObj: any;
|
package/src/http/apiCore.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger } from "../logger.js";
|
|
2
2
|
import { request } from "undici";
|
|
3
3
|
import { LocalInputSource } from "../input/index.js";
|
|
4
|
-
export const
|
|
4
|
+
export const TIMEOUT_SECS_DEFAULT = 120;
|
|
5
5
|
/**
|
|
6
6
|
* Cuts a document's pages according to the given options.
|
|
7
7
|
* @param inputDoc input document.
|
|
@@ -24,10 +24,9 @@ export async function sendRequestAndReadResponse(dispatcher, options) {
|
|
|
24
24
|
const response = await request(url, {
|
|
25
25
|
method: options.method,
|
|
26
26
|
headers: options.headers,
|
|
27
|
-
|
|
27
|
+
headersTimeout: options.timeoutSecs * 1000,
|
|
28
28
|
body: options.body,
|
|
29
|
-
|
|
30
|
-
dispatcher: dispatcher
|
|
29
|
+
dispatcher: dispatcher,
|
|
31
30
|
});
|
|
32
31
|
logger.debug("Parsing the response ...");
|
|
33
32
|
let responseBody = await response.body.text();
|
|
@@ -6,7 +6,7 @@ export interface MindeeApiConstructorProps {
|
|
|
6
6
|
export declare abstract class BaseSettings {
|
|
7
7
|
apiKey: string;
|
|
8
8
|
hostname: string;
|
|
9
|
-
|
|
9
|
+
timeoutSecs: number;
|
|
10
10
|
dispatcher: Dispatcher;
|
|
11
11
|
protected constructor(apiKey?: string, dispatcher?: Dispatcher);
|
|
12
12
|
protected getUserAgent(): string;
|
package/src/http/baseSettings.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getGlobalDispatcher } from "undici";
|
|
2
2
|
import packageJson from "../../package.json" with { type: "json" };
|
|
3
3
|
import * as os from "os";
|
|
4
|
-
import {
|
|
4
|
+
import { TIMEOUT_SECS_DEFAULT } from "./apiCore.js";
|
|
5
5
|
export class BaseSettings {
|
|
6
6
|
constructor(apiKey, dispatcher) {
|
|
7
7
|
if (apiKey === undefined || !apiKey || apiKey.length === 0) {
|
|
@@ -12,7 +12,9 @@ export class BaseSettings {
|
|
|
12
12
|
}
|
|
13
13
|
this.dispatcher = dispatcher ?? getGlobalDispatcher();
|
|
14
14
|
this.hostname = this.hostnameFromEnv();
|
|
15
|
-
this.
|
|
15
|
+
this.timeoutSecs = process.env.MINDEE_REQUEST_TIMEOUT
|
|
16
|
+
? parseInt(process.env.MINDEE_REQUEST_TIMEOUT)
|
|
17
|
+
: TIMEOUT_SECS_DEFAULT;
|
|
16
18
|
}
|
|
17
19
|
getUserAgent() {
|
|
18
20
|
let platform = os.type().toLowerCase();
|
package/src/v1/http/endpoint.js
CHANGED
|
@@ -5,8 +5,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _Endpoint_instances, _Endpoint_predictReqPost, _Endpoint_predictAsyncReqPost, _Endpoint_documentQueueReqGet, _Endpoint_documentGetReq, _Endpoint_documentFeedbackPutReq;
|
|
7
7
|
import { URLSearchParams } from "url";
|
|
8
|
+
import { FormData } from "undici";
|
|
8
9
|
import { LocalInputSource } from "../../input/index.js";
|
|
9
|
-
import { cutDocPages, sendRequestAndReadResponse } from "../../http/apiCore.js";
|
|
10
|
+
import { cutDocPages, sendRequestAndReadResponse, } from "../../http/apiCore.js";
|
|
10
11
|
import { handleError } from "./errors.js";
|
|
11
12
|
import { isValidAsyncResponse, isValidSyncResponse } from "./responseValidation.js";
|
|
12
13
|
/**
|
|
@@ -162,7 +163,7 @@ export class Endpoint {
|
|
|
162
163
|
headers: this.settings.baseHeaders,
|
|
163
164
|
hostname: this.settings.hostname,
|
|
164
165
|
path: path,
|
|
165
|
-
|
|
166
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
166
167
|
body: form,
|
|
167
168
|
};
|
|
168
169
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
@@ -193,7 +194,7 @@ async function _Endpoint_documentQueueReqGet(queueId) {
|
|
|
193
194
|
headers: this.settings.baseHeaders,
|
|
194
195
|
hostname: this.settings.hostname,
|
|
195
196
|
path: `${this.urlRoot}/documents/queue/${queueId}`,
|
|
196
|
-
|
|
197
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
197
198
|
};
|
|
198
199
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
199
200
|
}, _Endpoint_documentGetReq =
|
|
@@ -207,7 +208,7 @@ async function _Endpoint_documentGetReq(documentId) {
|
|
|
207
208
|
headers: this.settings.baseHeaders,
|
|
208
209
|
hostname: this.settings.hostname,
|
|
209
210
|
path: `${this.urlRoot}/documents/${documentId}`,
|
|
210
|
-
|
|
211
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
211
212
|
};
|
|
212
213
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
213
214
|
}, _Endpoint_documentFeedbackPutReq =
|
|
@@ -223,7 +224,7 @@ async function _Endpoint_documentFeedbackPutReq(documentId, feedback) {
|
|
|
223
224
|
hostname: this.settings.hostname,
|
|
224
225
|
path: `/v1/documents/${documentId}/feedback`,
|
|
225
226
|
body: JSON.stringify(feedback),
|
|
226
|
-
|
|
227
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
227
228
|
};
|
|
228
229
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
229
230
|
};
|
|
@@ -5,8 +5,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _WorkflowEndpoint_instances, _WorkflowEndpoint_workflowReqPost;
|
|
7
7
|
import { URLSearchParams } from "url";
|
|
8
|
+
import { FormData } from "undici";
|
|
8
9
|
import { LocalInputSource } from "../../input/index.js";
|
|
9
|
-
import { cutDocPages, sendRequestAndReadResponse } from "../../http/apiCore.js";
|
|
10
|
+
import { cutDocPages, sendRequestAndReadResponse, } from "../../http/apiCore.js";
|
|
10
11
|
import { handleError } from "./errors.js";
|
|
11
12
|
import { isValidSyncResponse } from "./responseValidation.js";
|
|
12
13
|
/**
|
|
@@ -78,7 +79,7 @@ export class WorkflowEndpoint {
|
|
|
78
79
|
headers: this.settings.baseHeaders,
|
|
79
80
|
hostname: this.settings.hostname,
|
|
80
81
|
path: path,
|
|
81
|
-
|
|
82
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
82
83
|
body: form,
|
|
83
84
|
};
|
|
84
85
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
package/src/v2/cli.js
CHANGED
|
@@ -16,13 +16,10 @@ function initClient(options) {
|
|
|
16
16
|
async function enqueueAndGetInference(product, inputPath, options) {
|
|
17
17
|
const mindeeClient = initClient(options);
|
|
18
18
|
const inputSource = new PathInput({ inputPath: inputPath });
|
|
19
|
-
const response = await mindeeClient.enqueueAndGetResult(product, inputSource, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
delaySec: 1.5,
|
|
24
|
-
maxRetries: 80,
|
|
25
|
-
}
|
|
19
|
+
const response = await mindeeClient.enqueueAndGetResult(product, inputSource, { modelId: options.model }, {
|
|
20
|
+
initialDelaySec: 2,
|
|
21
|
+
delaySec: 1.5,
|
|
22
|
+
maxRetries: 80,
|
|
26
23
|
});
|
|
27
24
|
if (!response.inference) {
|
|
28
25
|
throw Error("Inference could not be retrieved");
|
|
@@ -47,11 +44,11 @@ export function cli() {
|
|
|
47
44
|
.option("-d, --debug", "high verbosity mode")
|
|
48
45
|
.option("-k, --api-key <api_key>", "your Mindee API key");
|
|
49
46
|
const inferenceTypes = [
|
|
50
|
-
{ name: "extraction", description: "Extract data from a document.",
|
|
51
|
-
{ name: "crop", description: "Crop a document.",
|
|
52
|
-
{ name: "split", description: "Split a document into pages.",
|
|
53
|
-
{ name: "ocr", description: "Read text from a document.",
|
|
54
|
-
{ name: "classification", description: "Classify a document.",
|
|
47
|
+
{ name: "extraction", description: "Extract data from a document.", productClass: Extraction },
|
|
48
|
+
{ name: "crop", description: "Crop a document.", productClass: Crop },
|
|
49
|
+
{ name: "split", description: "Split a document into pages.", productClass: Split },
|
|
50
|
+
{ name: "ocr", description: "Read text from a document.", productClass: Ocr },
|
|
51
|
+
{ name: "classification", description: "Classify a document.", productClass: Classification },
|
|
55
52
|
];
|
|
56
53
|
for (const inference of inferenceTypes) {
|
|
57
54
|
const inferenceCmd = program.command(inference.name)
|
|
@@ -59,7 +56,7 @@ export function cli() {
|
|
|
59
56
|
addMainOptions(inferenceCmd);
|
|
60
57
|
inferenceCmd.action(function (inputPath, options) {
|
|
61
58
|
const allOptions = { ...program.opts(), ...options };
|
|
62
|
-
return enqueueAndGetInference(inference.
|
|
59
|
+
return enqueueAndGetInference(inference.productClass, inputPath, allOptions);
|
|
63
60
|
});
|
|
64
61
|
}
|
|
65
62
|
program.parse(process.argv);
|
|
@@ -100,7 +100,7 @@ async function _MindeeApiV2_reqPostProductEnqueue(product, inputSource, params)
|
|
|
100
100
|
hostname: this.settings.hostname,
|
|
101
101
|
path: path,
|
|
102
102
|
body: form,
|
|
103
|
-
|
|
103
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
104
104
|
};
|
|
105
105
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
106
106
|
}, _MindeeApiV2_reqGetJob = async function _MindeeApiV2_reqGetJob(jobId) {
|
|
@@ -109,7 +109,7 @@ async function _MindeeApiV2_reqPostProductEnqueue(product, inputSource, params)
|
|
|
109
109
|
headers: this.settings.baseHeaders,
|
|
110
110
|
hostname: this.settings.hostname,
|
|
111
111
|
path: `/v2/jobs/${jobId}`,
|
|
112
|
-
|
|
112
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
113
113
|
};
|
|
114
114
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
115
115
|
}, _MindeeApiV2_reqGetProductResult =
|
|
@@ -126,7 +126,7 @@ async function _MindeeApiV2_reqGetProductResult(inferenceId, slug) {
|
|
|
126
126
|
headers: this.settings.baseHeaders,
|
|
127
127
|
hostname: this.settings.hostname,
|
|
128
128
|
path: `/v2/products/${slug}/results/${inferenceId}`,
|
|
129
|
-
|
|
129
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
130
130
|
};
|
|
131
131
|
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
132
132
|
};
|