mindee 5.0.0-rc1 → 5.0.0-rc2

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 5.0.0-rc2 - 2026-01-18
4
+ ### Changes
5
+ * :sparkles: add Job to inference responses
6
+ ### Fixes
7
+ * :bug: fix for bin scripts
8
+
9
+
3
10
  ## 5.0.0-rc1 - 2026-01-17
4
11
  ### Changes
5
12
  * :boom: drop support for node.js 18
package/package.json CHANGED
@@ -1,14 +1,27 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.0.0-rc1",
3
+ "version": "5.0.0-rc2",
4
4
  "description": "Mindee Client Library for Node.js",
5
+ "author": {
6
+ "name": "Mindee",
7
+ "email": "opensource@mindee.com",
8
+ "url": "https://mindee.com/"
9
+ },
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/mindee/mindee-api-nodejs.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/mindee/mindee-api-nodejs/issues"
17
+ },
18
+ "homepage": "https://mindee.com/",
19
+ "type": "module",
5
20
  "main": "src/index.js",
6
21
  "bin": {
7
22
  "mindeeV1": "bin/mindeeV1.js",
8
23
  "mindeeV2": "bin/mindeeV2.js"
9
24
  },
10
- "license": "MIT",
11
- "type": "module",
12
25
  "scripts": {
13
26
  "build": "tsc --build && tsc-alias",
14
27
  "build-for-dist": "tsc --build && tsc-alias && cp LICENSE README.md CHANGELOG.md ./dist",
@@ -33,33 +46,6 @@
33
46
  "engines": {
34
47
  "node": ">= 20.1"
35
48
  },
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/mindee/mindee-api-nodejs.git"
39
- },
40
- "author": {
41
- "name": "Mindee",
42
- "email": "opensource@mindee.com",
43
- "url": "https://mindee.com/"
44
- },
45
- "bugs": {
46
- "url": "https://github.com/mindee/mindee-api-nodejs/issues"
47
- },
48
- "homepage": "https://mindee.com/",
49
- "devDependencies": {
50
- "@types/mocha": "^10.0.10",
51
- "@types/node": "^18.19.130",
52
- "@types/tmp": "^0.2.6",
53
- "@typescript-eslint/eslint-plugin": "^8.55.0",
54
- "@typescript-eslint/parser": "^8.55.0",
55
- "eslint": "^9.39.2",
56
- "eslint-plugin-jsdoc": "^52.0.4",
57
- "mocha": "^11.3.0",
58
- "tsc-alias": "^1.8.16",
59
- "tsx": "^4.21.0",
60
- "typedoc": "~0.28.16",
61
- "typescript": "^5.9.3"
62
- },
63
49
  "dependencies": {
64
50
  "commander": "~9.4.1",
65
51
  "file-type": "^19.6.0",
@@ -73,6 +59,20 @@
73
59
  "pdf.js-extract": "^0.2.1",
74
60
  "sharp": "~0.34.5"
75
61
  },
62
+ "devDependencies": {
63
+ "@types/mocha": "^10.0.10",
64
+ "@types/node": "^20.19.33",
65
+ "@types/tmp": "^0.2.6",
66
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
67
+ "@typescript-eslint/parser": "^8.56.0",
68
+ "eslint": "^9.39.2",
69
+ "eslint-plugin-jsdoc": "^62.6.0",
70
+ "mocha": "^11.7.5",
71
+ "tsc-alias": "^1.8.16",
72
+ "tsx": "^4.21.0",
73
+ "typedoc": "^0.28.17",
74
+ "typescript": "^5.9.3"
75
+ },
76
76
  "keywords": [
77
77
  "typescript",
78
78
  "mindee",
@@ -8,7 +8,7 @@ export interface BaseParametersConstructor {
8
8
  closeFile?: boolean;
9
9
  }
10
10
  /**
11
- * Parameters accepted by the asynchronous **inference** v2 endpoint.
11
+ * Parameters accepted by all v2 products.
12
12
  *
13
13
  * All fields are optional except `modelId`.
14
14
  *
@@ -19,10 +19,6 @@ export interface BaseParametersConstructor {
19
19
  * rag: true,
20
20
  * alias: "YOUR_ALIAS",
21
21
  * webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
22
- * pollingOptions: {
23
- * initialDelaySec: 2,
24
- * delaySec: 1.5,
25
- * }
26
22
  * };
27
23
  */
28
24
  export declare abstract class BaseParameters {
@@ -1,6 +1,6 @@
1
1
  import { MindeeConfigurationError } from "../../errors/index.js";
2
2
  /**
3
- * Parameters accepted by the asynchronous **inference** v2 endpoint.
3
+ * Parameters accepted by all v2 products.
4
4
  *
5
5
  * All fields are optional except `modelId`.
6
6
  *
@@ -11,10 +11,6 @@ import { MindeeConfigurationError } from "../../errors/index.js";
11
11
  * rag: true,
12
12
  * alias: "YOUR_ALIAS",
13
13
  * webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
14
- * pollingOptions: {
15
- * initialDelaySec: 2,
16
- * delaySec: 1.5,
17
- * }
18
14
  * };
19
15
  */
20
16
  export class BaseParameters {
@@ -1,3 +1,3 @@
1
1
  export { PollingOptions } from "./pollingOptions.js";
2
- export type { PollingOptionsConstructor } from "./pollingOptions.js";
2
+ export type { PollingOptionsConstructor, TimerOptions, } from "./pollingOptions.js";
3
3
  export { BaseParameters } from "./baseParameters.js";
@@ -13,8 +13,8 @@ export interface PollingOptionsConstructor {
13
13
  * Parameters for the internal polling loop in `enqueueAndGetInference()`.
14
14
  *
15
15
  * Default behavior:
16
- * - `initialDelaySec` = 2s
17
- * - `delaySec` = 1.5s
16
+ * - `initialDelaySec` = 2
17
+ * - `delaySec` = 1.5
18
18
  * - `maxRetries` = 80
19
19
  *
20
20
  * Validation rules:
@@ -23,17 +23,21 @@ export interface PollingOptionsConstructor {
23
23
  * - `maxRetries` >= 2
24
24
  *
25
25
  * The `initialTimerOptions` and `recurringTimerOptions` objects let you pass an
26
- * `AbortSignal` or make the timer `unref`-ed to the `setTimeout()`.
26
+ * `AbortSignal` or make the timer `ref`-ed to the `setTimeout()`.
27
27
  *
28
28
  * @category ClientV2
29
29
  * @example
30
- * const params = {
30
+ * ```
31
+ * const pollingOptions = {
31
32
  * initialDelaySec: 4,
32
33
  * delaySec: 2,
33
34
  * maxRetries: 50
34
35
  * };
35
36
  *
36
- * const inference = await client.enqueueAndGetInference(inputDoc, params);
37
+ * const inference = await client.enqueueAndGetInference(
38
+ * inputDoc, params, pollingOptions
39
+ * );
40
+ * ```
37
41
  */
38
42
  export declare class PollingOptions {
39
43
  /** Number of seconds to wait *before the first poll*. */
@@ -43,15 +47,9 @@ export declare class PollingOptions {
43
47
  /** Maximum number of polling attempts (including the first one). */
44
48
  maxRetries: number;
45
49
  /** Options passed to the initial `setTimeout()`. */
46
- initialTimerOptions?: {
47
- ref?: boolean;
48
- signal?: AbortSignal;
49
- };
50
+ initialTimerOptions?: TimerOptions;
50
51
  /** Options passed to every recurring `setTimeout()`. */
51
- recurringTimerOptions?: {
52
- ref?: boolean;
53
- signal?: AbortSignal;
54
- };
52
+ recurringTimerOptions?: TimerOptions;
55
53
  constructor(params?: PollingOptionsConstructor);
56
54
  validateOptions(): void;
57
55
  toString(): string;
@@ -7,8 +7,8 @@ const minRetries = 2;
7
7
  * Parameters for the internal polling loop in `enqueueAndGetInference()`.
8
8
  *
9
9
  * Default behavior:
10
- * - `initialDelaySec` = 2s
11
- * - `delaySec` = 1.5s
10
+ * - `initialDelaySec` = 2
11
+ * - `delaySec` = 1.5
12
12
  * - `maxRetries` = 80
13
13
  *
14
14
  * Validation rules:
@@ -17,17 +17,21 @@ const minRetries = 2;
17
17
  * - `maxRetries` >= 2
18
18
  *
19
19
  * The `initialTimerOptions` and `recurringTimerOptions` objects let you pass an
20
- * `AbortSignal` or make the timer `unref`-ed to the `setTimeout()`.
20
+ * `AbortSignal` or make the timer `ref`-ed to the `setTimeout()`.
21
21
  *
22
22
  * @category ClientV2
23
23
  * @example
24
- * const params = {
24
+ * ```
25
+ * const pollingOptions = {
25
26
  * initialDelaySec: 4,
26
27
  * delaySec: 2,
27
28
  * maxRetries: 50
28
29
  * };
29
30
  *
30
- * const inference = await client.enqueueAndGetInference(inputDoc, params);
31
+ * const inference = await client.enqueueAndGetInference(
32
+ * inputDoc, params, pollingOptions
33
+ * );
34
+ * ```
31
35
  */
32
36
  export class PollingOptions {
33
37
  constructor(params) {
@@ -1,5 +1,5 @@
1
1
  import { BaseSettings, MindeeApiConstructorProps } from "../../http/baseSettings.js";
2
- export declare class ApiSettingsV2 extends BaseSettings {
2
+ export declare class ApiSettings extends BaseSettings {
3
3
  baseHeaders: Record<string, string>;
4
4
  constructor({ apiKey, dispatcher, }: MindeeApiConstructorProps);
5
5
  protected apiKeyFromEnv(): string;
@@ -4,7 +4,7 @@ import { MindeeConfigurationError } from "../../errors/index.js";
4
4
  const API_V2_KEY_ENVVAR_NAME = "MINDEE_V2_API_KEY";
5
5
  const API_V2_HOST_ENVVAR_NAME = "MINDEE_V2_API_HOST";
6
6
  const DEFAULT_MINDEE_API_HOST = "api-v2.mindee.net";
7
- export class ApiSettingsV2 extends BaseSettings {
7
+ export class ApiSettings extends BaseSettings {
8
8
  constructor({ apiKey, dispatcher, }) {
9
9
  super(apiKey, dispatcher);
10
10
  if (!this.apiKey || this.apiKey.length === 0) {
@@ -16,6 +16,7 @@ export class ApiSettingsV2 extends BaseSettings {
16
16
  "User-Agent": this.getUserAgent(),
17
17
  Authorization: `${this.apiKey}`,
18
18
  };
19
+ /* eslint-enable @typescript-eslint/naming-convention */
19
20
  }
20
21
  apiKeyFromEnv() {
21
22
  const envVarValue = process.env[API_V2_KEY_ENVVAR_NAME];
@@ -1,5 +1,8 @@
1
1
  import { ErrorDetails, ErrorItem, ErrorResponse } from "../../v2/parsing/index.js";
2
2
  import { MindeeError } from "../../errors/index.js";
3
+ /**
4
+ * HTTP error returned by the API.
5
+ */
3
6
  export declare class MindeeHttpErrorV2 extends MindeeError implements ErrorDetails {
4
7
  status: number;
5
8
  detail: string;
@@ -1,4 +1,7 @@
1
1
  import { MindeeError } from "../../errors/index.js";
2
+ /**
3
+ * HTTP error returned by the API.
4
+ */
2
5
  export class MindeeHttpErrorV2 extends MindeeError {
3
6
  constructor(error) {
4
7
  super(`HTTP ${error.status} - ${error.title} :: ${error.code} - ${error.detail}`);
@@ -1,4 +1,4 @@
1
- import { ApiSettingsV2 } from "./apiSettingsV2.js";
1
+ import { ApiSettings } from "./apiSettings.js";
2
2
  import { Dispatcher } from "undici";
3
3
  import { BaseParameters } from "../../v2/client/index.js";
4
4
  import { JobResponse } from "../../v2/parsing/index.js";
@@ -6,7 +6,7 @@ import { InputSource } from "../../input/index.js";
6
6
  import { BaseProduct } from "../../v2/product/baseProduct.js";
7
7
  export declare class MindeeApiV2 {
8
8
  #private;
9
- settings: ApiSettingsV2;
9
+ settings: ApiSettings;
10
10
  constructor(dispatcher?: Dispatcher, apiKey?: string);
11
11
  /**
12
12
  * Sends a file to the extraction inference queue.
@@ -4,7 +4,7 @@ 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 _MindeeApiV2_instances, _MindeeApiV2_processResponse, _MindeeApiV2_reqPostProductEnqueue, _MindeeApiV2_reqGetJob, _MindeeApiV2_reqGetProductResult;
7
- import { ApiSettingsV2 } from "./apiSettingsV2.js";
7
+ import { ApiSettings } from "./apiSettings.js";
8
8
  import { ErrorResponse, JobResponse, } from "../../v2/parsing/index.js";
9
9
  import { sendRequestAndReadResponse } from "../../http/apiCore.js";
10
10
  import { LocalInputSource } from "../../input/index.js";
@@ -14,7 +14,7 @@ import { logger } from "../../logger.js";
14
14
  export class MindeeApiV2 {
15
15
  constructor(dispatcher, apiKey) {
16
16
  _MindeeApiV2_instances.add(this);
17
- this.settings = new ApiSettingsV2({ dispatcher: dispatcher, apiKey: apiKey });
17
+ this.settings = new ApiSettings({ dispatcher: dispatcher, apiKey: apiKey });
18
18
  }
19
19
  /**
20
20
  * Sends a file to the extraction inference queue.
@@ -58,7 +58,8 @@ export class MindeeApiV2 {
58
58
  }
59
59
  }
60
60
  _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function _MindeeApiV2_processResponse(result, responseClass) {
61
- if (result.messageObj?.statusCode && (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) {
61
+ if (result.messageObj?.statusCode
62
+ && (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) {
62
63
  if (result.data?.status !== null) {
63
64
  throw new MindeeHttpErrorV2(new ErrorResponse(result.data));
64
65
  }
package/src/v2/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * as parsing from "./parsing/index.js";
3
3
  export * as product from "./product/index.js";
4
4
  export { Client } from "./client.js";
5
5
  export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
6
- export type { PollingOptions, BaseParameters } from "./client/index.js";
6
+ export type { BaseParameters, TimerOptions } from "./client/index.js";
7
+ export { PollingOptions } from "./client/index.js";
package/src/v2/index.js CHANGED
@@ -3,3 +3,4 @@ export * as parsing from "./parsing/index.js";
3
3
  export * as product from "./product/index.js";
4
4
  export { Client } from "./client.js";
5
5
  export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
6
+ export { PollingOptions } from "./client/index.js";
@@ -1,11 +1,16 @@
1
+ import { StringDict } from "../../../parsing/index.js";
1
2
  import { InferenceModel } from "./inferenceModel.js";
2
3
  import { InferenceFile } from "./inferenceFile.js";
3
- import { StringDict } from "../../../parsing/index.js";
4
+ import { InferenceJob } from "./inferenceJob.js";
4
5
  export declare abstract class BaseInference {
5
6
  /**
6
7
  * Model info for the inference.
7
8
  */
8
9
  model: InferenceModel;
10
+ /**
11
+ * Job the inference belongs to.
12
+ */
13
+ job: InferenceJob;
9
14
  /**
10
15
  * File info for the inference.
11
16
  */
@@ -1,8 +1,10 @@
1
1
  import { InferenceModel } from "./inferenceModel.js";
2
2
  import { InferenceFile } from "./inferenceFile.js";
3
+ import { InferenceJob } from "./inferenceJob.js";
3
4
  export class BaseInference {
4
5
  constructor(serverResponse) {
5
6
  this.id = serverResponse["id"];
7
+ this.job = new InferenceJob(serverResponse["job"]);
6
8
  this.model = new InferenceModel(serverResponse["model"]);
7
9
  this.file = new InferenceFile(serverResponse["file"]);
8
10
  }
@@ -0,0 +1,9 @@
1
+ import { StringDict } from "../../../parsing/stringDict.js";
2
+ export declare class InferenceJob {
3
+ /**
4
+ * UUID of the Job.
5
+ */
6
+ id: string;
7
+ constructor(serverResponse: StringDict);
8
+ toString(): string;
9
+ }
@@ -0,0 +1,10 @@
1
+ export class InferenceJob {
2
+ constructor(serverResponse) {
3
+ this.id = serverResponse["id"];
4
+ }
5
+ toString() {
6
+ return ("Job\n" +
7
+ "===\n" +
8
+ `:ID: ${this.id}\n`);
9
+ }
10
+ }
@@ -1,5 +1,10 @@
1
1
  import { BaseParameters } from "../../v2/client/index.js";
2
2
  import { ResponseConstructor } from "../../v2/parsing/index.js";
3
+ /**
4
+ * Base class for all V2 product definitions.
5
+ *
6
+ * Child classes are passed to the Client when making requests.
7
+ */
3
8
  export declare abstract class BaseProduct {
4
9
  static get parametersClass(): new (...args: any[]) => BaseParameters;
5
10
  static get responseClass(): ResponseConstructor<any>;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Base class for all V2 product definitions.
3
+ *
4
+ * Child classes are passed to the Client when making requests.
5
+ */
1
6
  export class BaseProduct {
2
7
  static get parametersClass() {
3
8
  throw new Error("Must define static parameters property");
@@ -1,6 +1,9 @@
1
1
  import { ClassificationResponse } from "./classificationResponse.js";
2
2
  import { ClassificationParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Automatically sort any image or scanned document into categories.
6
+ */
4
7
  export declare class Classification extends BaseProduct {
5
8
  static get parametersClass(): typeof ClassificationParameters;
6
9
  static get responseClass(): typeof ClassificationResponse;
@@ -1,6 +1,9 @@
1
1
  import { ClassificationResponse } from "./classificationResponse.js";
2
2
  import { ClassificationParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Automatically sort any image or scanned document into categories.
6
+ */
4
7
  export class Classification extends BaseProduct {
5
8
  static get parametersClass() {
6
9
  return ClassificationParameters;
@@ -1,6 +1,9 @@
1
1
  import { CropResponse } from "./cropResponse.js";
2
2
  import { CropParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Identify the borders of documents on each page, matching each one to a category.
6
+ */
4
7
  export declare class Crop extends BaseProduct {
5
8
  static get parametersClass(): typeof CropParameters;
6
9
  static get responseClass(): typeof CropResponse;
@@ -1,6 +1,9 @@
1
1
  import { CropResponse } from "./cropResponse.js";
2
2
  import { CropParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Identify the borders of documents on each page, matching each one to a category.
6
+ */
4
7
  export class Crop extends BaseProduct {
5
8
  static get parametersClass() {
6
9
  return CropParameters;
@@ -1,6 +1,9 @@
1
1
  import { ExtractionResponse } from "./extractionResponse.js";
2
2
  import { ExtractionParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Automatically extract structured data from any image or scanned document.
6
+ */
4
7
  export declare class Extraction extends BaseProduct {
5
8
  static get parametersClass(): typeof ExtractionParameters;
6
9
  static get responseClass(): typeof ExtractionResponse;
@@ -1,6 +1,9 @@
1
1
  import { ExtractionResponse } from "./extractionResponse.js";
2
2
  import { ExtractionParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Automatically extract structured data from any image or scanned document.
6
+ */
4
7
  export class Extraction extends BaseProduct {
5
8
  static get parametersClass() {
6
9
  return ExtractionParameters;
@@ -1,6 +1,9 @@
1
1
  import { OcrResponse } from "./ocrResponse.js";
2
2
  import { OcrParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Extract raw text (OCR) from any image or scanned document.
6
+ */
4
7
  export declare class Ocr extends BaseProduct {
5
8
  static get parametersClass(): typeof OcrParameters;
6
9
  static get responseClass(): typeof OcrResponse;
@@ -1,6 +1,9 @@
1
1
  import { OcrResponse } from "./ocrResponse.js";
2
2
  import { OcrParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Extract raw text (OCR) from any image or scanned document.
6
+ */
4
7
  export class Ocr extends BaseProduct {
5
8
  static get parametersClass() {
6
9
  return OcrParameters;
@@ -1,6 +1,9 @@
1
1
  import { SplitResponse } from "./splitResponse.js";
2
2
  import { SplitParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Break a multipage source file into separate documents, associating a class for each one.
6
+ */
4
7
  export declare class Split extends BaseProduct {
5
8
  static get parametersClass(): typeof SplitParameters;
6
9
  static get responseClass(): typeof SplitResponse;
@@ -1,6 +1,9 @@
1
1
  import { SplitResponse } from "./splitResponse.js";
2
2
  import { SplitParameters } from "./params/index.js";
3
3
  import { BaseProduct } from "../../../v2/product/baseProduct.js";
4
+ /**
5
+ * Break a multipage source file into separate documents, associating a class for each one.
6
+ */
4
7
  export class Split extends BaseProduct {
5
8
  static get parametersClass() {
6
9
  return SplitParameters;