mindee 3.6.0 → 3.7.1

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 (50) hide show
  1. package/CHANGELOG.md +48 -39
  2. package/package.json +1 -1
  3. package/src/api/{response.d.ts → documentResponse.d.ts} +2 -2
  4. package/src/api/endpoint.d.ts +32 -5
  5. package/src/api/endpoint.js +104 -34
  6. package/src/api/index.d.ts +3 -2
  7. package/src/api/index.js +5 -3
  8. package/src/api/predictResponse.d.ts +33 -0
  9. package/src/api/predictResponse.js +52 -0
  10. package/src/cli.js +217 -65
  11. package/src/client.d.ts +20 -4
  12. package/src/client.js +65 -22
  13. package/src/documents/custom/fields.js +1 -1
  14. package/src/documents/custom/lineitems.d.ts +41 -0
  15. package/src/documents/custom/lineitems.js +127 -0
  16. package/src/documents/document.d.ts +1 -1
  17. package/src/documents/documentConfig.d.ts +12 -4
  18. package/src/documents/documentConfig.js +55 -24
  19. package/src/documents/eu/licensePlate/licensePlateV1.js +4 -2
  20. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +3 -2
  21. package/src/documents/fr/carteVitale/carteVitaleV1.js +2 -2
  22. package/src/documents/fr/idCard/idCardV1.js +10 -10
  23. package/src/documents/index.d.ts +2 -1
  24. package/src/documents/index.js +4 -2
  25. package/src/documents/invoice/invoiceV4.d.ts +2 -2
  26. package/src/documents/invoice/invoiceV4.js +1 -1
  27. package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +3 -3
  28. package/src/documents/invoiceSplitter/invoiceSplitterV1.js +1 -0
  29. package/src/documents/proofOfAddress/proofOfAddressV1.js +5 -6
  30. package/src/documents/receipt/receiptV3.d.ts +2 -2
  31. package/src/documents/receipt/receiptV3.js +1 -2
  32. package/src/documents/receipt/receiptV4.d.ts +3 -3
  33. package/src/documents/receipt/receiptV4.js +2 -4
  34. package/src/documents/{shipping_container → shippingContainer}/shippingContainerV1.js +2 -2
  35. package/src/fields/classification.d.ts +8 -0
  36. package/src/fields/classification.js +11 -0
  37. package/src/fields/field.d.ts +2 -2
  38. package/src/fields/field.js +1 -6
  39. package/src/fields/index.d.ts +1 -0
  40. package/src/fields/index.js +3 -1
  41. package/src/geometry.d.ts +18 -4
  42. package/src/geometry.js +40 -3
  43. package/src/index.d.ts +2 -2
  44. package/src/index.js +4 -1
  45. package/src/math/index.d.ts +1 -0
  46. package/src/math/index.js +5 -0
  47. package/src/math/precision.d.ts +1 -0
  48. package/src/math/precision.js +13 -0
  49. /package/src/api/{response.js → documentResponse.js} +0 -0
  50. /package/src/documents/{shipping_container → shippingContainer}/shippingContainerV1.d.ts +0 -0
package/src/geometry.d.ts CHANGED
@@ -4,18 +4,32 @@ export type MinMax = {
4
4
  };
5
5
  /** A point on the document defined by 2 coordinates: X, Y */
6
6
  export type Point = [number, number];
7
- /** A bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
8
- export type BoundingBox = [number, number, number, number];
7
+ /** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
8
+ export type BBox = [number, number, number, number];
9
+ /** A bounding box defined by 4 points. */
10
+ export type BoundingBox = [Point, Point, Point, Point];
9
11
  /** A polygon, composed of several Points. */
10
12
  export type Polygon = Array<Point>;
11
13
  /**
12
14
  * Given a Polygon, calculate a polygon that encompasses all points.
13
15
  */
14
- export declare function getBboxAsPolygon(polygon: Polygon): Polygon;
16
+ export declare function getBoundingBox(polygon: Polygon): BoundingBox;
17
+ /**
18
+ * Given a BBox, generate the associated bounding box.
19
+ */
20
+ export declare function getBoundingBoxFromBBox(bbox: BBox): BoundingBox;
21
+ /**
22
+ * Given 2 bbox, merge them.
23
+ */
24
+ export declare function mergeBbox(bbox1: BBox, bbox2: BBox): BBox;
15
25
  /**
16
26
  * Given a Polygon, calculate a bounding box that encompasses all points.
17
27
  */
18
- export declare function getBbox(polygon: Polygon): BoundingBox;
28
+ export declare function getBbox(polygon: Polygon): BBox;
29
+ /**
30
+ * Given polygons, calculate a bounding box that encompasses all points.
31
+ */
32
+ export declare function getBBoxForPolygons(polygons: Polygon[]): BBox;
19
33
  /**
20
34
  * Get the central point (centroid) given a list of points.
21
35
  */
package/src/geometry.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.relativeX = exports.isPointInPolygonX = exports.getMinMaxX = exports.isPointInX = exports.relativeY = exports.isPointInPolygonY = exports.getMinMaxY = exports.isPointInY = exports.getCentroid = exports.getBbox = exports.getBboxAsPolygon = void 0;
3
+ exports.relativeX = exports.isPointInPolygonX = exports.getMinMaxX = exports.isPointInX = exports.relativeY = exports.isPointInPolygonY = exports.getMinMaxY = exports.isPointInY = exports.getCentroid = exports.getBBoxForPolygons = exports.getBbox = exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = void 0;
4
4
  /**
5
5
  * Given a Polygon, calculate a polygon that encompasses all points.
6
6
  */
7
- function getBboxAsPolygon(polygon) {
7
+ function getBoundingBox(polygon) {
8
8
  const bbox = getBbox(polygon);
9
9
  return [
10
10
  [bbox[0], bbox[1]],
@@ -13,7 +13,31 @@ function getBboxAsPolygon(polygon) {
13
13
  [bbox[0], bbox[3]],
14
14
  ];
15
15
  }
16
- exports.getBboxAsPolygon = getBboxAsPolygon;
16
+ exports.getBoundingBox = getBoundingBox;
17
+ /**
18
+ * Given a BBox, generate the associated bounding box.
19
+ */
20
+ function getBoundingBoxFromBBox(bbox) {
21
+ return [
22
+ [bbox[0], bbox[1]],
23
+ [bbox[2], bbox[1]],
24
+ [bbox[2], bbox[3]],
25
+ [bbox[0], bbox[3]],
26
+ ];
27
+ }
28
+ exports.getBoundingBoxFromBBox = getBoundingBoxFromBBox;
29
+ /**
30
+ * Given 2 bbox, merge them.
31
+ */
32
+ function mergeBbox(bbox1, bbox2) {
33
+ return [
34
+ Math.min(bbox1[0], bbox2[0]),
35
+ Math.min(bbox1[1], bbox2[1]),
36
+ Math.max(bbox1[2], bbox2[2]),
37
+ Math.max(bbox1[3], bbox2[3]),
38
+ ];
39
+ }
40
+ exports.mergeBbox = mergeBbox;
17
41
  /**
18
42
  * Given a Polygon, calculate a bounding box that encompasses all points.
19
43
  */
@@ -27,6 +51,19 @@ function getBbox(polygon) {
27
51
  return [xMin, yMin, xMax, yMax];
28
52
  }
29
53
  exports.getBbox = getBbox;
54
+ /**
55
+ * Given polygons, calculate a bounding box that encompasses all points.
56
+ */
57
+ function getBBoxForPolygons(polygons) {
58
+ const allY = polygons.flatMap((polygon) => polygon.map((point) => point[1]));
59
+ const allX = polygons.flatMap((polygon) => polygon.map((point) => point[0]));
60
+ const yMin = Math.min(...allY);
61
+ const yMax = Math.max(...allY);
62
+ const xMin = Math.min(...allX);
63
+ const xMax = Math.max(...allX);
64
+ return [xMin, yMin, xMax, yMax];
65
+ }
66
+ exports.getBBoxForPolygons = getBBoxForPolygons;
30
67
  /**
31
68
  * Get the central point (centroid) given a list of points.
32
69
  */
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, PassportV1, ReceiptV3, ReceiptV4, CropperV1, ShippingContainerV1, fr, us, eu, } from "./documents";
1
+ export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, InvoiceSplitterV1, PassportV1, ReceiptV3, ReceiptV4, CropperV1, ShippingContainerV1, MindeeVisionV1, fr, us, eu, } from "./documents";
2
2
  export { Client, ClientOptions, CustomConfigParams, PredictOptions, } from "./client";
3
- export { ResponseSig, Response } from "./api";
3
+ export { ResponseSig, Response, AsyncPredictResponse } from "./api";
4
4
  export { InputSource, PageOptionsOperation } from "./inputs";
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageOptionsOperation = exports.InputSource = exports.Response = exports.Client = exports.eu = exports.us = exports.fr = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0;
3
+ exports.PageOptionsOperation = exports.InputSource = exports.AsyncPredictResponse = exports.Response = exports.Client = exports.eu = exports.us = exports.fr = exports.MindeeVisionV1 = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0;
4
4
  var documents_1 = require("./documents");
5
5
  Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return documents_1.CustomV1; } });
6
6
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return documents_1.Document; } });
@@ -8,11 +8,13 @@ Object.defineProperty(exports, "FinancialDocumentV0", { enumerable: true, get: f
8
8
  Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return documents_1.FinancialDocumentV1; } });
9
9
  Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return documents_1.InvoiceV3; } });
10
10
  Object.defineProperty(exports, "InvoiceV4", { enumerable: true, get: function () { return documents_1.InvoiceV4; } });
11
+ Object.defineProperty(exports, "InvoiceSplitterV1", { enumerable: true, get: function () { return documents_1.InvoiceSplitterV1; } });
11
12
  Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return documents_1.PassportV1; } });
12
13
  Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return documents_1.ReceiptV3; } });
13
14
  Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return documents_1.ReceiptV4; } });
14
15
  Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return documents_1.CropperV1; } });
15
16
  Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return documents_1.ShippingContainerV1; } });
17
+ Object.defineProperty(exports, "MindeeVisionV1", { enumerable: true, get: function () { return documents_1.MindeeVisionV1; } });
16
18
  Object.defineProperty(exports, "fr", { enumerable: true, get: function () { return documents_1.fr; } });
17
19
  Object.defineProperty(exports, "us", { enumerable: true, get: function () { return documents_1.us; } });
18
20
  Object.defineProperty(exports, "eu", { enumerable: true, get: function () { return documents_1.eu; } });
@@ -20,6 +22,7 @@ var client_1 = require("./client");
20
22
  Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
21
23
  var api_1 = require("./api");
22
24
  Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return api_1.Response; } });
25
+ Object.defineProperty(exports, "AsyncPredictResponse", { enumerable: true, get: function () { return api_1.AsyncPredictResponse; } });
23
26
  var inputs_1 = require("./inputs");
24
27
  Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return inputs_1.InputSource; } });
25
28
  Object.defineProperty(exports, "PageOptionsOperation", { enumerable: true, get: function () { return inputs_1.PageOptionsOperation; } });
@@ -0,0 +1 @@
1
+ export { equals as precisionEquals } from "./precision";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.precisionEquals = void 0;
4
+ var precision_1 = require("./precision");
5
+ Object.defineProperty(exports, "precisionEquals", { enumerable: true, get: function () { return precision_1.equals; } });
@@ -0,0 +1 @@
1
+ export declare function equals(a: number, b: number, tolerance: number): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.equals = void 0;
4
+ function equals(a, b, tolerance) {
5
+ if (Math.abs(b - a) <= tolerance) {
6
+ return true;
7
+ }
8
+ if (Math.abs(a - b) <= tolerance) {
9
+ return true;
10
+ }
11
+ return false;
12
+ }
13
+ exports.equals = equals;
File without changes