mindee 5.0.0-alpha2 → 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.
Files changed (34) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +36 -33
  3. package/src/v2/client/baseParameters.d.ts +1 -17
  4. package/src/v2/client/baseParameters.js +1 -41
  5. package/src/v2/client/index.d.ts +2 -1
  6. package/src/v2/client/index.js +1 -0
  7. package/src/v2/client/pollingOptions.d.ts +29 -22
  8. package/src/v2/client/pollingOptions.js +82 -1
  9. package/src/v2/client.d.ts +4 -3
  10. package/src/v2/client.js +7 -6
  11. package/src/v2/http/{apiSettingsV2.d.ts → apiSettings.d.ts} +1 -1
  12. package/src/v2/http/{apiSettingsV2.js → apiSettings.js} +2 -1
  13. package/src/v2/http/errors.d.ts +3 -0
  14. package/src/v2/http/errors.js +3 -0
  15. package/src/v2/http/mindeeApiV2.d.ts +2 -2
  16. package/src/v2/http/mindeeApiV2.js +4 -3
  17. package/src/v2/index.d.ts +2 -1
  18. package/src/v2/index.js +1 -0
  19. package/src/v2/parsing/inference/baseInference.d.ts +6 -1
  20. package/src/v2/parsing/inference/baseInference.js +2 -0
  21. package/src/v2/parsing/inference/inferenceJob.d.ts +9 -0
  22. package/src/v2/parsing/inference/inferenceJob.js +10 -0
  23. package/src/v2/product/baseProduct.d.ts +5 -0
  24. package/src/v2/product/baseProduct.js +5 -0
  25. package/src/v2/product/classification/classification.d.ts +3 -0
  26. package/src/v2/product/classification/classification.js +3 -0
  27. package/src/v2/product/crop/crop.d.ts +3 -0
  28. package/src/v2/product/crop/crop.js +3 -0
  29. package/src/v2/product/extraction/extraction.d.ts +3 -0
  30. package/src/v2/product/extraction/extraction.js +3 -0
  31. package/src/v2/product/ocr/ocr.d.ts +3 -0
  32. package/src/v2/product/ocr/ocr.js +3 -0
  33. package/src/v2/product/split/split.d.ts +3 -0
  34. package/src/v2/product/split/split.js +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
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
+
10
+ ## 5.0.0-rc1 - 2026-01-17
11
+ ### Changes
12
+ * :boom: drop support for node.js 18
13
+ * :boom: :recycle: separate polling options
14
+
15
+
3
16
  ## 5.0.0-alpha2 - 2026-01-16
4
17
  ### Changes
5
18
  * :recycle: use node test methods
package/package.json CHANGED
@@ -1,11 +1,27 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.0.0-alpha2",
3
+ "version": "5.0.0-rc2",
4
4
  "description": "Mindee Client Library for Node.js",
5
- "main": "src/index.js",
6
- "bin": "bin/mindee.js",
5
+ "author": {
6
+ "name": "Mindee",
7
+ "email": "opensource@mindee.com",
8
+ "url": "https://mindee.com/"
9
+ },
7
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/",
8
19
  "type": "module",
20
+ "main": "src/index.js",
21
+ "bin": {
22
+ "mindeeV1": "bin/mindeeV1.js",
23
+ "mindeeV2": "bin/mindeeV2.js"
24
+ },
9
25
  "scripts": {
10
26
  "build": "tsc --build && tsc-alias",
11
27
  "build-for-dist": "tsc --build && tsc-alias && cp LICENSE README.md CHANGELOG.md ./dist",
@@ -28,34 +44,7 @@
28
44
  "CHANGELOG.md"
29
45
  ],
30
46
  "engines": {
31
- "node": ">= 18.17"
32
- },
33
- "repository": {
34
- "type": "git",
35
- "url": "git+https://github.com/mindee/mindee-api-nodejs.git"
36
- },
37
- "author": {
38
- "name": "Mindee",
39
- "email": "opensource@mindee.com",
40
- "url": "https://mindee.com/"
41
- },
42
- "bugs": {
43
- "url": "https://github.com/mindee/mindee-api-nodejs/issues"
44
- },
45
- "homepage": "https://mindee.com/",
46
- "devDependencies": {
47
- "@types/mocha": "^10.0.10",
48
- "@types/node": "^18.19.130",
49
- "@types/tmp": "^0.2.6",
50
- "@typescript-eslint/eslint-plugin": "^8.55.0",
51
- "@typescript-eslint/parser": "^8.55.0",
52
- "eslint": "^9.39.2",
53
- "eslint-plugin-jsdoc": "^52.0.4",
54
- "mocha": "^11.7.5",
55
- "tsc-alias": "^1.8.16",
56
- "tsx": "^4.21.0",
57
- "typedoc": "~0.28.16",
58
- "typescript": "^5.9.3"
47
+ "node": ">= 20.1"
59
48
  },
60
49
  "dependencies": {
61
50
  "commander": "~9.4.1",
@@ -65,10 +54,24 @@
65
54
  "undici": "^6.23.0"
66
55
  },
67
56
  "optionalDependencies": {
68
- "sharp": "~0.34.5",
69
57
  "@cantoo/pdf-lib": "^2.3.2",
58
+ "node-poppler": "^7.2.4",
70
59
  "pdf.js-extract": "^0.2.1",
71
- "node-poppler": "^7.2.4"
60
+ "sharp": "~0.34.5"
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"
72
75
  },
73
76
  "keywords": [
74
77
  "typescript",
@@ -1,5 +1,3 @@
1
- import { ValidatedPollingOptions } from "../../v2/client/pollingOptions.js";
2
- import { PollingOptions } from "../../v2/index.js";
3
1
  /**
4
2
  * Constructor parameters for BaseParameters and its subclasses.
5
3
  */
@@ -7,11 +5,10 @@ export interface BaseParametersConstructor {
7
5
  modelId: string;
8
6
  alias?: string;
9
7
  webhookIds?: string[];
10
- pollingOptions?: PollingOptions;
11
8
  closeFile?: boolean;
12
9
  }
13
10
  /**
14
- * Parameters accepted by the asynchronous **inference** v2 endpoint.
11
+ * Parameters accepted by all v2 products.
15
12
  *
16
13
  * All fields are optional except `modelId`.
17
14
  *
@@ -22,10 +19,6 @@ export interface BaseParametersConstructor {
22
19
  * rag: true,
23
20
  * alias: "YOUR_ALIAS",
24
21
  * webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"],
25
- * pollingOptions: {
26
- * initialDelaySec: 2,
27
- * delaySec: 1.5,
28
- * }
29
22
  * };
30
23
  */
31
24
  export declare abstract class BaseParameters {
@@ -43,21 +36,12 @@ export declare abstract class BaseParameters {
43
36
  * If empty, no webhooks will be used.
44
37
  */
45
38
  webhookIds?: string[];
46
- /**
47
- * Client-side polling configuration (see {@link PollingOptions}).
48
- */
49
- pollingOptions?: PollingOptions;
50
39
  /**
51
40
  * By default, the file is closed once the upload is finished.
52
41
  * Set to `false` to keep it open.
53
42
  */
54
43
  closeFile?: boolean;
55
44
  protected constructor(params: BaseParametersConstructor);
56
- /**
57
- * Checks the values for asynchronous parsing. Returns their corrected value if they are undefined.
58
- * @returns A valid `AsyncOptions`.
59
- */
60
- getValidatedPollingOptions(): ValidatedPollingOptions;
61
45
  /**
62
46
  * Returns the form data to send to the API.
63
47
  * @returns A `FormData` object.
@@ -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 {
@@ -26,42 +22,6 @@ export class BaseParameters {
26
22
  this.alias = params.alias;
27
23
  this.webhookIds = params.webhookIds;
28
24
  this.closeFile = params.closeFile;
29
- this.pollingOptions = params.pollingOptions;
30
- }
31
- /**
32
- * Checks the values for asynchronous parsing. Returns their corrected value if they are undefined.
33
- * @returns A valid `AsyncOptions`.
34
- */
35
- getValidatedPollingOptions() {
36
- const minDelaySec = 1;
37
- const minInitialDelay = 1;
38
- const minRetries = 2;
39
- let newAsyncParams;
40
- if (this.pollingOptions === undefined) {
41
- newAsyncParams = {
42
- delaySec: 1.5,
43
- initialDelaySec: 2,
44
- maxRetries: 80
45
- };
46
- }
47
- else {
48
- newAsyncParams = { ...this.pollingOptions };
49
- if (!newAsyncParams.delaySec ||
50
- !newAsyncParams.initialDelaySec ||
51
- !newAsyncParams.maxRetries) {
52
- throw Error("Invalid polling options.");
53
- }
54
- if (newAsyncParams.delaySec < minDelaySec) {
55
- throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`);
56
- }
57
- if (newAsyncParams.initialDelaySec < minInitialDelay) {
58
- throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`);
59
- }
60
- if (newAsyncParams.maxRetries < minRetries) {
61
- throw Error(`Cannot set retry to less than ${minRetries}.`);
62
- }
63
- }
64
- return newAsyncParams;
65
25
  }
66
26
  /**
67
27
  * Returns the form data to send to the API.
@@ -1,2 +1,3 @@
1
- export type { PollingOptions, ValidatedPollingOptions } from "./pollingOptions.js";
1
+ export { PollingOptions } from "./pollingOptions.js";
2
+ export type { PollingOptionsConstructor, TimerOptions, } from "./pollingOptions.js";
2
3
  export { BaseParameters } from "./baseParameters.js";
@@ -1 +1,2 @@
1
+ export { PollingOptions } from "./pollingOptions.js";
1
2
  export { BaseParameters } from "./baseParameters.js";
@@ -1,9 +1,20 @@
1
+ export interface TimerOptions {
2
+ ref?: boolean;
3
+ signal?: AbortSignal;
4
+ }
5
+ export interface PollingOptionsConstructor {
6
+ initialDelaySec?: number;
7
+ delaySec?: number;
8
+ maxRetries?: number;
9
+ initialTimerOptions?: TimerOptions;
10
+ recurringTimerOptions?: TimerOptions;
11
+ }
1
12
  /**
2
13
  * Parameters for the internal polling loop in `enqueueAndGetInference()`.
3
14
  *
4
15
  * Default behavior:
5
- * - `initialDelaySec` = 2s
6
- * - `delaySec` = 1.5s
16
+ * - `initialDelaySec` = 2
17
+ * - `delaySec` = 1.5
7
18
  * - `maxRetries` = 80
8
19
  *
9
20
  * Validation rules:
@@ -12,38 +23,34 @@
12
23
  * - `maxRetries` >= 2
13
24
  *
14
25
  * The `initialTimerOptions` and `recurringTimerOptions` objects let you pass an
15
- * `AbortSignal` or make the timer `unref`-ed to the `setTimeout()`.
26
+ * `AbortSignal` or make the timer `ref`-ed to the `setTimeout()`.
16
27
  *
17
28
  * @category ClientV2
18
29
  * @example
19
- * const params = {
30
+ * ```
31
+ * const pollingOptions = {
20
32
  * initialDelaySec: 4,
21
33
  * delaySec: 2,
22
34
  * maxRetries: 50
23
35
  * };
24
36
  *
25
- * const inference = await client.enqueueAndGetInference(inputDoc, params);
37
+ * const inference = await client.enqueueAndGetInference(
38
+ * inputDoc, params, pollingOptions
39
+ * );
40
+ * ```
26
41
  */
27
- export interface PollingOptions {
42
+ export declare class PollingOptions {
28
43
  /** Number of seconds to wait *before the first poll*. */
29
- initialDelaySec?: number;
44
+ initialDelaySec: number;
30
45
  /** Interval in seconds between two consecutive polls. */
31
- delaySec?: number;
46
+ delaySec: number;
32
47
  /** Maximum number of polling attempts (including the first one). */
33
- maxRetries?: number;
48
+ maxRetries: number;
34
49
  /** Options passed to the initial `setTimeout()`. */
35
- initialTimerOptions?: {
36
- ref?: boolean;
37
- signal?: AbortSignal;
38
- };
50
+ initialTimerOptions?: TimerOptions;
39
51
  /** Options passed to every recurring `setTimeout()`. */
40
- recurringTimerOptions?: {
41
- ref?: boolean;
42
- signal?: AbortSignal;
43
- };
44
- }
45
- export interface ValidatedPollingOptions extends PollingOptions {
46
- initialDelaySec: number;
47
- delaySec: number;
48
- maxRetries: number;
52
+ recurringTimerOptions?: TimerOptions;
53
+ constructor(params?: PollingOptionsConstructor);
54
+ validateOptions(): void;
55
+ toString(): string;
49
56
  }
@@ -1 +1,82 @@
1
- export {};
1
+ import { MindeeConfigurationError } from "../../errors/index.js";
2
+ import { logger } from "../../logger.js";
3
+ const minInitialDelay = 1;
4
+ const minDelaySec = 1;
5
+ const minRetries = 2;
6
+ /**
7
+ * Parameters for the internal polling loop in `enqueueAndGetInference()`.
8
+ *
9
+ * Default behavior:
10
+ * - `initialDelaySec` = 2
11
+ * - `delaySec` = 1.5
12
+ * - `maxRetries` = 80
13
+ *
14
+ * Validation rules:
15
+ * - `initialDelaySec` >= 1
16
+ * - `delaySec` >= 1
17
+ * - `maxRetries` >= 2
18
+ *
19
+ * The `initialTimerOptions` and `recurringTimerOptions` objects let you pass an
20
+ * `AbortSignal` or make the timer `ref`-ed to the `setTimeout()`.
21
+ *
22
+ * @category ClientV2
23
+ * @example
24
+ * ```
25
+ * const pollingOptions = {
26
+ * initialDelaySec: 4,
27
+ * delaySec: 2,
28
+ * maxRetries: 50
29
+ * };
30
+ *
31
+ * const inference = await client.enqueueAndGetInference(
32
+ * inputDoc, params, pollingOptions
33
+ * );
34
+ * ```
35
+ */
36
+ export class PollingOptions {
37
+ constructor(params) {
38
+ if (!params) {
39
+ params = {};
40
+ }
41
+ if (!params.initialDelaySec) {
42
+ this.initialDelaySec = 2;
43
+ }
44
+ else {
45
+ this.initialDelaySec = params.initialDelaySec;
46
+ }
47
+ if (!params.delaySec) {
48
+ this.delaySec = 1.5;
49
+ }
50
+ else {
51
+ this.delaySec = params.delaySec;
52
+ }
53
+ if (!params.maxRetries) {
54
+ this.maxRetries = 80;
55
+ }
56
+ else {
57
+ this.maxRetries = params.maxRetries;
58
+ }
59
+ if (params.initialTimerOptions) {
60
+ this.initialTimerOptions = params.initialTimerOptions;
61
+ }
62
+ if (params.recurringTimerOptions) {
63
+ this.recurringTimerOptions = params.recurringTimerOptions;
64
+ }
65
+ this.validateOptions();
66
+ logger.debug(`Polling options initialized: ${this.toString()}`);
67
+ }
68
+ validateOptions() {
69
+ if (this.delaySec < minDelaySec) {
70
+ throw new MindeeConfigurationError(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`);
71
+ }
72
+ if (this.initialDelaySec < minInitialDelay) {
73
+ throw new MindeeConfigurationError(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`);
74
+ }
75
+ if (this.maxRetries < minRetries) {
76
+ throw new MindeeConfigurationError(`Cannot set retry to less than ${minRetries}.`);
77
+ }
78
+ }
79
+ toString() {
80
+ return `{ initialDelaySec: ${this.initialDelaySec}, delaySec: ${this.delaySec}, maxRetries: ${this.maxRetries} }`;
81
+ }
82
+ }
@@ -2,7 +2,7 @@ import { Dispatcher } from "undici";
2
2
  import { InputSource } from "../input/index.js";
3
3
  import { JobResponse } from "./parsing/index.js";
4
4
  import { MindeeApiV2 } from "./http/mindeeApiV2.js";
5
- import { ValidatedPollingOptions } from "./client/index.js";
5
+ import { PollingOptions, PollingOptionsConstructor } from "./client/index.js";
6
6
  import { BaseProduct } from "../v2/product/baseProduct.js";
7
7
  /**
8
8
  * Options for the V2 Mindee Client.
@@ -65,15 +65,16 @@ export declare class Client {
65
65
  * @param inputSource file or URL to parse.
66
66
  * @param params parameters relating to prediction options.
67
67
  *
68
+ * @param pollingOptions options for the polling loop, see {@link PollingOptions}.
68
69
  * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
69
70
  * @category Synchronous
70
71
  * @returns a `Promise` containing parsing results.
71
72
  */
72
- enqueueAndGetResult<P extends typeof BaseProduct>(product: P, inputSource: InputSource, params: InstanceType<P["parametersClass"]> | ConstructorParameters<P["parametersClass"]>[0]): Promise<InstanceType<P["responseClass"]>>;
73
+ enqueueAndGetResult<P extends typeof BaseProduct>(product: P, inputSource: InputSource, params: InstanceType<P["parametersClass"]> | ConstructorParameters<P["parametersClass"]>[0], pollingOptions?: PollingOptionsConstructor): Promise<InstanceType<P["responseClass"]>>;
73
74
  /**
74
75
  * Send a document to an endpoint and poll the server until the result is sent or
75
76
  * until the maximum number of tries is reached.
76
77
  * @protected
77
78
  */
78
- protected pollForResult<P extends typeof BaseProduct>(product: typeof BaseProduct, pollingOptions: ValidatedPollingOptions, queueId: string): Promise<InstanceType<P["responseClass"]>>;
79
+ protected pollForResult<P extends typeof BaseProduct>(product: typeof BaseProduct, pollingOptions: PollingOptions, queueId: string): Promise<InstanceType<P["responseClass"]>>;
79
80
  }
package/src/v2/client.js CHANGED
@@ -4,6 +4,7 @@ import { errorHandler } from "../errors/handler.js";
4
4
  import { LOG_LEVELS, logger } from "../logger.js";
5
5
  import { MindeeApiV2 } from "./http/mindeeApiV2.js";
6
6
  import { MindeeHttpErrorV2 } from "./http/errors.js";
7
+ import { PollingOptions } from "./client/index.js";
7
8
  /**
8
9
  * Mindee Client V2 class that centralizes most basic operations.
9
10
  *
@@ -76,15 +77,16 @@ export class Client {
76
77
  * @param inputSource file or URL to parse.
77
78
  * @param params parameters relating to prediction options.
78
79
  *
80
+ * @param pollingOptions options for the polling loop, see {@link PollingOptions}.
79
81
  * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
80
82
  * @category Synchronous
81
83
  * @returns a `Promise` containing parsing results.
82
84
  */
83
- async enqueueAndGetResult(product, inputSource, params) {
85
+ async enqueueAndGetResult(product, inputSource, params, pollingOptions) {
84
86
  const paramsInstance = new product.parametersClass(params);
85
- const pollingOptions = paramsInstance.getValidatedPollingOptions();
87
+ const pollingOptionsInstance = new PollingOptions(pollingOptions);
86
88
  const jobResponse = await this.enqueue(product, inputSource, paramsInstance);
87
- return await this.pollForResult(product, pollingOptions, jobResponse.job.id);
89
+ return await this.pollForResult(product, pollingOptionsInstance, jobResponse.job.id);
88
90
  }
89
91
  /**
90
92
  * Send a document to an endpoint and poll the server until the result is sent or
@@ -114,8 +116,7 @@ export class Client {
114
116
  await setTimeout(pollingOptions.delaySec * 1000, undefined, pollingOptions.recurringTimerOptions);
115
117
  retryCounter++;
116
118
  }
117
- throw new MindeeError("Asynchronous parsing request timed out after " +
118
- pollingOptions.delaySec * retryCounter +
119
- " seconds");
119
+ throw new MindeeError(`Polling failed to retrieve a result after ${retryCounter} attempts. ` +
120
+ "You can increase poll attempts by passing the pollingOptions argument to enqueueAndGetResult()");
120
121
  }
121
122
  }
@@ -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;