mindee 4.29.0-rc6 → 4.29.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +12 -24
  2. package/package.json +1 -1
  3. package/src/geometry/boundingBox.d.ts +4 -1
  4. package/src/geometry/boundingBox.js +9 -1
  5. package/src/geometry/boundingBoxUtils.js +1 -6
  6. package/src/geometry/index.js +2 -1
  7. package/src/geometry/polygon.d.ts +22 -0
  8. package/src/geometry/polygon.js +36 -0
  9. package/src/geometry/polygonUtils.d.ts +8 -9
  10. package/src/index.d.ts +1 -1
  11. package/src/index.js +3 -1
  12. package/src/parsing/custom/listField.d.ts +2 -2
  13. package/src/parsing/custom/listField.js +1 -6
  14. package/src/parsing/standard/field.js +1 -1
  15. package/src/parsing/v2/field/fieldFactory.d.ts +1 -1
  16. package/src/parsing/v2/field/inferenceFields.d.ts +3 -0
  17. package/src/parsing/v2/field/inferenceFields.js +30 -0
  18. package/src/parsing/v2/field/listField.d.ts +8 -0
  19. package/src/parsing/v2/field/listField.js +31 -0
  20. package/src/parsing/v2/field/objectField.d.ts +2 -0
  21. package/src/parsing/v2/field/objectField.js +12 -0
  22. package/src/parsing/v2/field/simpleField.d.ts +12 -0
  23. package/src/parsing/v2/field/simpleField.js +27 -0
  24. package/src/parsing/v2/index.d.ts +0 -1
  25. package/src/parsing/v2/index.js +1 -3
  26. package/src/parsing/v2/inferenceResult.d.ts +4 -4
  27. package/src/parsing/v2/inferenceResult.js +5 -8
  28. package/src/parsing/v2/rawText.d.ts +3 -9
  29. package/src/parsing/v2/rawText.js +2 -5
  30. package/src/parsing/v2/rawTextPage.d.ts +11 -0
  31. package/src/parsing/v2/rawTextPage.js +12 -0
  32. package/src/product/billOfLading/billOfLadingV1Carrier.js +2 -1
  33. package/src/product/billOfLading/billOfLadingV1CarrierItem.js +2 -1
  34. package/src/product/billOfLading/billOfLadingV1Consignee.js +2 -1
  35. package/src/product/billOfLading/billOfLadingV1NotifyParty.js +2 -1
  36. package/src/product/billOfLading/billOfLadingV1Shipper.js +2 -1
  37. package/src/product/financialDocument/financialDocumentV1LineItem.js +2 -1
  38. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +2 -1
  39. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.js +2 -1
  40. package/src/product/fr/energyBill/energyBillV1EnergySupplier.js +2 -1
  41. package/src/product/fr/energyBill/energyBillV1EnergyUsage.js +2 -1
  42. package/src/product/fr/energyBill/energyBillV1MeterDetail.js +2 -1
  43. package/src/product/fr/energyBill/energyBillV1Subscription.js +2 -1
  44. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.js +2 -1
  45. package/src/product/fr/payslip/payslipV2BankAccountDetail.js +2 -1
  46. package/src/product/fr/payslip/payslipV2Employee.js +2 -1
  47. package/src/product/fr/payslip/payslipV2Employer.js +2 -1
  48. package/src/product/fr/payslip/payslipV2Employment.js +2 -1
  49. package/src/product/fr/payslip/payslipV2PayDetail.js +2 -1
  50. package/src/product/fr/payslip/payslipV2PayPeriod.js +2 -1
  51. package/src/product/fr/payslip/payslipV2Pto.js +2 -1
  52. package/src/product/fr/payslip/payslipV2SalaryDetail.js +2 -1
  53. package/src/product/fr/payslip/payslipV3BankAccountDetail.js +2 -1
  54. package/src/product/fr/payslip/payslipV3Employee.js +2 -1
  55. package/src/product/fr/payslip/payslipV3Employer.js +2 -1
  56. package/src/product/fr/payslip/payslipV3Employment.js +2 -1
  57. package/src/product/fr/payslip/payslipV3PaidTimeOff.js +2 -1
  58. package/src/product/fr/payslip/payslipV3PayDetail.js +2 -1
  59. package/src/product/fr/payslip/payslipV3PayPeriod.js +2 -1
  60. package/src/product/fr/payslip/payslipV3SalaryDetail.js +2 -1
  61. package/src/product/invoice/invoiceV4LineItem.js +2 -1
  62. package/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.js +2 -1
  63. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.js +2 -1
  64. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.js +2 -1
  65. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.js +2 -1
  66. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.js +2 -1
  67. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.js +2 -1
  68. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.js +2 -1
  69. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.js +2 -1
  70. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.js +2 -1
  71. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.js +2 -1
  72. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.js +2 -1
  73. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.js +2 -1
  74. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.js +2 -1
  75. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.js +2 -1
  76. package/src/product/receipt/receiptV5LineItem.js +2 -1
  77. package/src/product/resume/resumeV1Certificate.js +2 -1
  78. package/src/product/resume/resumeV1Education.js +2 -1
  79. package/src/product/resume/resumeV1Language.js +2 -1
  80. package/src/product/resume/resumeV1ProfessionalExperience.js +2 -1
  81. package/src/product/resume/resumeV1SocialNetworksUrl.js +2 -1
  82. package/src/product/us/healthcareCard/healthcareCardV1Copay.js +2 -1
  83. package/src/product/us/usMail/usMailV2RecipientAddress.js +2 -1
  84. package/src/product/us/usMail/usMailV2SenderAddress.js +2 -1
  85. package/src/product/us/usMail/usMailV3RecipientAddress.js +2 -1
  86. package/src/product/us/usMail/usMailV3SenderAddress.js +2 -1
  87. package/src/parsing/v2/inferenceResultOptions.d.ts +0 -9
  88. package/src/parsing/v2/inferenceResultOptions.js +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.29.0 - 2025-08-29
4
+ ### Changes
5
+ * :sparkles: add typed accessors for fields, list, object
6
+ * :sparkles: add typed value accessors
7
+ * :sparkles: add geometry methods to polygon class
8
+ ### Fixes
9
+ * :bug: Polygon and BoundingBox should be a real classes
10
+
11
+
3
12
  ## v4.29.0-rc6 - 2025-08-22
4
13
  ### Changes
5
14
  * :recycle: rework local and input sources
@@ -35,7 +44,6 @@
35
44
  * :recycle: tweak CI & testing
36
45
  * :recycle: deprecate `cutPdf()` in favor of `applyPageOperations()` in `LocalInputSource`
37
46
  * :recycle: refactor some internals to account for new changes
38
-
39
47
  ### Fixes
40
48
  * :bug: fix bug where polling parameters could ignore validation checks on V1
41
49
 
@@ -178,7 +186,6 @@
178
186
  * :sparkles: add support for FR Payslips V1
179
187
  * :sparkles: add support for Nutrition Facts Label V1
180
188
  * :recycle: refactor internals to accommodate for new changes
181
-
182
189
  ### Fixes
183
190
  * :bug: fix float numbers not containing more 3 decimals in some instances
184
191
  * :bug: fix boolean field display issues
@@ -224,7 +231,6 @@
224
231
  * :sparkles: add support for HMAC validation for webhooks
225
232
  * :sparkles: add support for US Mail V2
226
233
  * :sparkles: add support for boolean fields
227
-
228
234
  ### Fixes
229
235
  * :recycle: fixed Locale display
230
236
 
@@ -242,7 +248,6 @@
242
248
  # v4.10.0 - 2024-04-12
243
249
  ### Changes
244
250
  * :sparkles: update Invoice to v4.5 (#264)
245
-
246
251
  ### Fixes
247
252
  * :bug: fix error management not following intended flow (#267)
248
253
  * :recycle: deprecated old error handler (#266)
@@ -261,14 +266,12 @@
261
266
  * :sparkles: add support for resume V1
262
267
  * :sparkles: add support for International ID v2
263
268
  * :sparkles: add support for EU Driver License V1
264
-
265
269
  ### Fixes
266
270
  :memo: misc doc fixes
267
271
 
268
272
  ## v4.8.2 - 2024-02-09
269
273
  ### Changes
270
274
  * :recycle: increased update time for async retries
271
-
272
275
  ### Fixes
273
276
  * :bug: fixed improper float parsing for Generated list objects
274
277
  * :bug: typescript should now allow the use of default values for enqueueAndParse() async options
@@ -292,7 +295,6 @@
292
295
  * :recycle: add CLI entry for generated APIs
293
296
  * :memo: add documentation entry for generated APIs
294
297
  * :recycle: expose a bit more of our internals for easier use (#247)
295
-
296
298
  ### Fixes
297
299
  * :memo: fix invoice v4 md doc
298
300
 
@@ -339,7 +341,6 @@
339
341
  ## v4.3.2 - 2023-11-07
340
342
  ### Changes
341
343
  * :recycle: update invoice splitter
342
-
343
344
  ### Fixes
344
345
  * :bug: fix display issues when products didn't have pages
345
346
  * :memo: fix doc typos
@@ -369,7 +370,6 @@
369
370
  * :sparkles: add support for FR Id Card V2
370
371
  * :sparkles: add support for OTS Cropper V1
371
372
  * :memo: update documentation
372
-
373
373
  ### Fixes
374
374
  * :bug: fix missing position field display issues
375
375
  * :bug: fix issues with asynchronous timeouts crashing in some instances
@@ -378,7 +378,6 @@
378
378
  ## v4.1.1 - 2023-09-04
379
379
  ### Changes
380
380
  * :recycle: tweaked timer management in async
381
-
382
381
  ### Fixes
383
382
  * :bug: fix ocr option not being generated as an Ocr object
384
383
 
@@ -395,7 +394,6 @@
395
394
  * :recycle: remove deprecated examples
396
395
  * :recycle: update linting rules
397
396
  * :arrow_up: update testing library
398
-
399
397
  ### Fixes
400
398
  * :bug: fix miscellaneous bugs related to http parsing issues
401
399
 
@@ -403,7 +401,6 @@
403
401
  ## v4.0.2 - 2023-08-24
404
402
  ### Changes
405
403
  * :recycle: updated technical documentation
406
-
407
404
  ### Fixes
408
405
  * :bug: fix url source document not being sent properly
409
406
 
@@ -418,7 +415,6 @@
418
415
  * :art: :boom: harmonize response types with other libraries
419
416
  * :art: :boom: change endpoint management & syntax
420
417
  * :art: :boom: move products to `product` module
421
-
422
418
  ### Changes
423
419
  * :sparkles: add full support for page-specific attributes
424
420
  * :sparkles: add support for FR Id Card
@@ -439,7 +435,6 @@
439
435
  ## v3.10.1 - 2023-07-04
440
436
  ### Changes
441
437
  * :arrow_up: update dependencies
442
-
443
438
  ### Fixes
444
439
  * :pencil2: added missing entry in changelog
445
440
 
@@ -455,8 +450,6 @@
455
450
  ### Changes
456
451
  * :sparkles: support for financial document v1.1
457
452
  * :recycle: change http status code handling for async requests
458
-
459
-
460
453
  ### Fixes
461
454
  * :bug: fix typing in PaymentDetails
462
455
  * :bug: locale value should always be set
@@ -472,7 +465,6 @@
472
465
  ## v3.7.4 - 2023-04-20
473
466
  ### Changes
474
467
  * :white_check_mark: minor improvements to tests
475
-
476
468
  ### Fixes
477
469
  * :bug: fix for options not being passed properly in the CLI tool
478
470
 
@@ -502,7 +494,6 @@
502
494
  * :art: harmonize bbox and bounding box terminology
503
495
  * :arrow_up: update test files, minor updates to string output
504
496
  * :label: classification fields are always strings
505
-
506
497
  ### Fixes
507
498
  * :bug: fix error message for missing API key, document type may be undefined
508
499
 
@@ -532,7 +523,6 @@ Usage is otherwise identical.
532
523
  ### Changes
533
524
  * :memo: updates to class documentation
534
525
  * :sparkles: Add invoice splitter support (beta)
535
-
536
526
  ### Fixes
537
527
  * :bug: fix for CLI command option description
538
528
 
@@ -593,7 +583,6 @@ Usage is otherwise identical.
593
583
  * :sparkles: Document (endpoints) are now versioned, providing better backward-compatible support.
594
584
  * :recycle: Pass the document class instead of the response class to the `parse` method.
595
585
  * :recycle: Some methods and parameters renamed for better clarity.
596
-
597
586
  ### Changes
598
587
  * :sparkles: New URL input source, `docFromUrl`.
599
588
  * :sparkles: Add support for expense receipts V4
@@ -630,15 +619,14 @@ It's **not** backwards compatible with previous versions.
630
619
 
631
620
 
632
621
  ## v1.4.0
622
+ ### Changes
623
+ * :sparkles: Add TIFF and HEIC support
624
+ * :white_check_mark: fully test PDF cut function
633
625
  ### Fixes
634
626
  * :bug: cut/merge pages of an encrypted PDF leads to unexpected results
635
627
  * :bug: logger not activating in some cases
636
628
  * :bug: align PDF cut/merge with other client libs
637
629
 
638
- ### Changes
639
- * :sparkles: Add TIFF and HEIC support
640
- * :white_check_mark: fully test PDF cut function
641
-
642
630
 
643
631
  ## v1.3.3
644
632
  ### Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.29.0-rc6",
3
+ "version": "4.29.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -1,4 +1,5 @@
1
1
  import { Point } from "./point";
2
+ import { Polygon } from "./polygon";
2
3
  /** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
3
4
  export declare class BBox {
4
5
  xMin: number;
@@ -8,4 +9,6 @@ export declare class BBox {
8
9
  constructor(xMin: number, yMin: number, xMax: number, yMax: number);
9
10
  }
10
11
  /** A bounding box defined by 4 points. */
11
- export type BoundingBox = [Point, Point, Point, Point];
12
+ export declare class BoundingBox extends Polygon {
13
+ constructor(topLeft: Point, topRight: Point, bottomRight: Point, bottomLeft: Point);
14
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BBox = void 0;
3
+ exports.BoundingBox = exports.BBox = void 0;
4
+ const polygon_1 = require("./polygon");
4
5
  /** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
5
6
  class BBox {
6
7
  constructor(xMin, yMin, xMax, yMax) {
@@ -11,3 +12,10 @@ class BBox {
11
12
  }
12
13
  }
13
14
  exports.BBox = BBox;
15
+ /** A bounding box defined by 4 points. */
16
+ class BoundingBox extends polygon_1.Polygon {
17
+ constructor(topLeft, topRight, bottomRight, bottomLeft) {
18
+ super(topLeft, topRight, bottomRight, bottomLeft);
19
+ }
20
+ }
21
+ exports.BoundingBox = BoundingBox;
@@ -17,12 +17,7 @@ function getBoundingBox(polygon) {
17
17
  * Given a BBox, generate the associated bounding box.
18
18
  */
19
19
  function getBoundingBoxFromBBox(bbox) {
20
- return [
21
- [bbox.xMin, bbox.yMin],
22
- [bbox.xMax, bbox.yMin],
23
- [bbox.xMax, bbox.yMax],
24
- [bbox.xMin, bbox.yMax],
25
- ];
20
+ return new boundingBox_1.BoundingBox([bbox.xMin, bbox.yMin], [bbox.xMax, bbox.yMin], [bbox.xMax, bbox.yMax], [bbox.xMin, bbox.yMax]);
26
21
  }
27
22
  /**
28
23
  * Given 2 bbox, merge them.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = exports.getBBoxForPolygons = exports.getBbox = exports.BBox = exports.getMinMaxY = exports.getMinMaxX = exports.relativeY = exports.relativeX = exports.isPointInPolygonY = exports.isPointInPolygonX = exports.getCentroid = exports.compareOnY = exports.compareOnX = exports.Polygon = void 0;
3
+ exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = exports.getBBoxForPolygons = exports.getBbox = exports.BBox = exports.BoundingBox = exports.getMinMaxY = exports.getMinMaxX = exports.relativeY = exports.relativeX = exports.isPointInPolygonY = exports.isPointInPolygonX = exports.getCentroid = exports.compareOnY = exports.compareOnX = exports.Polygon = void 0;
4
4
  var polygon_1 = require("./polygon");
5
5
  Object.defineProperty(exports, "Polygon", { enumerable: true, get: function () { return polygon_1.Polygon; } });
6
6
  var polygonUtils_1 = require("./polygonUtils");
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "relativeY", { enumerable: true, get: function ()
14
14
  Object.defineProperty(exports, "getMinMaxX", { enumerable: true, get: function () { return polygonUtils_1.getMinMaxX; } });
15
15
  Object.defineProperty(exports, "getMinMaxY", { enumerable: true, get: function () { return polygonUtils_1.getMinMaxY; } });
16
16
  var boundingBox_1 = require("./boundingBox");
17
+ Object.defineProperty(exports, "BoundingBox", { enumerable: true, get: function () { return boundingBox_1.BoundingBox; } });
17
18
  Object.defineProperty(exports, "BBox", { enumerable: true, get: function () { return boundingBox_1.BBox; } });
18
19
  var boundingBoxUtils_1 = require("./boundingBoxUtils");
19
20
  Object.defineProperty(exports, "getBbox", { enumerable: true, get: function () { return boundingBoxUtils_1.getBbox; } });
@@ -1,4 +1,26 @@
1
1
  import { Point } from "./point";
2
+ import { MinMax } from "./minMax";
2
3
  /** A polygon, composed of several Points. */
3
4
  export declare class Polygon extends Array<Point> {
5
+ constructor(...args: Point[]);
6
+ /**
7
+ * Get the central point (centroid) of the polygon.
8
+ */
9
+ getCentroid(): Point;
10
+ /**
11
+ * Get the maximum and minimum X coordinates of the polygon.
12
+ */
13
+ getMinMaxX(): MinMax;
14
+ /**
15
+ * Get the maximum and minimum Y coordinates of the polygon.
16
+ */
17
+ getMinMaxY(): MinMax;
18
+ /**
19
+ * Determine if a Point is within the Polygon's X axis (same column).
20
+ */
21
+ isPointInX(point: Point): boolean;
22
+ /**
23
+ * Determine if a Point is within the Polygon's Y axis (same line).
24
+ */
25
+ isPointInY(point: Point): boolean;
4
26
  }
@@ -1,7 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Polygon = void 0;
4
+ const polygonUtils_1 = require("./polygonUtils");
4
5
  /** A polygon, composed of several Points. */
5
6
  class Polygon extends Array {
7
+ constructor(...args) {
8
+ super(...args);
9
+ }
10
+ /**
11
+ * Get the central point (centroid) of the polygon.
12
+ */
13
+ getCentroid() {
14
+ return (0, polygonUtils_1.getCentroid)(this);
15
+ }
16
+ /**
17
+ * Get the maximum and minimum X coordinates of the polygon.
18
+ */
19
+ getMinMaxX() {
20
+ return (0, polygonUtils_1.getMinMaxX)(this);
21
+ }
22
+ /**
23
+ * Get the maximum and minimum Y coordinates of the polygon.
24
+ */
25
+ getMinMaxY() {
26
+ return (0, polygonUtils_1.getMinMaxY)(this);
27
+ }
28
+ /**
29
+ * Determine if a Point is within the Polygon's X axis (same column).
30
+ */
31
+ isPointInX(point) {
32
+ const xCoords = this.getMinMaxX();
33
+ return (0, polygonUtils_1.isPointInX)(point, xCoords.min, xCoords.max);
34
+ }
35
+ /**
36
+ * Determine if a Point is within the Polygon's Y axis (same line).
37
+ */
38
+ isPointInY(point) {
39
+ const yCoords = this.getMinMaxY();
40
+ return (0, polygonUtils_1.isPointInY)(point, yCoords.min, yCoords.max);
41
+ }
6
42
  }
7
43
  exports.Polygon = Polygon;
@@ -1,6 +1,5 @@
1
1
  import { MinMax } from "./minMax";
2
2
  import { Point } from "./point";
3
- import { Polygon } from "./polygon";
4
3
  /**
5
4
  * Get the central point (centroid) given a list of points.
6
5
  */
@@ -16,13 +15,13 @@ export declare function getMinMaxY(vertices: Array<Point>): MinMax;
16
15
  /**
17
16
  * Determine if a Point is within a Polygon's Y axis.
18
17
  */
19
- export declare function isPointInPolygonY(centroid: Point, polygon: Polygon): boolean;
18
+ export declare function isPointInPolygonY(centroid: Point, polygon: Array<Point>): boolean;
20
19
  /**
21
20
  * Calculate the relative Y position of a Polygon.
22
21
  *
23
22
  * Can be used to order (sort) words in the same column.
24
23
  */
25
- export declare function relativeY(polygon: Polygon): number;
24
+ export declare function relativeY(polygon: Array<Point>): number;
26
25
  /**
27
26
  * Determine if a Point is within two X coordinates.
28
27
  */
@@ -34,14 +33,14 @@ export declare function getMinMaxX(vertices: Array<Point>): MinMax;
34
33
  /**
35
34
  * Determine if a Point is within a Polygon's X axis.
36
35
  */
37
- export declare function isPointInPolygonX(centroid: Point, polygon: Polygon): boolean;
36
+ export declare function isPointInPolygonX(centroid: Point, polygon: Array<Point>): boolean;
38
37
  /**
39
38
  * Calculate the relative X position of a Polygon.
40
39
  *
41
40
  * Can be used to order (sort) words in the same line.
42
41
  */
43
- export declare function relativeX(polygon: Polygon): number;
44
- export declare function getMinYCoordinate(polygon: Polygon): number;
45
- export declare function getMinXCoordinate(polygon: Polygon): number;
46
- export declare function compareOnY(polygon1: Polygon, polygon2: Polygon): number;
47
- export declare function compareOnX(polygon1: Polygon, polygon2: Polygon): number;
42
+ export declare function relativeX(polygon: Array<Point>): number;
43
+ export declare function getMinYCoordinate(polygon: Array<Point>): number;
44
+ export declare function getMinXCoordinate(polygon: Array<Point>): number;
45
+ export declare function compareOnY(polygon1: Array<Point>, polygon2: Array<Point>): number;
46
+ export declare function compareOnX(polygon1: Array<Point>, polygon2: Array<Point>): number;
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 { InferenceResponse, JobResponse, } from "./parsing/v2";
5
+ export { InferenceFile, InferenceResponse, JobResponse, RawText, } 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.JobResponse = exports.InferenceResponse = 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.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; } });
@@ -47,8 +47,10 @@ Object.defineProperty(exports, "Prediction", { enumerable: true, get: function (
47
47
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return common_1.Document; } });
48
48
  Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return common_1.Page; } });
49
49
  var v2_1 = require("./parsing/v2");
50
+ Object.defineProperty(exports, "InferenceFile", { enumerable: true, get: function () { return v2_1.InferenceFile; } });
50
51
  Object.defineProperty(exports, "InferenceResponse", { enumerable: true, get: function () { return v2_1.InferenceResponse; } });
51
52
  Object.defineProperty(exports, "JobResponse", { enumerable: true, get: function () { return v2_1.JobResponse; } });
53
+ Object.defineProperty(exports, "RawText", { enumerable: true, get: function () { return v2_1.RawText; } });
52
54
  var input_1 = require("./input");
53
55
  Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return input_1.InputSource; } });
54
56
  Object.defineProperty(exports, "Base64Input", { enumerable: true, get: function () { return input_1.Base64Input; } });
@@ -1,5 +1,5 @@
1
1
  import { BaseFieldConstructor } from "../standard";
2
- import { Polygon } from "../../geometry";
2
+ import { Polygon, BoundingBox } from "../../geometry";
3
3
  import { StringDict } from "../common";
4
4
  export declare class ListFieldValue {
5
5
  /** Extracted content of the prediction */
@@ -13,7 +13,7 @@ export declare class ListFieldValue {
13
13
  * Contains exactly 4 relative vertices coordinates (points) of a right
14
14
  * rectangle containing the word in the document.
15
15
  */
16
- bbox: Polygon;
16
+ bbox?: BoundingBox;
17
17
  /**
18
18
  * Contains the relative vertices coordinates (points) of a polygon containing
19
19
  * the word in the document.
@@ -4,16 +4,11 @@ exports.ListField = exports.ListFieldValue = void 0;
4
4
  const geometry_1 = require("../../geometry");
5
5
  class ListFieldValue {
6
6
  constructor(prediction, pageId) {
7
- /**
8
- * Contains exactly 4 relative vertices coordinates (points) of a right
9
- * rectangle containing the word in the document.
10
- */
11
- this.bbox = [];
12
7
  /**
13
8
  * Contains the relative vertices coordinates (points) of a polygon containing
14
9
  * the word in the document.
15
10
  */
16
- this.polygon = [];
11
+ this.polygon = new geometry_1.Polygon();
17
12
  this.content = prediction["content"];
18
13
  this.confidence = prediction["confidence"];
19
14
  if (prediction["polygon"]) {
@@ -16,7 +16,7 @@ class Field extends base_1.BaseField {
16
16
  * Contains the relative vertices coordinates (points) of a polygon containing
17
17
  * the field in the document.
18
18
  */
19
- this.polygon = [];
19
+ this.polygon = new geometry_1.Polygon();
20
20
  this.confidence = prediction["confidence"] ? prediction["confidence"] : 0.0;
21
21
  if (prediction["polygon"]) {
22
22
  this.polygon = prediction["polygon"];
@@ -5,4 +5,4 @@ import { StringDict } from "../../common";
5
5
  import { ListField } from "./listField";
6
6
  import { ObjectField } from "./objectField";
7
7
  import { SimpleField } from "./simpleField";
8
- export declare function createField(serverResponse: StringDict, indentLevel?: number): ObjectField | SimpleField | ListField;
8
+ export declare function createField(serverResponse: StringDict, indentLevel?: number): SimpleField | ObjectField | ListField;
@@ -5,5 +5,8 @@ import type { SimpleField } from "./simpleField";
5
5
  export declare class InferenceFields extends Map<string, SimpleField | ObjectField | ListField> {
6
6
  protected _indentLevel: number;
7
7
  constructor(serverResponse: StringDict, indentLevel?: number);
8
+ getSimpleField(fieldName: string): SimpleField;
9
+ getObjectField(fieldName: string): ObjectField;
10
+ getListField(fieldName: string): ListField;
8
11
  toString(indent?: number): string;
9
12
  }
@@ -9,6 +9,36 @@ class InferenceFields extends Map {
9
9
  }));
10
10
  this._indentLevel = indentLevel;
11
11
  }
12
+ getSimpleField(fieldName) {
13
+ const field = this.get(fieldName);
14
+ if (field === undefined) {
15
+ throw new Error(`The field '${fieldName}' was not found.`);
16
+ }
17
+ if (field.constructor.name !== "SimpleField") {
18
+ throw new Error(`The field '${fieldName}' is not a SimpleField.`);
19
+ }
20
+ return field;
21
+ }
22
+ getObjectField(fieldName) {
23
+ const field = this.get(fieldName);
24
+ if (field === undefined) {
25
+ throw new Error(`The field '${fieldName}' was not found.`);
26
+ }
27
+ if (field.constructor.name !== "ObjectField") {
28
+ throw new Error(`The field '${fieldName}' is not an ObjectField.`);
29
+ }
30
+ return field;
31
+ }
32
+ getListField(fieldName) {
33
+ const field = this.get(fieldName);
34
+ if (field === undefined) {
35
+ throw new Error(`The field '${fieldName}' was not found.`);
36
+ }
37
+ if (field.constructor.name !== "ListField") {
38
+ throw new Error(`The field '${fieldName}' is not a ListField.`);
39
+ }
40
+ return field;
41
+ }
12
42
  toString(indent = this._indentLevel) {
13
43
  if (this.size === 0) {
14
44
  return "";
@@ -7,6 +7,14 @@ export declare class ListField extends BaseField {
7
7
  * Items contained in the list.
8
8
  */
9
9
  items: Array<ListField | ObjectField | SimpleField>;
10
+ /**
11
+ * SimpleField items from the list.
12
+ */
13
+ get simpleItems(): Array<SimpleField>;
14
+ /**
15
+ * SimpleField items from the list.
16
+ */
17
+ get objectItems(): Array<ObjectField>;
10
18
  constructor(serverResponse: StringDict, indentLevel?: number);
11
19
  toString(): string;
12
20
  }
@@ -4,8 +4,39 @@ exports.ListField = void 0;
4
4
  const mindeeError_1 = require("../../../errors/mindeeError");
5
5
  const baseField_1 = require("./baseField");
6
6
  const objectField_1 = require("./objectField");
7
+ const simpleField_1 = require("./simpleField");
7
8
  const fieldFactory_1 = require("./fieldFactory");
8
9
  class ListField extends baseField_1.BaseField {
10
+ /**
11
+ * SimpleField items from the list.
12
+ */
13
+ get simpleItems() {
14
+ const result = [];
15
+ for (const item of this.items) {
16
+ if (item instanceof simpleField_1.SimpleField) {
17
+ result.push(item);
18
+ }
19
+ else {
20
+ throw new mindeeError_1.MindeeApiV2Error(`All items must be SimpleField, found item of type ${item.constructor.name}.`);
21
+ }
22
+ }
23
+ return result;
24
+ }
25
+ /**
26
+ * SimpleField items from the list.
27
+ */
28
+ get objectItems() {
29
+ const result = [];
30
+ for (const item of this.items) {
31
+ if (item instanceof objectField_1.ObjectField) {
32
+ result.push(item);
33
+ }
34
+ else {
35
+ throw new mindeeError_1.MindeeApiV2Error(`All items must be ObjectField, found item of type ${item.constructor.name}.`);
36
+ }
37
+ }
38
+ return result;
39
+ }
9
40
  constructor(serverResponse, indentLevel = 0) {
10
41
  super(serverResponse, indentLevel);
11
42
  if (!Array.isArray(serverResponse["items"])) {
@@ -1,8 +1,10 @@
1
1
  import { InferenceFields } from "./inferenceFields";
2
2
  import { StringDict } from "../../common";
3
3
  import { BaseField } from "./baseField";
4
+ import type { SimpleField } from "./simpleField";
4
5
  export declare class ObjectField extends BaseField {
5
6
  readonly fields: InferenceFields;
7
+ get simpleFields(): Map<string, SimpleField>;
6
8
  constructor(serverResponse: StringDict, indentLevel?: number);
7
9
  toString(): string;
8
10
  toStringFromList(): string;
@@ -4,6 +4,18 @@ exports.ObjectField = void 0;
4
4
  const inferenceFields_1 = require("./inferenceFields");
5
5
  const baseField_1 = require("./baseField");
6
6
  class ObjectField extends baseField_1.BaseField {
7
+ get simpleFields() {
8
+ const result = new Map();
9
+ for (const [fieldName, fieldValue] of this.fields) {
10
+ if (fieldValue.constructor.name === "SimpleField") {
11
+ result.set(fieldName, fieldValue);
12
+ }
13
+ else {
14
+ throw new Error(`The field '${fieldName}' is not a SimpleField.`);
15
+ }
16
+ }
17
+ return result;
18
+ }
7
19
  constructor(serverResponse, indentLevel = 0) {
8
20
  super(serverResponse, indentLevel);
9
21
  this.fields = new inferenceFields_1.InferenceFields(serverResponse["fields"], this._indentLevel + 1);
@@ -3,5 +3,17 @@ import { BaseField } from "./baseField";
3
3
  export declare class SimpleField extends BaseField {
4
4
  readonly value: string | number | boolean | null;
5
5
  constructor(serverResponse: StringDict, indentLevel?: number);
6
+ /**
7
+ * Retrieves a string field value as a string.
8
+ */
9
+ get stringValue(): string | null;
10
+ /**
11
+ * Retrieves a number field value as a number.
12
+ */
13
+ get numberValue(): number | null;
14
+ /**
15
+ * Retrieves a boolean field value as a boolean.
16
+ */
17
+ get booleanValue(): boolean | null;
6
18
  toString(): string;
7
19
  }
@@ -8,6 +8,33 @@ class SimpleField extends baseField_1.BaseField {
8
8
  this.value =
9
9
  serverResponse["value"] !== undefined ? serverResponse["value"] : null;
10
10
  }
11
+ /**
12
+ * Retrieves a string field value as a string.
13
+ */
14
+ get stringValue() {
15
+ if (this.value !== null && typeof this.value !== "string") {
16
+ throw new Error("Value is not a string");
17
+ }
18
+ return this.value;
19
+ }
20
+ /**
21
+ * Retrieves a number field value as a number.
22
+ */
23
+ get numberValue() {
24
+ if (this.value !== null && typeof this.value !== "number") {
25
+ throw new Error("Value is not a number");
26
+ }
27
+ return this.value;
28
+ }
29
+ /**
30
+ * Retrieves a boolean field value as a boolean.
31
+ */
32
+ get booleanValue() {
33
+ if (this.value !== null && typeof this.value !== "boolean") {
34
+ throw new Error("Value is not a boolean");
35
+ }
36
+ return this.value;
37
+ }
11
38
  toString() {
12
39
  if (this.value === null) {
13
40
  return "";
@@ -3,7 +3,6 @@ export { ErrorResponse } from "./errorResponse";
3
3
  export { Inference } from "./inference";
4
4
  export { InferenceFile } from "./inferenceFile";
5
5
  export { InferenceModel } from "./inferenceModel";
6
- export { InferenceResultOptions } from "./inferenceResultOptions";
7
6
  export { InferenceResponse } from "./inferenceResponse";
8
7
  export { InferenceResult } from "./inferenceResult";
9
8
  export { Job } from "./job";