mindee 5.0.2 → 5.1.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,6 +1,14 @@
1
1
  # Mindee Node.js API Library Changelog
2
2
 
3
3
 
4
+ ## v5.1.0 - 2026-03-02
5
+ ### Changes
6
+ * :sparkles: add to job information
7
+ ### Fixes
8
+ * :bug: fix for printing crop results
9
+ * :bug: proper init of webhook payload
10
+
11
+
4
12
  ## v5.0.2 - 2026-02-27
5
13
  ### Changes
6
14
  * :bug: always use the provided result URL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.0.2",
3
+ "version": "5.1.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "author": {
6
6
  "name": "Mindee",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/mocha": "^10.0.10",
64
- "@types/node": "^20.19.33",
64
+ "@types/node": "^20.19.35",
65
65
  "@types/tmp": "^0.2.6",
66
66
  "@typescript-eslint/eslint-plugin": "^8.56.1",
67
67
  "@typescript-eslint/parser": "^8.56.1",
@@ -37,6 +37,7 @@ export class Polygon extends Array {
37
37
  return isPointInY(point, yCoords.min, yCoords.max);
38
38
  }
39
39
  toString() {
40
- return this.map((point) => `(${point})`).join(", ");
40
+ const points = this.map((point) => `(${point})`).join(", ");
41
+ return `(${points})`;
41
42
  }
42
43
  }
@@ -1,13 +1,13 @@
1
1
  import { Polygon } from "../../../../geometry/index.js";
2
2
  import { StringDict } from "../../../../parsing/stringDict.js";
3
3
  /**
4
- * Location of a field.
4
+ * A field's location on the document.
5
5
  */
6
6
  export declare class FieldLocation {
7
- /** Free polygon made up of points (can be null when not provided). */
8
- readonly polygon: Polygon | null;
9
- /** Page ID. */
10
- readonly page: number | undefined;
7
+ /** Position information as a list of points in clockwise order. */
8
+ readonly polygon: Polygon;
9
+ /** 0-based page index of where the polygon is located. */
10
+ readonly page: any;
11
11
  constructor(serverResponse: StringDict);
12
12
  toString(): string;
13
13
  }
@@ -1,13 +1,13 @@
1
1
  import { Polygon } from "../../../../geometry/index.js";
2
2
  /**
3
- * Location of a field.
3
+ * A field's location on the document.
4
4
  */
5
5
  export class FieldLocation {
6
6
  constructor(serverResponse) {
7
- this.polygon = "polygon" in serverResponse ? new Polygon(...serverResponse["polygon"]) : null;
8
- this.page = "page" in serverResponse ? serverResponse["page"] : undefined;
7
+ this.polygon = new Polygon(...serverResponse["polygon"]);
8
+ this.page = serverResponse["page"];
9
9
  }
10
10
  toString() {
11
- return this.polygon?.toString() ?? "";
11
+ return `${this.polygon} on page ${this.page}`;
12
12
  }
13
13
  }
@@ -14,9 +14,13 @@ export declare class Job {
14
14
  */
15
15
  error?: ErrorResponse;
16
16
  /**
17
- * Timestamp of the job creation.
17
+ * Date and time of the Job creation.
18
18
  */
19
19
  createdAt: Date | null;
20
+ /**
21
+ * Date and time of the Job completion. Filled once processing is finished.
22
+ */
23
+ completedAt: Date | null | undefined;
20
24
  /**
21
25
  * ID of the model.
22
26
  */
@@ -1,5 +1,6 @@
1
1
  import { parseDate } from "../../../parsing/index.js";
2
2
  import { ErrorResponse } from "../../../v2/index.js";
3
+ import { JobWebhook } from "./jobWebhook.js";
3
4
  /**
4
5
  * Job information for a V2 polling attempt.
5
6
  */
@@ -9,17 +10,21 @@ export class Job {
9
10
  if (serverResponse["status"] !== undefined) {
10
11
  this.status = serverResponse["status"];
11
12
  }
12
- if (serverResponse["error"] !== undefined &&
13
- serverResponse["error"] !== null &&
14
- Object.keys(serverResponse["error"]).length > 0) {
13
+ if (serverResponse["error"]) {
15
14
  this.error = new ErrorResponse(serverResponse["error"]);
16
15
  }
17
16
  this.createdAt = parseDate(serverResponse["created_at"]);
17
+ if (!serverResponse["completed_at"]) {
18
+ this.completedAt = undefined;
19
+ }
20
+ else {
21
+ this.completedAt = parseDate(serverResponse["completed_at"]);
22
+ }
18
23
  this.modelId = serverResponse["model_id"];
19
24
  this.pollingUrl = serverResponse["polling_url"];
20
25
  this.filename = serverResponse["filename"];
21
26
  this.resultUrl = serverResponse["result_url"];
22
27
  this.alias = serverResponse["alias"];
23
- this.webhooks = serverResponse["webhooks"];
28
+ this.webhooks = (serverResponse["webhooks"] ?? []).map((webhook) => new JobWebhook(webhook));
24
29
  }
25
30
  }
@@ -8,7 +8,7 @@ export class JobWebhook {
8
8
  this.id = serverResponse["id"];
9
9
  this.createdAt = parseDate(serverResponse["created_at"]);
10
10
  this.status = serverResponse["status"];
11
- if (serverResponse["error"] !== undefined) {
11
+ if (serverResponse["error"]) {
12
12
  this.error = new ErrorResponse(serverResponse["error"]);
13
13
  }
14
14
  }
@@ -5,6 +5,6 @@ export class CropItem {
5
5
  this.location = new FieldLocation(serverResponse["location"]);
6
6
  }
7
7
  toString() {
8
- return `${this.objectType}: ${this.location}`;
8
+ return `* :Location: ${this.location}\n :Object Type: ${this.objectType}`;
9
9
  }
10
10
  }
@@ -8,7 +8,7 @@ export class CropResult {
8
8
  this.crops = serverResponse["crops"].map((cropItem) => new CropItem(cropItem));
9
9
  }
10
10
  toString() {
11
- const crops = this.crops.map(item => item.toString()).join("\n * ");
12
- return `Crop\n====\n * ${crops}`;
11
+ const crops = this.crops.map(item => item.toString()).join("\n");
12
+ return `Crops\n=====\n${crops}`;
13
13
  }
14
14
  }