mindee 4.32.0 → 4.33.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.33.0 - 2025-10-27
4
+ ### Changes
5
+ * :sparkles: add more details to V2 errors
6
+ * :sparkles: add RAG metadata in V2 results
7
+
8
+
3
9
  ## v4.32.0 - 2025-10-13
4
10
  ### Changes
5
11
  * :sparkles: add getting page count of a local source
@@ -12,7 +18,7 @@
12
18
 
13
19
  ## v4.31.0 - 2025-10-07
14
20
  ### Changes
15
- * :sparkles: allow comparing v2 field confidence
21
+ * :sparkles: allow comparing V2 field confidence
16
22
  * :coffin: remove obsolete US Mail V2
17
23
 
18
24
 
package/README.md CHANGED
@@ -6,26 +6,26 @@ Quickly and easily connect to Mindee's API services using Node.js.
6
6
  ## Mindee API Versions
7
7
  This client library has support for both Mindee platform versions.
8
8
 
9
- ### Latest - V2
10
- This is the new platform located here:
9
+ ### V2 - Latest
10
+ This is the latest platform located here:
11
11
 
12
12
  https://app.mindee.com
13
13
 
14
14
  It uses **API version 2**.
15
15
 
16
16
  Consult the
17
- **[Latest Documentation](https://docs.mindee.com/integrations/client-libraries-sdk)**
17
+ **[V2 Documentation](https://docs.mindee.com/integrations/client-libraries-sdk)**
18
18
 
19
19
 
20
- ### Legacy - V1
21
- This is the legacy platform located here:
20
+ ### V1
21
+ This is the platform located here:
22
22
 
23
23
  https://platform.mindee.com/
24
24
 
25
25
  It uses **API version 1**.
26
26
 
27
27
  Consult the
28
- **[Legacy Documentation](https://developers.mindee.com/docs/nodejs-getting-started)**
28
+ **[V1 Documentation](https://docs.mindee.com/v1/libraries/nodejs-sdk)**
29
29
 
30
30
  ## Additional Information
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.32.0",
3
+ "version": "4.33.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/clientV2.js CHANGED
@@ -105,7 +105,7 @@ class ClientV2 {
105
105
  return this.getInference(pollResults.job.id);
106
106
  }
107
107
  logger_1.logger.debug(`Polling server for parsing result with queueId: ${queueId}.
108
- Attempt n°${retryCounter}/${validatedAsyncParams.maxRetries}.
108
+ Attempt no. ${retryCounter} of ${validatedAsyncParams.maxRetries}.
109
109
  Job status: ${pollResults.job.status}.`);
110
110
  await (0, promises_1.setTimeout)(validatedAsyncParams.delaySec * 1000, undefined, validatedAsyncParams.recurringTimerOptions);
111
111
  pollResults = await this.getJob(queueId);
@@ -113,7 +113,7 @@ Job status: ${pollResults.job.status}.`);
113
113
  }
114
114
  const error = pollResults.job.error;
115
115
  if (error) {
116
- throw new mindeeError_1.MindeeHttpErrorV2(error.status, error.detail);
116
+ throw new mindeeError_1.MindeeHttpErrorV2(error);
117
117
  }
118
118
  throw Error("Asynchronous parsing request timed out after " +
119
119
  validatedAsyncParams.delaySec * retryCounter +
@@ -1,3 +1,4 @@
1
+ import { ErrorDetails, ErrorResponse } from "../parsing/v2";
1
2
  /**
2
3
  * Main Mindee Error custom class.
3
4
  */
@@ -19,8 +20,10 @@ export declare class MindeePdfError extends MindeeError {
19
20
  export declare class MindeeApiV2Error extends MindeeError {
20
21
  constructor(message: string);
21
22
  }
22
- export declare class MindeeHttpErrorV2 extends MindeeError {
23
+ export declare class MindeeHttpErrorV2 extends MindeeError implements ErrorDetails {
23
24
  status: number;
24
25
  detail: string;
25
- constructor(status: number, detail: string);
26
+ title: string;
27
+ code: string;
28
+ constructor(error: ErrorResponse);
26
29
  }
@@ -43,10 +43,12 @@ class MindeeApiV2Error extends MindeeError {
43
43
  }
44
44
  exports.MindeeApiV2Error = MindeeApiV2Error;
45
45
  class MindeeHttpErrorV2 extends MindeeError {
46
- constructor(status, detail) {
47
- super(`HTTP ${status} - ${detail}`);
48
- this.status = status;
49
- this.detail = detail;
46
+ constructor(error) {
47
+ super(`HTTP ${error.status} :: ${error.title} - ${error.detail}`);
48
+ this.status = error.status;
49
+ this.detail = error.detail;
50
+ this.title = error.title;
51
+ this.code = error.code;
50
52
  this.name = "MindeeHttpErrorV2";
51
53
  }
52
54
  }
@@ -28,7 +28,7 @@ export declare class MindeeApiV2 {
28
28
  * Throws an error if the server's response contains one.
29
29
  * @param jobId The document's ID in the queue.
30
30
  * @category Asynchronous
31
- * @returns a `Promise` containing either the parsed result, or information on the queue.
31
+ * @returns a `Promise` containing information on the queue.
32
32
  */
33
33
  reqGetJob(jobId: string): Promise<JobResponse>;
34
34
  }
@@ -36,8 +36,8 @@ class MindeeApiV2 {
36
36
  throw new Error("Model ID must be provided");
37
37
  }
38
38
  const result = await __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_documentEnqueuePost).call(this, inputSource, params);
39
- if (result.data.error?.code !== undefined) {
40
- throw new mindeeError_1.MindeeHttpErrorV2(result.data.error.code, result.data.error.message ?? "Unknown error.");
39
+ if (result.data.error !== undefined) {
40
+ throw new mindeeError_1.MindeeHttpErrorV2(result.data.error);
41
41
  }
42
42
  return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, result, v2_1.JobResponse);
43
43
  }
@@ -57,7 +57,7 @@ class MindeeApiV2 {
57
57
  * Throws an error if the server's response contains one.
58
58
  * @param jobId The document's ID in the queue.
59
59
  * @category Asynchronous
60
- * @returns a `Promise` containing either the parsed result, or information on the queue.
60
+ * @returns a `Promise` containing information on the queue.
61
61
  */
62
62
  async reqGetJob(jobId) {
63
63
  const queueResponse = await __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_inferenceResultReqGet).call(this, jobId, "jobs");
@@ -68,9 +68,14 @@ exports.MindeeApiV2 = MindeeApiV2;
68
68
  _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function _MindeeApiV2_processResponse(result, responseType) {
69
69
  if (result.messageObj?.statusCode && (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) {
70
70
  if (result.data?.status !== null) {
71
- throw new mindeeError_1.MindeeHttpErrorV2(result.data?.status, result.data?.detail ?? "Unknown error.");
71
+ throw new mindeeError_1.MindeeHttpErrorV2(new v2_1.ErrorResponse(result.data));
72
72
  }
73
- throw new mindeeError_1.MindeeHttpErrorV2(result.messageObj?.statusCode ?? -1, result.data?.statusMessage ?? "Unknown error.");
73
+ throw new mindeeError_1.MindeeHttpErrorV2(new v2_1.ErrorResponse({
74
+ status: result.messageObj?.statusCode ?? -1,
75
+ title: "Unknown Error",
76
+ detail: result.data?.detail ?? "The server returned an Unknown error.",
77
+ code: `${result.messageObj?.statusCode ?? -1}-000`,
78
+ }));
74
79
  }
75
80
  try {
76
81
  return new responseType(result.data);
package/src/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * as product from "./product";
2
2
  export { Client, PredictOptions, WorkflowOptions } from "./client";
3
3
  export { ClientV2, InferenceParameters, PollingOptions } from "./clientV2";
4
4
  export { AsyncPredictResponse, PredictResponse, Inference, Prediction, Document, Page, } from "./parsing/common";
5
- export { InferenceFile, InferenceResponse, JobResponse, RawText, } from "./parsing/v2";
5
+ export { InferenceFile, InferenceResponse, JobResponse, RawText, RagMetadata, } from "./parsing/v2";
6
6
  export { InputSource, Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput, PageOptions, PageOptionsOperation, LocalResponse } from "./input";
7
7
  export * as internal from "./internal";
8
8
  export * as imageOperations from "./imageOperations";
package/src/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.imageOperations = exports.internal = exports.LocalResponse = exports.PageOptionsOperation = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.BufferInput = exports.Base64Input = exports.InputSource = exports.RawText = exports.JobResponse = exports.InferenceResponse = exports.InferenceFile = exports.Page = exports.Document = exports.Prediction = exports.Inference = exports.PredictResponse = exports.AsyncPredictResponse = exports.ClientV2 = exports.Client = exports.product = void 0;
36
+ exports.imageOperations = exports.internal = exports.LocalResponse = exports.PageOptionsOperation = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.BufferInput = exports.Base64Input = exports.InputSource = exports.RagMetadata = exports.RawText = exports.JobResponse = exports.InferenceResponse = exports.InferenceFile = exports.Page = exports.Document = exports.Prediction = exports.Inference = exports.PredictResponse = exports.AsyncPredictResponse = exports.ClientV2 = exports.Client = exports.product = void 0;
37
37
  exports.product = __importStar(require("./product"));
38
38
  var client_1 = require("./client");
39
39
  Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
@@ -51,6 +51,7 @@ Object.defineProperty(exports, "InferenceFile", { enumerable: true, get: functio
51
51
  Object.defineProperty(exports, "InferenceResponse", { enumerable: true, get: function () { return v2_1.InferenceResponse; } });
52
52
  Object.defineProperty(exports, "JobResponse", { enumerable: true, get: function () { return v2_1.JobResponse; } });
53
53
  Object.defineProperty(exports, "RawText", { enumerable: true, get: function () { return v2_1.RawText; } });
54
+ Object.defineProperty(exports, "RagMetadata", { enumerable: true, get: function () { return v2_1.RagMetadata; } });
54
55
  var input_1 = require("./input");
55
56
  Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return input_1.InputSource; } });
56
57
  Object.defineProperty(exports, "Base64Input", { enumerable: true, get: function () { return input_1.Base64Input; } });
@@ -0,0 +1,15 @@
1
+ import { StringDict } from "../common";
2
+ export declare class ErrorItem {
3
+ /**
4
+ * The HTTP status code returned by the server.
5
+ */
6
+ pointer?: string;
7
+ /**
8
+ * Explicit information on the issue.
9
+ */
10
+ detail: string;
11
+ /**
12
+ * @param serverResponse JSON response from the server.
13
+ */
14
+ constructor(serverResponse: StringDict);
15
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorItem = void 0;
4
+ class ErrorItem {
5
+ /**
6
+ * @param serverResponse JSON response from the server.
7
+ */
8
+ constructor(serverResponse) {
9
+ if (serverResponse["pointer"] !== undefined) {
10
+ this.pointer = serverResponse["pointer"];
11
+ }
12
+ this.detail = serverResponse["detail"];
13
+ }
14
+ }
15
+ exports.ErrorItem = ErrorItem;
@@ -1,13 +1,35 @@
1
1
  import { StringDict } from "../common";
2
- export declare class ErrorResponse {
2
+ import { ErrorItem } from "./errorItem";
3
+ export interface ErrorDetails {
3
4
  /**
4
- * The HTTP code status.
5
+ * The HTTP status code returned by the server.
5
6
  */
6
7
  status: number;
7
8
  /**
8
- * The detail on the error.
9
+ * A human-readable explanation specific to the occurrence of the problem.
9
10
  */
10
11
  detail: string;
12
+ /**
13
+ * A short, human-readable summary of the problem.
14
+ */
15
+ title: string;
16
+ /**
17
+ * A machine-readable code specific to the occurrence of the problem.
18
+ */
19
+ code: string;
20
+ }
21
+ /**
22
+ * Error response detailing a problem. The format adheres to RFC 9457.
23
+ */
24
+ export declare class ErrorResponse implements ErrorDetails {
25
+ status: number;
26
+ detail: string;
27
+ title: string;
28
+ code: string;
29
+ /**
30
+ * A machine-readable code specific to the occurrence of the problem.
31
+ */
32
+ errors: ErrorItem[];
11
33
  /**
12
34
  * @param serverResponse JSON response from the server.
13
35
  */
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ErrorResponse = void 0;
4
+ const errorItem_1 = require("./errorItem");
5
+ /**
6
+ * Error response detailing a problem. The format adheres to RFC 9457.
7
+ */
4
8
  class ErrorResponse {
5
9
  /**
6
10
  * @param serverResponse JSON response from the server.
@@ -8,6 +12,14 @@ class ErrorResponse {
8
12
  constructor(serverResponse) {
9
13
  this.status = serverResponse["status"];
10
14
  this.detail = serverResponse["detail"];
15
+ this.title = serverResponse["title"];
16
+ this.code = serverResponse["code"];
17
+ if (serverResponse["errors"] !== undefined) {
18
+ this.errors = serverResponse["errors"].map((error) => new errorItem_1.ErrorItem(error));
19
+ }
20
+ else {
21
+ this.errors = [];
22
+ }
11
23
  }
12
24
  }
13
25
  exports.ErrorResponse = ErrorResponse;
@@ -1,5 +1,6 @@
1
1
  export { CommonResponse } from "./commonResponse";
2
- export { ErrorResponse } from "./errorResponse";
2
+ export { ErrorResponse, ErrorDetails } from "./errorResponse";
3
+ export { ErrorItem } from "./errorItem";
3
4
  export { Inference } from "./inference";
4
5
  export { InferenceActiveOptions } from "./inferenceActiveOptions";
5
6
  export { InferenceFile } from "./inferenceFile";
@@ -10,3 +11,4 @@ export { Job } from "./job";
10
11
  export { JobResponse } from "./jobResponse";
11
12
  export { RawText } from "./rawText";
12
13
  export { JobWebhook } from "./jobWebhook";
14
+ export { RagMetadata } from "./ragMetadata";
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JobWebhook = exports.RawText = exports.JobResponse = exports.Job = exports.InferenceResult = exports.InferenceResponse = exports.InferenceModel = exports.InferenceFile = exports.InferenceActiveOptions = exports.Inference = exports.ErrorResponse = exports.CommonResponse = void 0;
3
+ exports.RagMetadata = exports.JobWebhook = exports.RawText = exports.JobResponse = exports.Job = exports.InferenceResult = exports.InferenceResponse = exports.InferenceModel = exports.InferenceFile = exports.InferenceActiveOptions = exports.Inference = exports.ErrorItem = exports.ErrorResponse = exports.CommonResponse = void 0;
4
4
  var commonResponse_1 = require("./commonResponse");
5
5
  Object.defineProperty(exports, "CommonResponse", { enumerable: true, get: function () { return commonResponse_1.CommonResponse; } });
6
6
  var errorResponse_1 = require("./errorResponse");
7
7
  Object.defineProperty(exports, "ErrorResponse", { enumerable: true, get: function () { return errorResponse_1.ErrorResponse; } });
8
+ var errorItem_1 = require("./errorItem");
9
+ Object.defineProperty(exports, "ErrorItem", { enumerable: true, get: function () { return errorItem_1.ErrorItem; } });
8
10
  var inference_1 = require("./inference");
9
11
  Object.defineProperty(exports, "Inference", { enumerable: true, get: function () { return inference_1.Inference; } });
10
12
  var inferenceActiveOptions_1 = require("./inferenceActiveOptions");
@@ -25,3 +27,5 @@ var rawText_1 = require("./rawText");
25
27
  Object.defineProperty(exports, "RawText", { enumerable: true, get: function () { return rawText_1.RawText; } });
26
28
  var jobWebhook_1 = require("./jobWebhook");
27
29
  Object.defineProperty(exports, "JobWebhook", { enumerable: true, get: function () { return jobWebhook_1.JobWebhook; } });
30
+ var ragMetadata_1 = require("./ragMetadata");
31
+ Object.defineProperty(exports, "RagMetadata", { enumerable: true, get: function () { return ragMetadata_1.RagMetadata; } });
@@ -1,6 +1,7 @@
1
1
  import { InferenceFields } from "./field";
2
2
  import { StringDict } from "../common";
3
3
  import { RawText } from "./rawText";
4
+ import { RagMetadata } from "./ragMetadata";
4
5
  export declare class InferenceResult {
5
6
  /**
6
7
  * Fields contained in the inference.
@@ -10,6 +11,10 @@ export declare class InferenceResult {
10
11
  * Raw text extracted from all pages.
11
12
  */
12
13
  rawText?: RawText;
14
+ /**
15
+ * RAG metadata.
16
+ */
17
+ rag?: RagMetadata;
13
18
  constructor(serverResponse: StringDict);
14
19
  toString(): string;
15
20
  }
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InferenceResult = void 0;
4
4
  const field_1 = require("./field");
5
5
  const rawText_1 = require("./rawText");
6
+ const ragMetadata_1 = require("./ragMetadata");
6
7
  class InferenceResult {
7
8
  constructor(serverResponse) {
8
9
  this.fields = new field_1.InferenceFields(serverResponse["fields"]);
9
10
  if (serverResponse["raw_text"]) {
10
11
  this.rawText = new rawText_1.RawText(serverResponse["raw_text"]);
11
12
  }
13
+ if (serverResponse["rag"]) {
14
+ this.rag = new ragMetadata_1.RagMetadata(serverResponse["rag"]);
15
+ }
12
16
  }
13
17
  toString() {
14
18
  return `Fields\n======\n${this.fields}`;
@@ -0,0 +1,8 @@
1
+ import { StringDict } from "../common";
2
+ export declare class RagMetadata {
3
+ /**
4
+ * The UUID of the matched document used during the RAG operation.
5
+ */
6
+ retrievedDocumentId?: string;
7
+ constructor(serverResponse: StringDict);
8
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RagMetadata = void 0;
4
+ class RagMetadata {
5
+ constructor(serverResponse) {
6
+ this.retrievedDocumentId = serverResponse["retrieved_document_id"] ?? undefined;
7
+ }
8
+ }
9
+ exports.RagMetadata = RagMetadata;