mindee 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.json +4 -3
  3. package/src/cli.js +36 -66
  4. package/src/client.d.ts +76 -32
  5. package/src/client.js +108 -21
  6. package/src/http/endpoint.d.ts +36 -0
  7. package/src/http/endpoint.js +54 -16
  8. package/src/http/error.d.ts +66 -1
  9. package/src/http/error.js +196 -4
  10. package/src/http/index.d.ts +1 -1
  11. package/src/http/index.js +10 -1
  12. package/src/index.d.ts +2 -1
  13. package/src/index.js +2 -1
  14. package/src/input/base.d.ts +1 -0
  15. package/src/input/base.js +3 -0
  16. package/src/input/pageOptions.d.ts +4 -0
  17. package/src/input/pageOptions.js +3 -0
  18. package/src/input/sources.d.ts +2 -3
  19. package/src/input/sources.js +2 -1
  20. package/src/internal.d.ts +5 -0
  21. package/src/internal.js +31 -0
  22. package/src/parsing/common/apiRequest.d.ts +9 -0
  23. package/src/parsing/common/apiRequest.js +5 -0
  24. package/src/parsing/common/apiResponse.d.ts +15 -0
  25. package/src/parsing/common/apiResponse.js +15 -0
  26. package/src/parsing/common/asyncPredictResponse.d.ts +24 -3
  27. package/src/parsing/common/asyncPredictResponse.js +15 -0
  28. package/src/parsing/common/document.d.ts +17 -0
  29. package/src/parsing/common/document.js +16 -4
  30. package/src/parsing/common/extras/cropperExtra.d.ts +3 -0
  31. package/src/parsing/common/extras/cropperExtra.js +3 -0
  32. package/src/parsing/common/extras/extras.d.ts +3 -0
  33. package/src/parsing/common/extras/extras.js +3 -0
  34. package/src/parsing/common/inference.d.ts +26 -0
  35. package/src/parsing/common/inference.js +23 -2
  36. package/src/parsing/common/mvisionV1.d.ts +3 -0
  37. package/src/parsing/common/mvisionV1.js +3 -0
  38. package/src/parsing/common/ocr.d.ts +3 -0
  39. package/src/parsing/common/ocr.js +3 -0
  40. package/src/parsing/common/ocrPage.d.ts +3 -0
  41. package/src/parsing/common/ocrPage.js +3 -0
  42. package/src/parsing/common/orientation.d.ts +3 -0
  43. package/src/parsing/common/orientation.js +3 -0
  44. package/src/parsing/common/page.d.ts +19 -0
  45. package/src/parsing/common/page.js +15 -0
  46. package/src/parsing/common/predictResponse.d.ts +11 -0
  47. package/src/parsing/common/predictResponse.js +10 -0
  48. package/src/parsing/custom/classificationField.d.ts +3 -0
  49. package/src/parsing/custom/classificationField.js +3 -0
  50. package/src/parsing/custom/listField.d.ts +6 -0
  51. package/src/parsing/custom/listField.js +6 -0
  52. package/src/parsing/standard/amount.d.ts +3 -0
  53. package/src/parsing/standard/amount.js +3 -0
  54. package/src/parsing/standard/base.d.ts +3 -0
  55. package/src/parsing/standard/base.js +3 -0
  56. package/src/parsing/standard/locale.d.ts +3 -0
  57. package/src/parsing/standard/locale.js +3 -0
  58. package/src/parsing/standard/paymentDetails.d.ts +3 -0
  59. package/src/parsing/standard/paymentDetails.js +3 -0
  60. package/src/parsing/standard/position.d.ts +3 -0
  61. package/src/parsing/standard/position.js +3 -0
  62. package/src/parsing/standard/tax.d.ts +3 -0
  63. package/src/parsing/standard/tax.js +3 -0
  64. package/src/product/cropper/cropperV1.d.ts +7 -0
  65. package/src/product/cropper/cropperV1.js +6 -0
  66. package/src/product/cropper/cropperV1Document.d.ts +6 -0
  67. package/src/product/cropper/cropperV1Document.js +6 -0
  68. package/src/product/cropper/internal.d.ts +2 -0
  69. package/src/product/cropper/internal.js +7 -0
  70. package/src/product/custom/customV1.d.ts +7 -0
  71. package/src/product/custom/customV1.js +6 -0
  72. package/src/product/custom/customV1Document.d.ts +16 -0
  73. package/src/product/custom/customV1Document.js +16 -2
  74. package/src/product/custom/customV1Page.d.ts +7 -0
  75. package/src/product/custom/customV1Page.js +7 -0
  76. package/src/product/custom/internal.d.ts +3 -0
  77. package/src/product/custom/internal.js +9 -0
  78. package/src/product/eu/internal.d.ts +1 -0
  79. package/src/product/eu/internal.js +27 -0
  80. package/src/product/eu/licensePlate/internal.d.ts +2 -0
  81. package/src/product/eu/licensePlate/internal.js +7 -0
  82. package/src/product/eu/licensePlate/licensePlateV1.d.ts +7 -0
  83. package/src/product/eu/licensePlate/licensePlateV1.js +6 -0
  84. package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +3 -0
  85. package/src/product/eu/licensePlate/licensePlateV1Document.js +3 -0
  86. package/src/product/financialDocument/financialDocumentV1.d.ts +7 -0
  87. package/src/product/financialDocument/financialDocumentV1.js +6 -0
  88. package/src/product/financialDocument/financialDocumentV1Document.d.ts +3 -0
  89. package/src/product/financialDocument/financialDocumentV1Document.js +3 -0
  90. package/src/product/financialDocument/internal.d.ts +3 -0
  91. package/src/product/financialDocument/internal.js +9 -0
  92. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +7 -0
  93. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +6 -0
  94. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +3 -0
  95. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +3 -0
  96. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +7 -0
  97. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +6 -0
  98. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts +3 -0
  99. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +3 -0
  100. package/src/product/fr/bankAccountDetails/internal.d.ts +5 -0
  101. package/src/product/fr/bankAccountDetails/internal.js +13 -0
  102. package/src/product/fr/carteVitale/carteVitaleV1.d.ts +7 -0
  103. package/src/product/fr/carteVitale/carteVitaleV1.js +6 -0
  104. package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +3 -0
  105. package/src/product/fr/carteVitale/carteVitaleV1Document.js +3 -0
  106. package/src/product/fr/carteVitale/internal.d.ts +2 -0
  107. package/src/product/fr/carteVitale/internal.js +7 -0
  108. package/src/product/fr/idCard/idCardV1.d.ts +7 -0
  109. package/src/product/fr/idCard/idCardV1.js +6 -0
  110. package/src/product/fr/idCard/idCardV1Document.d.ts +3 -0
  111. package/src/product/fr/idCard/idCardV1Document.js +3 -0
  112. package/src/product/fr/idCard/internal.d.ts +3 -0
  113. package/src/product/fr/idCard/internal.js +9 -0
  114. package/src/product/fr/internal.d.ts +3 -0
  115. package/src/product/fr/internal.js +29 -0
  116. package/src/product/index.d.ts +0 -1
  117. package/src/product/index.js +1 -3
  118. package/src/product/internal.d.ts +11 -0
  119. package/src/product/internal.js +37 -0
  120. package/src/product/invoice/internal.d.ts +3 -0
  121. package/src/product/invoice/internal.js +9 -0
  122. package/src/product/invoice/invoiceV4.d.ts +7 -0
  123. package/src/product/invoice/invoiceV4.js +6 -0
  124. package/src/product/invoice/invoiceV4Document.d.ts +3 -1
  125. package/src/product/invoice/invoiceV4Document.js +3 -1
  126. package/src/product/invoice/invoiceV4LineItem.d.ts +9 -0
  127. package/src/product/invoice/invoiceV4LineItem.js +9 -0
  128. package/src/product/invoiceSplitter/internal.d.ts +3 -0
  129. package/src/product/invoiceSplitter/internal.js +9 -0
  130. package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +7 -0
  131. package/src/product/invoiceSplitter/invoiceSplitterV1.js +6 -0
  132. package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -2
  133. package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +7 -1
  134. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +9 -1
  135. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +10 -3
  136. package/src/product/passport/internal.d.ts +2 -0
  137. package/src/product/passport/internal.js +7 -0
  138. package/src/product/passport/passportV1.d.ts +7 -0
  139. package/src/product/passport/passportV1.js +6 -0
  140. package/src/product/passport/passportV1Document.d.ts +3 -0
  141. package/src/product/passport/passportV1Document.js +3 -0
  142. package/src/product/proofOfAddress/internal.d.ts +2 -0
  143. package/src/product/proofOfAddress/internal.js +7 -0
  144. package/src/product/proofOfAddress/proofOfAddressV1.d.ts +7 -0
  145. package/src/product/proofOfAddress/proofOfAddressV1.js +6 -0
  146. package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +3 -0
  147. package/src/product/proofOfAddress/proofOfAddressV1Document.js +3 -0
  148. package/src/product/receipt/internal.d.ts +5 -0
  149. package/src/product/receipt/internal.js +13 -0
  150. package/src/product/receipt/receiptV4.d.ts +7 -0
  151. package/src/product/receipt/receiptV4.js +5 -0
  152. package/src/product/receipt/receiptV4Document.d.ts +6 -0
  153. package/src/product/receipt/receiptV4Document.js +6 -0
  154. package/src/product/receipt/receiptV5.d.ts +7 -0
  155. package/src/product/receipt/receiptV5.js +6 -0
  156. package/src/product/receipt/receiptV5Document.d.ts +3 -0
  157. package/src/product/receipt/receiptV5Document.js +3 -0
  158. package/src/product/us/bankCheck/bankCheckV1.d.ts +7 -0
  159. package/src/product/us/bankCheck/bankCheckV1.js +6 -0
  160. package/src/product/us/bankCheck/bankCheckV1Document.d.ts +3 -0
  161. package/src/product/us/bankCheck/bankCheckV1Document.js +3 -0
  162. package/src/product/us/bankCheck/internal.d.ts +3 -0
  163. package/src/product/us/bankCheck/internal.js +9 -0
  164. package/src/product/us/driverLicense/driverLicenseV1.d.ts +7 -0
  165. package/src/product/us/driverLicense/driverLicenseV1.js +6 -0
  166. package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +3 -0
  167. package/src/product/us/driverLicense/driverLicenseV1Document.js +3 -0
  168. package/src/product/us/driverLicense/internal.d.ts +3 -0
  169. package/src/product/us/driverLicense/internal.js +9 -0
  170. package/src/product/us/internal.d.ts +2 -0
  171. package/src/product/us/internal.js +28 -0
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiRequest = void 0;
4
+ /**
5
+ * Holds the information relating to an API HTTP request.
6
+ *
7
+ * @category API Response
8
+ */
4
9
  class ApiRequest {
5
10
  constructor(serverResponse) {
6
11
  this.error = serverResponse["error"];
@@ -1,6 +1,21 @@
1
1
  import { ApiRequest } from "./apiRequest";
2
2
  import { StringDict } from "./stringDict";
3
+ /** Base wrapper for API requests.
4
+ *
5
+ * @category API Response
6
+ */
3
7
  export declare abstract class ApiResponse {
8
+ /** Initial request sent to the API. */
4
9
  apiRequest: ApiRequest;
10
+ /** Raw text representation of the API's response. */
11
+ private readonly rawHttp;
12
+ /**
13
+ * @param serverResponse JSON response from the server.
14
+ */
5
15
  constructor(serverResponse: StringDict);
16
+ /**
17
+ * Raw HTTP request sent from server, as a JSON-like structure
18
+ * @returns The HTTP request
19
+ */
20
+ getRawHttp(): StringDict;
6
21
  }
@@ -2,9 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiResponse = void 0;
4
4
  const apiRequest_1 = require("./apiRequest");
5
+ /** Base wrapper for API requests.
6
+ *
7
+ * @category API Response
8
+ */
5
9
  class ApiResponse {
10
+ /**
11
+ * @param serverResponse JSON response from the server.
12
+ */
6
13
  constructor(serverResponse) {
7
14
  this.apiRequest = new apiRequest_1.ApiRequest(serverResponse["api_request"]);
15
+ this.rawHttp = serverResponse;
16
+ }
17
+ /**
18
+ * Raw HTTP request sent from server, as a JSON-like structure
19
+ * @returns The HTTP request
20
+ */
21
+ getRawHttp() {
22
+ return this.rawHttp;
8
23
  }
9
24
  }
10
25
  exports.ApiResponse = ApiResponse;
@@ -2,20 +2,41 @@ import { ApiResponse } from "./apiResponse";
2
2
  import { StringDict } from "./stringDict";
3
3
  import { Inference } from "./inference";
4
4
  import { Document } from "./document";
5
+ /** Wrapper for asynchronous request queues. Holds information regarding a job (queue).
6
+ *
7
+ * @category API Response
8
+ * @category Asynchronous
9
+ */
5
10
  export declare class Job {
11
+ /** Timestamp noting the enqueueing of a document. */
6
12
  issuedAt: Date;
13
+ /** Timestamp noting the availability of a prediction for an enqueued document. */
7
14
  availableAt?: Date;
15
+ /** ID of the job. */
8
16
  id: string;
17
+ /** Status of the job. */
9
18
  status?: "waiting" | "processing" | "completed";
10
- /**
11
- * The time taken to process the job, in milliseconds.
12
- */
19
+ /** The time taken to process the job, in milliseconds. */
13
20
  milliSecsTaken?: number;
14
21
  constructor(jsonResponse: StringDict);
15
22
  protected datetimeWithTimezone(date: string): Date;
16
23
  }
24
+ /** Wrapper for asynchronous jobs and parsing results.
25
+ *
26
+ * @category API Response
27
+ * @category Asynchronous
28
+ */
17
29
  export declare class AsyncPredictResponse<T extends Inference> extends ApiResponse {
30
+ /** Job for a queue. */
18
31
  job: Job;
32
+ /** Prediction for an asynchronous request. Will not be available so long as the job is not
33
+ * `completed`.
34
+ */
19
35
  document?: Document<T>;
36
+ /**
37
+ *
38
+ * @param inferenceClass constructor signature for an inference.
39
+ * @param httpResponse raw http response.
40
+ */
20
41
  constructor(inferenceClass: new (httpResponse: StringDict) => T, httpResponse: StringDict);
21
42
  }
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AsyncPredictResponse = exports.Job = void 0;
4
4
  const apiResponse_1 = require("./apiResponse");
5
5
  const document_1 = require("./document");
6
+ /** Wrapper for asynchronous request queues. Holds information regarding a job (queue).
7
+ *
8
+ * @category API Response
9
+ * @category Asynchronous
10
+ */
6
11
  class Job {
7
12
  constructor(jsonResponse) {
8
13
  this.issuedAt = this.datetimeWithTimezone(jsonResponse["issued_at"]);
@@ -26,7 +31,17 @@ class Job {
26
31
  }
27
32
  }
28
33
  exports.Job = Job;
34
+ /** Wrapper for asynchronous jobs and parsing results.
35
+ *
36
+ * @category API Response
37
+ * @category Asynchronous
38
+ */
29
39
  class AsyncPredictResponse extends apiResponse_1.ApiResponse {
40
+ /**
41
+ *
42
+ * @param inferenceClass constructor signature for an inference.
43
+ * @param httpResponse raw http response.
44
+ */
30
45
  constructor(inferenceClass, httpResponse) {
31
46
  super(httpResponse);
32
47
  this.job = new Job(httpResponse["job"]);
@@ -2,12 +2,29 @@ import { Extras } from "./extras/extras";
2
2
  import { Inference } from "./inference";
3
3
  import { Ocr } from "./ocr";
4
4
  import { StringDict } from "./stringDict";
5
+ /**
6
+ * Document prediction wrapper class. Holds the results of a parsed document.
7
+ * @typeParam T an extension of an `Inference`. Mandatory in order to properly create an inference.
8
+ */
5
9
  export declare class Document<T extends Inference> {
10
+ /** File name as sent back by the server. */
6
11
  filename: string;
12
+ /** Result of the base inference. */
7
13
  inference: T;
14
+ /** Id of the document as sent back by the server. */
8
15
  id: string;
16
+ /** Potential `Extras` fields sent back along the prediction. */
9
17
  extras?: Extras;
18
+ /** Raw-text response for `allWords` parsing. */
10
19
  ocr?: Ocr;
20
+ /**
21
+ *
22
+ * @param inferenceClass constructor signature for an inference.
23
+ * @param httpResponse raw http response.
24
+ */
11
25
  constructor(inferenceClass: new (httpResponse: StringDict) => T, httpResponse: StringDict);
26
+ /**
27
+ * Default string representation.
28
+ */
12
29
  toString(): string;
13
30
  }
@@ -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 {};