mindee 4.0.0 → 4.0.2

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 (124) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +3 -4
  3. package/src/client.d.ts +58 -32
  4. package/src/client.js +50 -19
  5. package/src/http/endpoint.js +9 -11
  6. package/src/index.d.ts +1 -1
  7. package/src/input/base.d.ts +1 -0
  8. package/src/input/base.js +3 -0
  9. package/src/input/pageOptions.d.ts +4 -0
  10. package/src/input/pageOptions.js +3 -0
  11. package/src/input/sources.d.ts +2 -3
  12. package/src/input/sources.js +2 -1
  13. package/src/parsing/common/apiRequest.d.ts +9 -0
  14. package/src/parsing/common/apiRequest.js +5 -0
  15. package/src/parsing/common/apiResponse.d.ts +9 -0
  16. package/src/parsing/common/apiResponse.js +8 -0
  17. package/src/parsing/common/asyncPredictResponse.d.ts +24 -3
  18. package/src/parsing/common/asyncPredictResponse.js +15 -0
  19. package/src/parsing/common/document.d.ts +17 -0
  20. package/src/parsing/common/document.js +16 -4
  21. package/src/parsing/common/extras/cropperExtra.d.ts +3 -0
  22. package/src/parsing/common/extras/cropperExtra.js +3 -0
  23. package/src/parsing/common/extras/extras.d.ts +3 -0
  24. package/src/parsing/common/extras/extras.js +3 -0
  25. package/src/parsing/common/inference.d.ts +26 -0
  26. package/src/parsing/common/inference.js +23 -2
  27. package/src/parsing/common/mvisionV1.d.ts +3 -0
  28. package/src/parsing/common/mvisionV1.js +3 -0
  29. package/src/parsing/common/ocr.d.ts +3 -0
  30. package/src/parsing/common/ocr.js +3 -0
  31. package/src/parsing/common/ocrPage.d.ts +3 -0
  32. package/src/parsing/common/ocrPage.js +3 -0
  33. package/src/parsing/common/orientation.d.ts +3 -0
  34. package/src/parsing/common/orientation.js +3 -0
  35. package/src/parsing/common/page.d.ts +19 -0
  36. package/src/parsing/common/page.js +15 -0
  37. package/src/parsing/common/predictResponse.d.ts +11 -0
  38. package/src/parsing/common/predictResponse.js +10 -0
  39. package/src/parsing/custom/classificationField.d.ts +3 -0
  40. package/src/parsing/custom/classificationField.js +3 -0
  41. package/src/parsing/custom/listField.d.ts +6 -0
  42. package/src/parsing/custom/listField.js +6 -0
  43. package/src/parsing/standard/amount.d.ts +3 -0
  44. package/src/parsing/standard/amount.js +3 -0
  45. package/src/parsing/standard/base.d.ts +3 -0
  46. package/src/parsing/standard/base.js +3 -0
  47. package/src/parsing/standard/locale.d.ts +3 -0
  48. package/src/parsing/standard/locale.js +3 -0
  49. package/src/parsing/standard/paymentDetails.d.ts +3 -0
  50. package/src/parsing/standard/paymentDetails.js +3 -0
  51. package/src/parsing/standard/position.d.ts +3 -0
  52. package/src/parsing/standard/position.js +3 -0
  53. package/src/parsing/standard/tax.d.ts +3 -0
  54. package/src/parsing/standard/tax.js +3 -0
  55. package/src/product/cropper/cropperV1.d.ts +7 -0
  56. package/src/product/cropper/cropperV1.js +6 -0
  57. package/src/product/cropper/cropperV1Document.d.ts +6 -0
  58. package/src/product/cropper/cropperV1Document.js +6 -0
  59. package/src/product/custom/customV1.d.ts +7 -0
  60. package/src/product/custom/customV1.js +6 -0
  61. package/src/product/custom/customV1Document.d.ts +16 -0
  62. package/src/product/custom/customV1Document.js +16 -2
  63. package/src/product/custom/customV1Page.d.ts +7 -0
  64. package/src/product/custom/customV1Page.js +7 -0
  65. package/src/product/eu/licensePlate/licensePlateV1.d.ts +7 -0
  66. package/src/product/eu/licensePlate/licensePlateV1.js +6 -0
  67. package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +3 -0
  68. package/src/product/eu/licensePlate/licensePlateV1Document.js +3 -0
  69. package/src/product/financialDocument/financialDocumentV1.d.ts +7 -0
  70. package/src/product/financialDocument/financialDocumentV1.js +6 -0
  71. package/src/product/financialDocument/financialDocumentV1Document.d.ts +3 -0
  72. package/src/product/financialDocument/financialDocumentV1Document.js +3 -0
  73. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +7 -0
  74. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +6 -0
  75. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +3 -0
  76. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +3 -0
  77. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +7 -0
  78. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +6 -0
  79. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts +3 -0
  80. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +3 -0
  81. package/src/product/fr/carteVitale/carteVitaleV1.d.ts +7 -0
  82. package/src/product/fr/carteVitale/carteVitaleV1.js +6 -0
  83. package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +3 -0
  84. package/src/product/fr/carteVitale/carteVitaleV1Document.js +3 -0
  85. package/src/product/fr/idCard/idCardV1.d.ts +7 -0
  86. package/src/product/fr/idCard/idCardV1.js +6 -0
  87. package/src/product/fr/idCard/idCardV1Document.d.ts +3 -0
  88. package/src/product/fr/idCard/idCardV1Document.js +3 -0
  89. package/src/product/invoice/invoiceV4.d.ts +7 -0
  90. package/src/product/invoice/invoiceV4.js +6 -0
  91. package/src/product/invoice/invoiceV4Document.d.ts +3 -1
  92. package/src/product/invoice/invoiceV4Document.js +3 -1
  93. package/src/product/invoice/invoiceV4LineItem.d.ts +9 -0
  94. package/src/product/invoice/invoiceV4LineItem.js +9 -0
  95. package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +7 -0
  96. package/src/product/invoiceSplitter/invoiceSplitterV1.js +6 -0
  97. package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +6 -0
  98. package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +6 -0
  99. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +8 -0
  100. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +7 -0
  101. package/src/product/passport/passportV1.d.ts +7 -0
  102. package/src/product/passport/passportV1.js +6 -0
  103. package/src/product/passport/passportV1Document.d.ts +3 -0
  104. package/src/product/passport/passportV1Document.js +3 -0
  105. package/src/product/proofOfAddress/proofOfAddressV1.d.ts +7 -0
  106. package/src/product/proofOfAddress/proofOfAddressV1.js +6 -0
  107. package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +3 -0
  108. package/src/product/proofOfAddress/proofOfAddressV1Document.js +3 -0
  109. package/src/product/receipt/receiptV4.d.ts +7 -0
  110. package/src/product/receipt/receiptV4.js +5 -0
  111. package/src/product/receipt/receiptV4Document.d.ts +6 -0
  112. package/src/product/receipt/receiptV4Document.js +6 -0
  113. package/src/product/receipt/receiptV5.d.ts +7 -0
  114. package/src/product/receipt/receiptV5.js +6 -0
  115. package/src/product/receipt/receiptV5Document.d.ts +3 -0
  116. package/src/product/receipt/receiptV5Document.js +3 -0
  117. package/src/product/us/bankCheck/bankCheckV1.d.ts +7 -0
  118. package/src/product/us/bankCheck/bankCheckV1.js +6 -0
  119. package/src/product/us/bankCheck/bankCheckV1Document.d.ts +3 -0
  120. package/src/product/us/bankCheck/bankCheckV1Document.js +3 -0
  121. package/src/product/us/driverLicense/driverLicenseV1.d.ts +7 -0
  122. package/src/product/us/driverLicense/driverLicenseV1.js +6 -0
  123. package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +3 -0
  124. package/src/product/us/driverLicense/driverLicenseV1Document.js +3 -0
@@ -3,14 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Document = void 0;
4
4
  const cropperExtra_1 = require("./extras/cropperExtra");
5
5
  const extras_1 = require("./extras/extras");
6
+ /**
7
+ * Document prediction wrapper class. Holds the results of a parsed document.
8
+ * @typeParam T an extension of an `Inference`. Mandatory in order to properly create an inference.
9
+ */
6
10
  class Document {
11
+ /**
12
+ *
13
+ * @param inferenceClass constructor signature for an inference.
14
+ * @param httpResponse raw http response.
15
+ */
7
16
  constructor(inferenceClass, httpResponse) {
8
- this.id = httpResponse["id"] ?? "";
9
- this.filename = httpResponse["name"] ?? "";
10
- this.ocr = httpResponse["ocr"] ?? undefined;
17
+ this.id = httpResponse?.id ?? "";
18
+ this.filename = httpResponse?.name ?? "";
19
+ this.ocr = httpResponse?.ocr ?? undefined;
11
20
  this.inference = new inferenceClass(httpResponse["inference"]);
12
21
  // Note: this is a convoluted but functional way of being able to implement/use Extras fields
13
- // as an extension of a Map object (like having an adapted toString() method, for instance)
22
+ // as an extension of a Map object (like having an adapted toString() method, for instance).
14
23
  if (httpResponse["extras"] &&
15
24
  Object.keys(httpResponse["extras"].length > 0)) {
16
25
  const extras = {};
@@ -23,6 +32,9 @@ class Document {
23
32
  this.extras = new extras_1.Extras(extras);
24
33
  }
25
34
  }
35
+ /**
36
+ * Default string representation.
37
+ */
26
38
  toString() {
27
39
  return `########\nDocument\n########
28
40
  :Mindee ID: ${this.id}
@@ -4,5 +4,8 @@ import { ExtraField } from "./extras";
4
4
  export declare class CropperExtra extends ExtraField {
5
5
  cropping: PositionField[];
6
6
  constructor(rawPrediction: StringDict, pageId?: number);
7
+ /**
8
+ * Default string representation.
9
+ */
7
10
  toString(): string;
8
11
  }
@@ -16,6 +16,9 @@ class CropperExtra extends extras_1.ExtraField {
16
16
  }));
17
17
  });
18
18
  }
19
+ /**
20
+ * Default string representation.
21
+ */
19
22
  toString() {
20
23
  const cropping = this.cropping
21
24
  .map((crop) => crop.toString())
@@ -6,6 +6,9 @@ interface ExtraDict<T extends ExtraField> {
6
6
  export declare class Extras<ExtraT extends ExtraField = ExtraField> implements ExtraDict<ExtraT> {
7
7
  [key: string]: ExtraT | (() => string);
8
8
  constructor(fields: Record<string, ExtraT>);
9
+ /**
10
+ * Default string representation.
11
+ */
9
12
  toString(): string;
10
13
  }
11
14
  export {};
@@ -9,6 +9,9 @@ class Extras {
9
9
  Object.keys(fields).length > 0 &&
10
10
  Object.keys(fields).forEach((name) => (this[name] = fields[name]));
11
11
  }
12
+ /**
13
+ * Default string representation.
14
+ */
12
15
  toString() {
13
16
  return (Object.entries(this)
14
17
  .map(([name, extraField]) => name + ":\n" + extraField.toString())
@@ -3,18 +3,44 @@ import { ExtraField } from "./extras/extras";
3
3
  import { Page } from "./page";
4
4
  import type { Prediction } from "./prediction";
5
5
  import { Product } from "./product";
6
+ /**
7
+ *
8
+ * @typeParam DocT an extension of a `Prediction`. Is generic by default to
9
+ * allow for easier optional `PageT` generic typing.
10
+ * @typeParam PageT an extension of a `DocT` (`Prediction`). Should only be set
11
+ * if a document's pages have specific implementation.
12
+ */
6
13
  export declare abstract class Inference<DocT extends Prediction = Prediction, PageT extends DocT = DocT> {
14
+ /** A boolean denoting whether a given inference result was rotated. */
7
15
  isRotationApplied?: boolean;
16
+ /** Name and version of a given product. */
8
17
  product: Product;
18
+ /** Wrapper for a document's pages prediction. */
9
19
  pages: Page<PageT>[];
20
+ /** A document's top-level `Prediction`. */
10
21
  prediction: DocT;
22
+ /** Extraneous fields relating to specific tools for some APIs. */
11
23
  extras?: ExtraField[];
24
+ /** Name of a document's endpoint. Has a default value for OTS APIs. */
12
25
  endpointName?: string;
26
+ /** A document's version. Has a default value for OTS APIs. */
13
27
  endpointVersion?: string;
14
28
  constructor(rawPrediction: StringDict);
29
+ /**
30
+ * Default string representation.
31
+ */
15
32
  toString(): string;
33
+ /**
34
+ * Takes in an input string and replaces line breaks with `\n`.
35
+ * @param outStr string to cleanup
36
+ * @returns cleaned out string
37
+ */
16
38
  static cleanOutString(outStr: string): string;
17
39
  }
40
+ /**
41
+ * Factory to allow for static-like property access syntax in TypeScript.
42
+ * Used to retrieve endpoint data for standard products.
43
+ */
18
44
  export declare class InferenceFactory {
19
45
  /**
20
46
  * Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
@@ -1,13 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InferenceFactory = exports.Inference = void 0;
4
+ /**
5
+ *
6
+ * @typeParam DocT an extension of a `Prediction`. Is generic by default to
7
+ * allow for easier optional `PageT` generic typing.
8
+ * @typeParam PageT an extension of a `DocT` (`Prediction`). Should only be set
9
+ * if a document's pages have specific implementation.
10
+ */
4
11
  class Inference {
5
12
  constructor(rawPrediction) {
13
+ /** Wrapper for a document's pages prediction. */
6
14
  this.pages = [];
15
+ /** Extraneous fields relating to specific tools for some APIs. */
7
16
  this.extras = [];
8
- this.isRotationApplied = rawPrediction["is_rotation_applied"] ?? undefined;
9
- this.product = rawPrediction["product"];
17
+ this.isRotationApplied = rawPrediction?.is_rotation_applied ?? undefined;
18
+ this.product = rawPrediction?.product;
10
19
  }
20
+ /**
21
+ * Default string representation.
22
+ */
11
23
  toString() {
12
24
  return `Inference
13
25
  #########
@@ -23,12 +35,21 @@ Page Predictions
23
35
 
24
36
  ${this.pages.map((e) => e.toString() || "").join("\n")}`;
25
37
  }
38
+ /**
39
+ * Takes in an input string and replaces line breaks with `\n`.
40
+ * @param outStr string to cleanup
41
+ * @returns cleaned out string
42
+ */
26
43
  static cleanOutString(outStr) {
27
44
  const lines = / \n/gm;
28
45
  return outStr.replace(lines, "\n");
29
46
  }
30
47
  }
31
48
  exports.Inference = Inference;
49
+ /**
50
+ * Factory to allow for static-like property access syntax in TypeScript.
51
+ * Used to retrieve endpoint data for standard products.
52
+ */
32
53
  class InferenceFactory {
33
54
  /**
34
55
  * Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
@@ -4,5 +4,8 @@ export declare class MvisionV1 {
4
4
  /** List of words found on the page. */
5
5
  pages: OcrPage[];
6
6
  constructor(rawPrediction: StringDict);
7
+ /**
8
+ * Default string representation.
9
+ */
7
10
  toString(): string;
8
11
  }
@@ -10,6 +10,9 @@ class MvisionV1 {
10
10
  this.pages.push(new ocrPage_1.OcrPage(page));
11
11
  });
12
12
  }
13
+ /**
14
+ * Default string representation.
15
+ */
13
16
  toString() {
14
17
  return this.pages.map((page) => page.toString()).join("\n") + "\n";
15
18
  }
@@ -4,5 +4,8 @@ export declare class Ocr {
4
4
  /** Default Mindee OCR */
5
5
  mVisionV1: MvisionV1;
6
6
  constructor(rawPrediction: StringDict);
7
+ /**
8
+ * Default string representation.
9
+ */
7
10
  toString(): string;
8
11
  }
@@ -6,6 +6,9 @@ class Ocr {
6
6
  constructor(rawPrediction) {
7
7
  this.mVisionV1 = new mvisionV1_1.MvisionV1(rawPrediction["mvision-v1"]);
8
8
  }
9
+ /**
10
+ * Default string representation.
11
+ */
9
12
  toString() {
10
13
  return this.mVisionV1.toString();
11
14
  }
@@ -12,5 +12,8 @@ export declare class OcrPage {
12
12
  * @returns Sorted lines on the pages
13
13
  */
14
14
  getAllLines(): Word[][];
15
+ /**
16
+ * Default string representation.
17
+ */
15
18
  toString(): string;
16
19
  }
@@ -32,6 +32,9 @@ class OcrPage {
32
32
  }
33
33
  return this.allLines;
34
34
  }
35
+ /**
36
+ * Default string representation.
37
+ */
35
38
  toString() {
36
39
  return this.getAllLines()
37
40
  .map((line) => line.map((word) => word.text).join(" "))
@@ -17,6 +17,9 @@ export declare class OrientationField extends BaseField {
17
17
  * @param {Integer} pageId - Page ID for multi-page document
18
18
  */
19
19
  constructor({ prediction, valueKey, reconstructed, pageId, }: OrientationFieldConstructor);
20
+ /**
21
+ * Default string representation.
22
+ */
20
23
  toString(): string;
21
24
  }
22
25
  export {};
@@ -20,6 +20,9 @@ class OrientationField extends standard_1.BaseField {
20
20
  if (!orientations.includes(this.value))
21
21
  this.value = 0;
22
22
  }
23
+ /**
24
+ * Default string representation.
25
+ */
23
26
  toString() {
24
27
  return `${this.value} degrees`;
25
28
  }
@@ -2,11 +2,30 @@ import { Extras } from "./extras/extras";
2
2
  import { OrientationField } from "./orientation";
3
3
  import { Prediction } from "./prediction";
4
4
  import { StringDict } from "./stringDict";
5
+ /**
6
+ * Page prediction wrapper class. Holds the results of a parsed document's page.
7
+ * Holds a `Prediction` that's either a document-level Prediction, or inherits from one.
8
+ * @typeParam T an extension of an `Prediction`. Mandatory in order to properly create a page-level prediction.
9
+ */
5
10
  export declare class Page<T extends Prediction> {
11
+ /** The page's index (identifier). */
6
12
  id: number;
13
+ /** The page's orientation */
7
14
  orientation?: OrientationField;
15
+ /** A page-level prediction. Can either be specific to pages or identical to the document prediction. */
8
16
  prediction: T;
17
+ /** Potential `Extras` fields sent back along with the prediction. */
9
18
  extras?: Extras;
19
+ /**
20
+ *
21
+ * @param inferenceClass constructor signature for an inference.
22
+ * @param httpResponse raw http response.
23
+ * @param pageId the page's index (identifier).
24
+ * @param orientation the page's orientation.
25
+ */
10
26
  constructor(predictionType: new (rawPrediction: StringDict, pageId: number) => T, rawPrediction: StringDict, pageId: number, orientation?: StringDict);
27
+ /**
28
+ * Default string representation.
29
+ */
11
30
  toString(): string;
12
31
  }
@@ -4,7 +4,19 @@ exports.Page = void 0;
4
4
  const cropperExtra_1 = require("./extras/cropperExtra");
5
5
  const extras_1 = require("./extras/extras");
6
6
  const orientation_1 = require("./orientation");
7
+ /**
8
+ * Page prediction wrapper class. Holds the results of a parsed document's page.
9
+ * Holds a `Prediction` that's either a document-level Prediction, or inherits from one.
10
+ * @typeParam T an extension of an `Prediction`. Mandatory in order to properly create a page-level prediction.
11
+ */
7
12
  class Page {
13
+ /**
14
+ *
15
+ * @param inferenceClass constructor signature for an inference.
16
+ * @param httpResponse raw http response.
17
+ * @param pageId the page's index (identifier).
18
+ * @param orientation the page's orientation.
19
+ */
8
20
  constructor(predictionType, rawPrediction, pageId, orientation) {
9
21
  if (pageId !== undefined && orientation !== undefined) {
10
22
  this.orientation = new orientation_1.OrientationField({
@@ -29,6 +41,9 @@ class Page {
29
41
  this.extras = new extras_1.Extras(extras);
30
42
  }
31
43
  }
44
+ /**
45
+ * Default string representation.
46
+ */
32
47
  toString() {
33
48
  const title = `Page ${this.id}`;
34
49
  return `${title}
@@ -1,6 +1,17 @@
1
1
  import { ApiResponse } from "./apiResponse";
2
2
  import { Document, Inference, StringDict } from ".";
3
+ /** Wrapper for synchronous prediction response.
4
+ *
5
+ * @category API Response
6
+ * @category Synchronous
7
+ */
3
8
  export declare class PredictResponse<T extends Inference> extends ApiResponse {
9
+ /** A document prediction response. */
4
10
  document: Document<T>;
11
+ /**
12
+ *
13
+ * @param inferenceClass constructor signature for an inference.
14
+ * @param rawPrediction raw http response.
15
+ */
5
16
  constructor(inferenceClass: new (rawPrediction: StringDict) => T, rawPrediction: StringDict);
6
17
  }
@@ -3,7 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PredictResponse = void 0;
4
4
  const apiResponse_1 = require("./apiResponse");
5
5
  const _1 = require(".");
6
+ /** Wrapper for synchronous prediction response.
7
+ *
8
+ * @category API Response
9
+ * @category Synchronous
10
+ */
6
11
  class PredictResponse extends apiResponse_1.ApiResponse {
12
+ /**
13
+ *
14
+ * @param inferenceClass constructor signature for an inference.
15
+ * @param rawPrediction raw http response.
16
+ */
7
17
  constructor(inferenceClass, rawPrediction) {
8
18
  super(rawPrediction);
9
19
  this.document = new _1.Document(inferenceClass, rawPrediction["document"]);
@@ -12,5 +12,8 @@ export declare class ClassificationField {
12
12
  prediction: StringDict;
13
13
  pageId?: number;
14
14
  });
15
+ /**
16
+ * Default string representation.
17
+ */
15
18
  toString(): string;
16
19
  }
@@ -7,6 +7,9 @@ class ClassificationField {
7
7
  this.confidence = prediction["confidence"];
8
8
  this.pageId ?? (this.pageId = pageId);
9
9
  }
10
+ /**
11
+ * Default string representation.
12
+ */
10
13
  toString() {
11
14
  return `${this.value}`;
12
15
  }
@@ -20,6 +20,9 @@ export declare class ListFieldValue {
20
20
  */
21
21
  polygon: Polygon;
22
22
  constructor(prediction: StringDict);
23
+ /**
24
+ * Default string representation.
25
+ */
23
26
  toString(): string;
24
27
  }
25
28
  export declare class ListField {
@@ -32,5 +35,8 @@ export declare class ListField {
32
35
  constructor({ prediction, reconstructed, pageId, }: FieldConstructor);
33
36
  contentsList(): Array<string | number>;
34
37
  contentsString(separator?: string): string;
38
+ /**
39
+ * Default string representation.
40
+ */
35
41
  toString(): string;
36
42
  }
@@ -21,6 +21,9 @@ class ListFieldValue {
21
21
  this.bbox = (0, geometry_1.getBoundingBox)(prediction["polygon"]);
22
22
  }
23
23
  }
24
+ /**
25
+ * Default string representation.
26
+ */
24
27
  toString() {
25
28
  return `${this.content}`;
26
29
  }
@@ -44,6 +47,9 @@ class ListField {
44
47
  contentsString(separator = " ") {
45
48
  return this.values.map((item) => `${item.content}`).join(separator);
46
49
  }
50
+ /**
51
+ * Default string representation.
52
+ */
47
53
  toString() {
48
54
  return this.contentsString();
49
55
  }
@@ -13,5 +13,8 @@ export declare class AmountField extends Field {
13
13
  * @param {Integer} pageId - Page ID for multi-page document
14
14
  */
15
15
  constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
16
+ /**
17
+ * Default string representation.
18
+ */
16
19
  toString(): string;
17
20
  }
@@ -30,6 +30,9 @@ class AmountField extends field_1.Field {
30
30
  this.confidence = 0.0;
31
31
  }
32
32
  }
33
+ /**
34
+ * Default string representation.
35
+ */
33
36
  toString() {
34
37
  if (this.value !== undefined) {
35
38
  return floatToString(this.value);
@@ -26,5 +26,8 @@ export declare class BaseField {
26
26
  * @returns {Number} Sum of all the Fields values in the array
27
27
  */
28
28
  static arraySum(array: BaseField[]): number;
29
+ /**
30
+ * Default string representation.
31
+ */
29
32
  toString(): string;
30
33
  }
@@ -47,6 +47,9 @@ class BaseField {
47
47
  }
48
48
  return total;
49
49
  }
50
+ /**
51
+ * Default string representation.
52
+ */
50
53
  toString() {
51
54
  if (this.value !== undefined) {
52
55
  return `${this.value}`;
@@ -19,5 +19,8 @@ export declare class LocaleField extends BaseField {
19
19
  * @param {boolean} reconstructed - Is the object reconstructed (not extracted by the API)
20
20
  */
21
21
  constructor({ prediction, reconstructed, pageId, }: BaseFieldConstructor);
22
+ /**
23
+ * Default string representation.
24
+ */
22
25
  toString(): string;
23
26
  }
@@ -22,6 +22,9 @@ class LocaleField extends base_1.BaseField {
22
22
  this.currency =
23
23
  prediction["currency"] !== undefined ? prediction["currency"] : undefined;
24
24
  }
25
+ /**
26
+ * Default string representation.
27
+ */
25
28
  toString() {
26
29
  let outStr = "";
27
30
  if (this.value) {
@@ -36,6 +36,9 @@ export declare class PaymentDetailsField extends Field {
36
36
  * @param {Integer} pageId - Page ID for multi-page document
37
37
  */
38
38
  constructor({ prediction, valueKey, accountNumberKey, ibanKey, routingNumberKey, swiftKey, reconstructed, pageId, }: PaymentDetailsConstructor);
39
+ /**
40
+ * Default string representation.
41
+ */
39
42
  toString(): string;
40
43
  }
41
44
  export {};
@@ -41,6 +41,9 @@ class PaymentDetailsField extends field_1.Field {
41
41
  this.swift = prediction[swiftKey];
42
42
  }
43
43
  }
44
+ /**
45
+ * Default string representation.
46
+ */
44
47
  toString() {
45
48
  let str = "";
46
49
  if (this.accountNumber !== undefined) {
@@ -20,5 +20,8 @@ export declare class PositionField {
20
20
  /** The document page on which the information was found. */
21
21
  pageId: number | undefined;
22
22
  constructor({ prediction, pageId }: PositionFieldConstructor);
23
+ /**
24
+ * Default string representation.
25
+ */
23
26
  toString(): string;
24
27
  }
@@ -12,6 +12,9 @@ class PositionField {
12
12
  this.quadrangle = prediction["quadrangle"];
13
13
  this.rectangle = prediction["rectangle"];
14
14
  }
15
+ /**
16
+ * Default string representation.
17
+ */
15
18
  toString() {
16
19
  return `Polygon with ${this.polygon.length} points.`;
17
20
  }
@@ -49,6 +49,9 @@ export declare class TaxField extends Field {
49
49
  export declare class Taxes extends Array<TaxField> {
50
50
  #private;
51
51
  init(prediction: StringDict[] | undefined, pageId: number | undefined): this;
52
+ /**
53
+ * Default string representation.
54
+ */
52
55
  toString(): string;
53
56
  }
54
57
  export {};
@@ -105,6 +105,9 @@ class Taxes extends Array {
105
105
  }
106
106
  return this;
107
107
  }
108
+ /**
109
+ * Default string representation.
110
+ */
108
111
  toString() {
109
112
  let outStr = `
110
113
  ${__classPrivateFieldGet(this, _Taxes_instances, "m", _Taxes_lineSeparator).call(this, "-")}
@@ -1,9 +1,16 @@
1
1
  import { Inference, Page, StringDict } from "../../parsing/common";
2
2
  import { CropperV1Document } from "./cropperV1Document";
3
+ /**
4
+ * Inference prediction for Cropper API, version 1.
5
+ */
3
6
  export declare class CropperV1 extends Inference {
7
+ /** The endpoint's name. */
4
8
  endpointName: string;
9
+ /** The endpoint's version. */
5
10
  endpointVersion: string;
11
+ /** The document-level prediction. */
6
12
  prediction: CropperV1Document;
13
+ /** The document's pages. */
7
14
  pages: Page<CropperV1Document>[];
8
15
  constructor(rawPrediction: StringDict);
9
16
  }
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CropperV1 = void 0;
4
4
  const common_1 = require("../../parsing/common");
5
5
  const cropperV1Document_1 = require("./cropperV1Document");
6
+ /**
7
+ * Inference prediction for Cropper API, version 1.
8
+ */
6
9
  class CropperV1 extends common_1.Inference {
7
10
  constructor(rawPrediction) {
8
11
  super(rawPrediction);
12
+ /** The endpoint's name. */
9
13
  this.endpointName = "cropper";
14
+ /** The endpoint's version. */
10
15
  this.endpointVersion = "1";
16
+ /** The document's pages. */
11
17
  this.pages = [];
12
18
  this.prediction = new cropperV1Document_1.CropperV1Document(rawPrediction["prediction"]);
13
19
  this.pages = rawPrediction["pages"].map((page) => new common_1.Page(cropperV1Document_1.CropperV1Document, page, page["id"], page["orientation"]));
@@ -1,8 +1,14 @@
1
1
  import { Prediction, StringDict } from "../../parsing/common";
2
2
  import { PositionField } from "../../parsing/standard";
3
+ /**
4
+ * Document data for Cropper API, version 1.
5
+ */
3
6
  export declare class CropperV1Document implements Prediction {
4
7
  /** A list of cropped positions. */
5
8
  cropping: PositionField[];
6
9
  constructor(rawPrediction: StringDict, pageId?: number);
10
+ /**
11
+ * Default string representation.
12
+ */
7
13
  toString(): string;
8
14
  }
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CropperV1Document = void 0;
4
4
  const summaryHelper_1 = require("../../parsing/common/summaryHelper");
5
5
  const standard_1 = require("../../parsing/standard");
6
+ /**
7
+ * Document data for Cropper API, version 1.
8
+ */
6
9
  class CropperV1Document {
7
10
  constructor(rawPrediction, pageId) {
8
11
  /** A list of cropped positions. */
@@ -15,6 +18,9 @@ class CropperV1Document {
15
18
  }));
16
19
  });
17
20
  }
21
+ /**
22
+ * Default string representation.
23
+ */
18
24
  toString() {
19
25
  const cropping = this.cropping
20
26
  .map((crop) => crop.toString())
@@ -1,10 +1,17 @@
1
1
  import { Inference, Page, StringDict } from "../../parsing/common";
2
2
  import { CustomV1Document } from "./customV1Document";
3
3
  import { CustomV1Page } from "./customV1Page";
4
+ /**
5
+ * Inference prediction for Custom builds.
6
+ */
4
7
  export declare class CustomV1 extends Inference {
8
+ /** The endpoint's name. Note: placeholder for custom APIs. */
5
9
  endpointName: string;
10
+ /** The endpoint's version. Note: placeholder for custom APIs. */
6
11
  endpointVersion: string;
12
+ /** The document-level prediction. */
7
13
  prediction: CustomV1Document;
14
+ /** The document's pages. */
8
15
  pages: Page<CustomV1Page>[];
9
16
  constructor(rawPrediction: StringDict);
10
17
  }