mindee 5.7.2 → 5.8.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,10 @@
1
1
  # Mindee Node.js API Library Changelog
2
2
 
3
+ ## v5.8.0 - 2026-09-17
4
+ ### Changes
5
+ * :sparkles: better logging of errors
6
+
7
+
3
8
  ## v5.7.2 - 2026-09-16
4
9
  ### Fixes
5
10
  * :bug: RST output should be locale-agnostic
@@ -14,7 +19,6 @@
14
19
  ### Changes
15
20
  * :sparkles: add support for RAG search API
16
21
  * :recycle: rework and mutualize a lot of http classes
17
-
18
22
  ### Fixes
19
23
  * :bug: fix undici unexpectedly re-using request agents when not specified
20
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.7.2",
3
+ "version": "5.8.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "author": {
6
6
  "name": "Mindee",
@@ -133,15 +133,20 @@ _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_paramsToFormData = function
133
133
  }, _MindeeApiV2_processResponse = function _MindeeApiV2_processResponse(result, responseClass) {
134
134
  if (result.messageObj?.statusCode
135
135
  && (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) {
136
+ let errorResponse;
136
137
  if (result.data?.status !== null) {
137
- throw new MindeeHttpErrorV2(new ErrorResponse(result.data));
138
+ errorResponse = new ErrorResponse(result.data);
138
139
  }
139
- throw new MindeeHttpErrorV2(new ErrorResponse({
140
- status: result.messageObj?.statusCode ?? -1,
141
- title: "Unknown Error",
142
- detail: result.data?.detail ?? "The server returned an Unknown error.",
143
- code: `${result.messageObj?.statusCode ?? -1}-000`,
144
- }));
140
+ else {
141
+ errorResponse = new ErrorResponse({
142
+ status: result.messageObj?.statusCode ?? -1,
143
+ title: "Unknown Error",
144
+ detail: result.data?.detail ?? "The server returned an Unknown error.",
145
+ code: `${result.messageObj?.statusCode ?? -1}-000`,
146
+ });
147
+ }
148
+ logger.error(errorResponse.toString());
149
+ throw new MindeeHttpErrorV2(errorResponse);
145
150
  }
146
151
  try {
147
152
  return new responseClass(result.data);
package/src/v2/index.d.ts CHANGED
@@ -3,6 +3,6 @@ export * as parsing from "./parsing/index.js";
3
3
  export * as product from "./product/index.js";
4
4
  export * as search from "./search/index.js";
5
5
  export { Client } from "./client.js";
6
- export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
6
+ export { JobResponse, ErrorResponse, LocalResponse, FailedInferenceResponse, } from "./parsing/index.js";
7
7
  export type { BaseProductParameters, TimerOptions } from "./clientOptions/index.js";
8
8
  export { PollingOptions } from "./clientOptions/index.js";
package/src/v2/index.js CHANGED
@@ -3,5 +3,5 @@ export * as parsing from "./parsing/index.js";
3
3
  export * as product from "./product/index.js";
4
4
  export * as search from "./search/index.js";
5
5
  export { Client } from "./client.js";
6
- export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
6
+ export { JobResponse, ErrorResponse, LocalResponse, FailedInferenceResponse, } from "./parsing/index.js";
7
7
  export { PollingOptions } from "./clientOptions/index.js";
@@ -6,7 +6,7 @@ export declare class ErrorItem {
6
6
  /**
7
7
  * A JSON Pointer to the location of the body property.
8
8
  */
9
- pointer?: string;
9
+ pointer: string;
10
10
  /**
11
11
  * Explicit information on the issue.
12
12
  */
@@ -6,9 +6,7 @@ export class ErrorItem {
6
6
  * @param serverResponse JSON response from the server.
7
7
  */
8
8
  constructor(serverResponse) {
9
- if (serverResponse["pointer"] !== undefined) {
10
- this.pointer = serverResponse["pointer"];
11
- }
9
+ this.pointer = serverResponse["pointer"];
12
10
  this.detail = serverResponse["detail"];
13
11
  }
14
12
  }
@@ -15,4 +15,8 @@ export declare class ErrorResponse extends BaseResponse implements ErrorDetails
15
15
  * @param serverResponse JSON response from the server.
16
16
  */
17
17
  constructor(serverResponse: StringDict);
18
+ /**
19
+ * To make the error prettier to display.
20
+ */
21
+ toString(): string;
18
22
  }
@@ -20,4 +20,30 @@ export class ErrorResponse extends BaseResponse {
20
20
  this.errors = [];
21
21
  }
22
22
  }
23
+ /**
24
+ * To make the error prettier to display.
25
+ */
26
+ toString() {
27
+ const result = [];
28
+ result.push("Error Details");
29
+ result.push("=============");
30
+ result.push(`:HTTP Status: ${this.status}`);
31
+ result.push(`:Title: ${this.title}`);
32
+ result.push(`:Code: ${this.code}`);
33
+ result.push(`:Detail: ${this.detail}`);
34
+ if (this.errors && this.errors.length > 0) {
35
+ result.push("");
36
+ result.push("Error Items");
37
+ result.push("-----------");
38
+ this.errors.forEach((error, i) => {
39
+ result.push(`**Error ${i + 1}:**`);
40
+ result.push(` :Pointer: ${error.pointer}`);
41
+ result.push(` :Detail: ${error.detail}`);
42
+ if (i < this.errors.length - 1) {
43
+ result.push("");
44
+ }
45
+ });
46
+ }
47
+ return result.join("\n") + "\n";
48
+ }
23
49
  }
@@ -1,7 +1,7 @@
1
1
  export { ErrorResponse, ErrorItem, } from "./error/index.js";
2
2
  export type { ErrorDetails } from "./error/index.js";
3
3
  export { Job, JobResponse, JobWebhook, } from "./job/index.js";
4
- export { BaseInference, InferenceFile, InferenceModel, } from "./inference/index.js";
4
+ export { BaseInference, InferenceFile, InferenceModel, FailedInferenceResponse, } from "./inference/index.js";
5
5
  export { LocalResponse } from "./localResponse.js";
6
6
  export { BaseResponse } from "./baseResponse.js";
7
7
  export type { ResponseConstructor } from "./baseResponse.js";
@@ -1,6 +1,6 @@
1
1
  export { ErrorResponse, ErrorItem, } from "./error/index.js";
2
2
  export { Job, JobResponse, JobWebhook, } from "./job/index.js";
3
- export { BaseInference, InferenceFile, InferenceModel, } from "./inference/index.js";
3
+ export { BaseInference, InferenceFile, InferenceModel, FailedInferenceResponse, } from "./inference/index.js";
4
4
  export { LocalResponse } from "./localResponse.js";
5
5
  export { BaseResponse } from "./baseResponse.js";
6
6
  export * as field from "./inference/field/index.js";
@@ -1,4 +1,5 @@
1
1
  export { BaseInference } from "./baseInference.js";
2
2
  export { InferenceFile } from "./inferenceFile.js";
3
3
  export { InferenceModel } from "./inferenceModel.js";
4
+ export { FailedInferenceResponse } from "./failedInferenceResponse.js";
4
5
  export * as field from "./field/index.js";
@@ -1,4 +1,5 @@
1
1
  export { BaseInference } from "./baseInference.js";
2
2
  export { InferenceFile } from "./inferenceFile.js";
3
3
  export { InferenceModel } from "./inferenceModel.js";
4
+ export { FailedInferenceResponse } from "./failedInferenceResponse.js";
4
5
  export * as field from "./field/index.js";