mindee 4.29.0-rc6 → 4.30.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 (96) hide show
  1. package/CHANGELOG.md +19 -24
  2. package/package.json +1 -1
  3. package/src/clientV2.d.ts +8 -1
  4. package/src/geometry/boundingBox.d.ts +4 -1
  5. package/src/geometry/boundingBox.js +9 -1
  6. package/src/geometry/boundingBoxUtils.js +1 -6
  7. package/src/geometry/index.js +2 -1
  8. package/src/geometry/polygon.d.ts +22 -0
  9. package/src/geometry/polygon.js +36 -0
  10. package/src/geometry/polygonUtils.d.ts +8 -9
  11. package/src/http/mindeeApiV2.js +11 -2
  12. package/src/index.d.ts +1 -1
  13. package/src/index.js +3 -1
  14. package/src/parsing/custom/listField.d.ts +2 -2
  15. package/src/parsing/custom/listField.js +1 -6
  16. package/src/parsing/standard/field.js +1 -1
  17. package/src/parsing/v2/field/fieldFactory.d.ts +1 -1
  18. package/src/parsing/v2/field/inferenceFields.d.ts +3 -0
  19. package/src/parsing/v2/field/inferenceFields.js +30 -0
  20. package/src/parsing/v2/field/listField.d.ts +8 -0
  21. package/src/parsing/v2/field/listField.js +31 -0
  22. package/src/parsing/v2/field/objectField.d.ts +2 -0
  23. package/src/parsing/v2/field/objectField.js +12 -0
  24. package/src/parsing/v2/field/simpleField.d.ts +12 -0
  25. package/src/parsing/v2/field/simpleField.js +27 -0
  26. package/src/parsing/v2/index.d.ts +1 -1
  27. package/src/parsing/v2/index.js +3 -3
  28. package/src/parsing/v2/inference.d.ts +5 -0
  29. package/src/parsing/v2/inference.js +4 -6
  30. package/src/parsing/v2/inferenceActiveOptions.d.ts +21 -0
  31. package/src/parsing/v2/inferenceActiveOptions.js +20 -0
  32. package/src/parsing/v2/inferenceModel.d.ts +1 -0
  33. package/src/parsing/v2/inferenceModel.js +5 -0
  34. package/src/parsing/v2/inferenceResult.d.ts +4 -4
  35. package/src/parsing/v2/inferenceResult.js +6 -14
  36. package/src/parsing/v2/rawText.d.ts +4 -9
  37. package/src/parsing/v2/rawText.js +5 -5
  38. package/src/parsing/v2/rawTextPage.d.ts +11 -0
  39. package/src/parsing/v2/rawTextPage.js +12 -0
  40. package/src/product/billOfLading/billOfLadingV1Carrier.js +2 -1
  41. package/src/product/billOfLading/billOfLadingV1CarrierItem.js +2 -1
  42. package/src/product/billOfLading/billOfLadingV1Consignee.js +2 -1
  43. package/src/product/billOfLading/billOfLadingV1NotifyParty.js +2 -1
  44. package/src/product/billOfLading/billOfLadingV1Shipper.js +2 -1
  45. package/src/product/financialDocument/financialDocumentV1LineItem.js +2 -1
  46. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +2 -1
  47. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.js +2 -1
  48. package/src/product/fr/energyBill/energyBillV1EnergySupplier.js +2 -1
  49. package/src/product/fr/energyBill/energyBillV1EnergyUsage.js +2 -1
  50. package/src/product/fr/energyBill/energyBillV1MeterDetail.js +2 -1
  51. package/src/product/fr/energyBill/energyBillV1Subscription.js +2 -1
  52. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.js +2 -1
  53. package/src/product/fr/payslip/payslipV2BankAccountDetail.js +2 -1
  54. package/src/product/fr/payslip/payslipV2Employee.js +2 -1
  55. package/src/product/fr/payslip/payslipV2Employer.js +2 -1
  56. package/src/product/fr/payslip/payslipV2Employment.js +2 -1
  57. package/src/product/fr/payslip/payslipV2PayDetail.js +2 -1
  58. package/src/product/fr/payslip/payslipV2PayPeriod.js +2 -1
  59. package/src/product/fr/payslip/payslipV2Pto.js +2 -1
  60. package/src/product/fr/payslip/payslipV2SalaryDetail.js +2 -1
  61. package/src/product/fr/payslip/payslipV3BankAccountDetail.js +2 -1
  62. package/src/product/fr/payslip/payslipV3Employee.js +2 -1
  63. package/src/product/fr/payslip/payslipV3Employer.js +2 -1
  64. package/src/product/fr/payslip/payslipV3Employment.js +2 -1
  65. package/src/product/fr/payslip/payslipV3PaidTimeOff.js +2 -1
  66. package/src/product/fr/payslip/payslipV3PayDetail.js +2 -1
  67. package/src/product/fr/payslip/payslipV3PayPeriod.js +2 -1
  68. package/src/product/fr/payslip/payslipV3SalaryDetail.js +2 -1
  69. package/src/product/invoice/invoiceV4LineItem.js +2 -1
  70. package/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.js +2 -1
  71. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.js +2 -1
  72. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.js +2 -1
  73. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.js +2 -1
  74. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.js +2 -1
  75. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.js +2 -1
  76. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.js +2 -1
  77. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.js +2 -1
  78. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.js +2 -1
  79. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.js +2 -1
  80. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.js +2 -1
  81. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.js +2 -1
  82. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.js +2 -1
  83. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.js +2 -1
  84. package/src/product/receipt/receiptV5LineItem.js +2 -1
  85. package/src/product/resume/resumeV1Certificate.js +2 -1
  86. package/src/product/resume/resumeV1Education.js +2 -1
  87. package/src/product/resume/resumeV1Language.js +2 -1
  88. package/src/product/resume/resumeV1ProfessionalExperience.js +2 -1
  89. package/src/product/resume/resumeV1SocialNetworksUrl.js +2 -1
  90. package/src/product/us/healthcareCard/healthcareCardV1Copay.js +2 -1
  91. package/src/product/us/usMail/usMailV2RecipientAddress.js +2 -1
  92. package/src/product/us/usMail/usMailV2SenderAddress.js +2 -1
  93. package/src/product/us/usMail/usMailV3RecipientAddress.js +2 -1
  94. package/src/product/us/usMail/usMailV3SenderAddress.js +2 -1
  95. package/src/parsing/v2/inferenceResultOptions.d.ts +0 -9
  96. package/src/parsing/v2/inferenceResultOptions.js +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.30.0 - 2025-09-04
4
+ ### Changes
5
+ * :sparkles: add support for inference options
6
+ * :recycle: refactor rst display to match other SDKs
7
+ ### ¡Breaking Changes!
8
+ * :recycle: :boom: update raw text output from server
9
+
10
+ ## v4.29.0 - 2025-08-29
11
+ ### Changes
12
+ * :sparkles: add typed accessors for fields, list, object
13
+ * :sparkles: add typed value accessors
14
+ * :sparkles: add geometry methods to polygon class
15
+ ### Fixes
16
+ * :bug: Polygon and BoundingBox should be a real classes
17
+
18
+
3
19
  ## v4.29.0-rc6 - 2025-08-22
4
20
  ### Changes
5
21
  * :recycle: rework local and input sources
@@ -35,7 +51,6 @@
35
51
  * :recycle: tweak CI & testing
36
52
  * :recycle: deprecate `cutPdf()` in favor of `applyPageOperations()` in `LocalInputSource`
37
53
  * :recycle: refactor some internals to account for new changes
38
-
39
54
  ### Fixes
40
55
  * :bug: fix bug where polling parameters could ignore validation checks on V1
41
56
 
@@ -178,7 +193,6 @@
178
193
  * :sparkles: add support for FR Payslips V1
179
194
  * :sparkles: add support for Nutrition Facts Label V1
180
195
  * :recycle: refactor internals to accommodate for new changes
181
-
182
196
  ### Fixes
183
197
  * :bug: fix float numbers not containing more 3 decimals in some instances
184
198
  * :bug: fix boolean field display issues
@@ -224,7 +238,6 @@
224
238
  * :sparkles: add support for HMAC validation for webhooks
225
239
  * :sparkles: add support for US Mail V2
226
240
  * :sparkles: add support for boolean fields
227
-
228
241
  ### Fixes
229
242
  * :recycle: fixed Locale display
230
243
 
@@ -242,7 +255,6 @@
242
255
  # v4.10.0 - 2024-04-12
243
256
  ### Changes
244
257
  * :sparkles: update Invoice to v4.5 (#264)
245
-
246
258
  ### Fixes
247
259
  * :bug: fix error management not following intended flow (#267)
248
260
  * :recycle: deprecated old error handler (#266)
@@ -261,14 +273,12 @@
261
273
  * :sparkles: add support for resume V1
262
274
  * :sparkles: add support for International ID v2
263
275
  * :sparkles: add support for EU Driver License V1
264
-
265
276
  ### Fixes
266
277
  :memo: misc doc fixes
267
278
 
268
279
  ## v4.8.2 - 2024-02-09
269
280
  ### Changes
270
281
  * :recycle: increased update time for async retries
271
-
272
282
  ### Fixes
273
283
  * :bug: fixed improper float parsing for Generated list objects
274
284
  * :bug: typescript should now allow the use of default values for enqueueAndParse() async options
@@ -292,7 +302,6 @@
292
302
  * :recycle: add CLI entry for generated APIs
293
303
  * :memo: add documentation entry for generated APIs
294
304
  * :recycle: expose a bit more of our internals for easier use (#247)
295
-
296
305
  ### Fixes
297
306
  * :memo: fix invoice v4 md doc
298
307
 
@@ -339,7 +348,6 @@
339
348
  ## v4.3.2 - 2023-11-07
340
349
  ### Changes
341
350
  * :recycle: update invoice splitter
342
-
343
351
  ### Fixes
344
352
  * :bug: fix display issues when products didn't have pages
345
353
  * :memo: fix doc typos
@@ -369,7 +377,6 @@
369
377
  * :sparkles: add support for FR Id Card V2
370
378
  * :sparkles: add support for OTS Cropper V1
371
379
  * :memo: update documentation
372
-
373
380
  ### Fixes
374
381
  * :bug: fix missing position field display issues
375
382
  * :bug: fix issues with asynchronous timeouts crashing in some instances
@@ -378,7 +385,6 @@
378
385
  ## v4.1.1 - 2023-09-04
379
386
  ### Changes
380
387
  * :recycle: tweaked timer management in async
381
-
382
388
  ### Fixes
383
389
  * :bug: fix ocr option not being generated as an Ocr object
384
390
 
@@ -395,7 +401,6 @@
395
401
  * :recycle: remove deprecated examples
396
402
  * :recycle: update linting rules
397
403
  * :arrow_up: update testing library
398
-
399
404
  ### Fixes
400
405
  * :bug: fix miscellaneous bugs related to http parsing issues
401
406
 
@@ -403,7 +408,6 @@
403
408
  ## v4.0.2 - 2023-08-24
404
409
  ### Changes
405
410
  * :recycle: updated technical documentation
406
-
407
411
  ### Fixes
408
412
  * :bug: fix url source document not being sent properly
409
413
 
@@ -418,7 +422,6 @@
418
422
  * :art: :boom: harmonize response types with other libraries
419
423
  * :art: :boom: change endpoint management & syntax
420
424
  * :art: :boom: move products to `product` module
421
-
422
425
  ### Changes
423
426
  * :sparkles: add full support for page-specific attributes
424
427
  * :sparkles: add support for FR Id Card
@@ -439,7 +442,6 @@
439
442
  ## v3.10.1 - 2023-07-04
440
443
  ### Changes
441
444
  * :arrow_up: update dependencies
442
-
443
445
  ### Fixes
444
446
  * :pencil2: added missing entry in changelog
445
447
 
@@ -455,8 +457,6 @@
455
457
  ### Changes
456
458
  * :sparkles: support for financial document v1.1
457
459
  * :recycle: change http status code handling for async requests
458
-
459
-
460
460
  ### Fixes
461
461
  * :bug: fix typing in PaymentDetails
462
462
  * :bug: locale value should always be set
@@ -472,7 +472,6 @@
472
472
  ## v3.7.4 - 2023-04-20
473
473
  ### Changes
474
474
  * :white_check_mark: minor improvements to tests
475
-
476
475
  ### Fixes
477
476
  * :bug: fix for options not being passed properly in the CLI tool
478
477
 
@@ -502,7 +501,6 @@
502
501
  * :art: harmonize bbox and bounding box terminology
503
502
  * :arrow_up: update test files, minor updates to string output
504
503
  * :label: classification fields are always strings
505
-
506
504
  ### Fixes
507
505
  * :bug: fix error message for missing API key, document type may be undefined
508
506
 
@@ -532,7 +530,6 @@ Usage is otherwise identical.
532
530
  ### Changes
533
531
  * :memo: updates to class documentation
534
532
  * :sparkles: Add invoice splitter support (beta)
535
-
536
533
  ### Fixes
537
534
  * :bug: fix for CLI command option description
538
535
 
@@ -593,7 +590,6 @@ Usage is otherwise identical.
593
590
  * :sparkles: Document (endpoints) are now versioned, providing better backward-compatible support.
594
591
  * :recycle: Pass the document class instead of the response class to the `parse` method.
595
592
  * :recycle: Some methods and parameters renamed for better clarity.
596
-
597
593
  ### Changes
598
594
  * :sparkles: New URL input source, `docFromUrl`.
599
595
  * :sparkles: Add support for expense receipts V4
@@ -630,15 +626,14 @@ It's **not** backwards compatible with previous versions.
630
626
 
631
627
 
632
628
  ## v1.4.0
629
+ ### Changes
630
+ * :sparkles: Add TIFF and HEIC support
631
+ * :white_check_mark: fully test PDF cut function
633
632
  ### Fixes
634
633
  * :bug: cut/merge pages of an encrypted PDF leads to unexpected results
635
634
  * :bug: logger not activating in some cases
636
635
  * :bug: align PDF cut/merge with other client libs
637
636
 
638
- ### Changes
639
- * :sparkles: Add TIFF and HEIC support
640
- * :white_check_mark: fully test PDF cut function
641
-
642
637
 
643
638
  ## v1.3.3
644
639
  ### Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.29.0-rc6",
3
+ "version": "4.30.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.d.ts CHANGED
@@ -52,7 +52,11 @@ export interface PollingOptions {
52
52
  * All fields are optional except `modelId`.
53
53
  *
54
54
  * @property modelId Identifier of the model that must process the document. **Required**.
55
- * @property rag When `true`, activates Retrieval-Augmented Generation (RAG).
55
+ * @property rag Enhance extraction accuracy with Retrieval-Augmented Generation.
56
+ * @property rawText Extract the full text content from the document as strings, and fill the `raw_text` attribute.
57
+ * @property polygon Calculate bounding box polygons for all fields, and fill their `locations` attribute.
58
+ * @property confidence Boost the precision and accuracy of all extractions.
59
+ * Calculate confidence scores for all fields and fill their `confidence` attribute.
56
60
  * @property alias Custom alias assigned to the uploaded document.
57
61
  * @property webhookIds List of webhook UUIDs that will receive the final API response.
58
62
  * @property pollingOptions Client-side polling configuration (see {@link PollingOptions}).
@@ -73,6 +77,9 @@ export interface PollingOptions {
73
77
  export interface InferenceParameters {
74
78
  modelId: string;
75
79
  rag?: boolean;
80
+ rawText?: boolean;
81
+ polygon?: boolean;
82
+ confidence?: boolean;
76
83
  alias?: string;
77
84
  webhookIds?: string[];
78
85
  pollingOptions?: PollingOptions;
@@ -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;
@@ -82,8 +82,17 @@ _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function
82
82
  }, _MindeeApiV2_documentEnqueuePost = function _MindeeApiV2_documentEnqueuePost(inputSource, params) {
83
83
  const form = new form_data_1.default();
84
84
  form.append("model_id", params.modelId);
85
- if (params.rag) {
86
- form.append("rag", "true");
85
+ if (params.rag !== undefined && params.rag !== null) {
86
+ form.append("rag", params.rag.toString());
87
+ }
88
+ if (params.polygon !== undefined && params.polygon !== null) {
89
+ form.append("polygon", params.polygon.toString().toLowerCase());
90
+ }
91
+ if (params.confidence !== undefined && params.confidence !== null) {
92
+ form.append("confidence", params.confidence.toString().toLowerCase());
93
+ }
94
+ if (params.rawText !== undefined && params.rawText !== null) {
95
+ form.append("raw_text", params.rawText.toString().toLowerCase());
87
96
  }
88
97
  if (params.webhookIds && params.webhookIds.length > 0) {
89
98
  form.append("webhook_ids", params.webhookIds.join(","));
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
  }