mindee 4.1.0 → 4.2.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 (63) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +4 -1
  3. package/package.json +1 -1
  4. package/src/client.d.ts +9 -0
  5. package/src/client.js +7 -2
  6. package/src/http/error.d.ts +1 -1
  7. package/src/http/error.js +2 -2
  8. package/src/parsing/common/document.js +2 -1
  9. package/src/parsing/common/inference.js +1 -2
  10. package/src/parsing/standard/base.d.ts +2 -2
  11. package/src/parsing/standard/base.js +2 -2
  12. package/src/parsing/standard/field.d.ts +10 -10
  13. package/src/parsing/standard/field.js +10 -10
  14. package/src/parsing/standard/position.js +12 -1
  15. package/src/product/barcodeReader/barcodeReaderV1.d.ts +16 -0
  16. package/src/product/barcodeReader/barcodeReaderV1.js +22 -0
  17. package/src/product/barcodeReader/barcodeReaderV1Document.d.ts +16 -0
  18. package/src/product/barcodeReader/barcodeReaderV1Document.js +37 -0
  19. package/src/product/barcodeReader/internal.d.ts +2 -0
  20. package/src/product/barcodeReader/internal.js +7 -0
  21. package/src/product/cropper/cropperV1.d.ts +4 -3
  22. package/src/product/cropper/cropperV1.js +4 -3
  23. package/src/product/cropper/cropperV1Document.d.ts +2 -6
  24. package/src/product/cropper/cropperV1Document.js +2 -19
  25. package/src/product/cropper/cropperV1Page.d.ts +12 -0
  26. package/src/product/cropper/cropperV1Page.js +26 -0
  27. package/src/product/cropper/internal.d.ts +1 -0
  28. package/src/product/cropper/internal.js +3 -1
  29. package/src/product/fr/carteVitale/carteVitaleV1Document.js +1 -1
  30. package/src/product/fr/idCard/idCardV1Document.js +1 -1
  31. package/src/product/fr/idCard/idCardV2.d.ts +17 -0
  32. package/src/product/fr/idCard/idCardV2.js +23 -0
  33. package/src/product/fr/idCard/idCardV2Document.d.ts +42 -0
  34. package/src/product/fr/idCard/idCardV2Document.js +98 -0
  35. package/src/product/fr/idCard/idCardV2Page.d.ts +14 -0
  36. package/src/product/fr/idCard/idCardV2Page.js +27 -0
  37. package/src/product/fr/idCard/internal.d.ts +1 -0
  38. package/src/product/fr/idCard/internal.js +3 -1
  39. package/src/product/fr/index.d.ts +1 -0
  40. package/src/product/fr/index.js +3 -1
  41. package/src/product/index.d.ts +8 -6
  42. package/src/product/index.js +16 -12
  43. package/src/product/internal.d.ts +2 -0
  44. package/src/product/internal.js +3 -1
  45. package/src/product/multiReceiptsDetector/internal.d.ts +2 -0
  46. package/src/product/multiReceiptsDetector/internal.js +7 -0
  47. package/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.d.ts +16 -0
  48. package/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.js +22 -0
  49. package/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.d.ts +14 -0
  50. package/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.js +28 -0
  51. package/src/product/passport/passportV1Document.js +1 -1
  52. package/src/product/proofOfAddress/proofOfAddressV1Document.js +2 -2
  53. package/src/product/us/bankCheck/bankCheckV1Page.js +1 -1
  54. package/src/product/us/index.d.ts +1 -0
  55. package/src/product/us/index.js +3 -1
  56. package/src/product/us/w9/internal.d.ts +3 -0
  57. package/src/product/us/w9/internal.js +9 -0
  58. package/src/product/us/w9/w9V1.d.ts +17 -0
  59. package/src/product/us/w9/w9V1.js +23 -0
  60. package/src/product/us/w9/w9V1Document.d.ts +10 -0
  61. package/src/product/us/w9/w9V1Document.js +15 -0
  62. package/src/product/us/w9/w9V1Page.d.ts +34 -0
  63. package/src/product/us/w9/w9V1Page.js +78 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.2.0 - 2023-09-15
4
+ ### Changes
5
+ * :sparkles: add support for W9 V1
6
+ * :sparkles: add support for Barcode Reader V11
7
+ * :sparkles: add support for Multi Receipt Detector V1
8
+ * :sparkles: add support for FR Id Card V2
9
+ * :sparkles: add support for OTS Cropper V1
10
+ * :memo: update documentation
11
+
12
+ ### Fixes
13
+ * :bug: fix missing position field display issues
14
+ * :bug: fix issues with asynchronous timeouts crashing in some instances
15
+
16
+
17
+ ## v4.1.1 - 2023-09-04
18
+ ### Changes
19
+ * :recycle: tweaked timer management in async
20
+
21
+ ### Fixes
22
+ * :bug: fix ocr option not being generated as an Ocr object
23
+
24
+
3
25
  ## v4.1.0 - 2023-08-31
4
26
  ### Changes
5
27
  * :boom: remove support for node versions <16
package/README.md CHANGED
@@ -155,9 +155,12 @@ Complete details on the working of the library are available in the following gu
155
155
  * [Node.js FR Carte Vitale OCR](https://developers.mindee.com/docs/nodejs-fr-carte-vitale-ocr)
156
156
  * [Node.js FR ID Card OCR](https://developers.mindee.com/docs/nodejs-fr-id-card-ocr)
157
157
  * [Node.js US Bank Check OCR](https://developers.mindee.com/docs/nodejs-us-bank-checks-ocr)
158
- * [Node.js US Driver License OCR](https://developers.mindee.com/docs/nodejs-us-driver-license-ocr)
158
+ * [Node.js US W9 OCR](https://developers.mindee.com/docs/nodejs-us-driver-license-ocr)
159
+ * [Node.js US Driver License OCR](https://developers.mindee.com/docs/nodejs-us-w9-ocr)
160
+ * [Node.js Barcode Reader API](https://developers.mindee.com/docs/nodejs-barcode-reader-api)
159
161
  * [Node.js Cropper API](https://developers.mindee.com/docs/nodejs-cropper-api)
160
162
  * [Node.js Invoice Splitter API](https://developers.mindee.com/docs/nodejs-invoice-splitter-api)
163
+ * [Node.js Multi Receipts Detector API](https://developers.mindee.com/docs/nodejs-multi-receipts-detector-api)
161
164
 
162
165
  You can also take a look at the **[Reference Documentation](https://mindee.github.io/mindee-api-nodejs/)**.
163
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import { Readable } from "stream";
4
5
  import { InputSource, PageOptions } from "./input";
5
6
  import { Endpoint } from "./http";
@@ -35,6 +36,14 @@ export interface AsyncOptions extends PredictOptions {
35
36
  initialDelaySec: number;
36
37
  delaySec: number;
37
38
  maxRetries: number;
39
+ initialTimerOptions?: {
40
+ ref?: boolean;
41
+ signal?: AbortSignal;
42
+ };
43
+ recurringTimerOptions?: {
44
+ ref?: boolean;
45
+ signal?: AbortSignal;
46
+ };
38
47
  }
39
48
  export interface ClientOptions {
40
49
  /** Your API key for all endpoints. */
package/src/client.js CHANGED
@@ -122,6 +122,8 @@ class Client {
122
122
  initialDelaySec: 6,
123
123
  delaySec: 3,
124
124
  maxRetries: 10,
125
+ initialTimerOptions: undefined,
126
+ recurringTimerOptions: undefined,
125
127
  }) {
126
128
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_validateAsyncParams).call(this, asyncParams);
127
129
  const enqueueResponse = await this.enqueue(productClass, inputSource, asyncParams);
@@ -130,7 +132,7 @@ class Client {
130
132
  }
131
133
  const queueId = enqueueResponse.job.id;
132
134
  logger_1.logger.debug(`Successfully enqueued document with job id: ${queueId}.`);
133
- await (0, promises_1.setTimeout)(asyncParams.initialDelaySec * 1000);
135
+ await (0, promises_1.setTimeout)(asyncParams.initialDelaySec * 1000, undefined, asyncParams.initialTimerOptions);
134
136
  let retryCounter = 1;
135
137
  let pollResults;
136
138
  pollResults = await this.parseQueued(productClass, queueId, asyncParams);
@@ -141,7 +143,7 @@ Job status: ${pollResults.job.status}.`);
141
143
  if (pollResults.job.status === "completed") {
142
144
  break;
143
145
  }
144
- await (0, promises_1.setTimeout)(asyncParams.delaySec * 1000);
146
+ await (0, promises_1.setTimeout)(asyncParams.delaySec * 1000, undefined, asyncParams.recurringTimerOptions);
145
147
  pollResults = await this.parseQueued(productClass, queueId, asyncParams);
146
148
  retryCounter++;
147
149
  }
@@ -248,6 +250,9 @@ Job status: ${pollResults.job.status}.`);
248
250
  }
249
251
  exports.Client = Client;
250
252
  _Client_instances = new WeakSet(), _Client_validateAsyncParams = function _Client_validateAsyncParams(asyncParams) {
253
+ asyncParams.delaySec ?? (asyncParams.delaySec = 3);
254
+ asyncParams.initialDelaySec ?? (asyncParams.initialDelaySec = 6);
255
+ asyncParams.maxRetries ?? (asyncParams.maxRetries = 10);
251
256
  if (asyncParams.delaySec < 2) {
252
257
  throw Error("Cannot set auto-parsing delay to less than 2 seconds.");
253
258
  }
@@ -46,7 +46,7 @@ export declare class MindeeHttp413Error extends MindeeHttpError {
46
46
  constructor(httpError: StringDict, url: string, code?: number);
47
47
  }
48
48
  /**
49
- * Usually contains TooManyRequests errors.
49
+ * Usually corresponds to TooManyRequests errors.
50
50
  * Arises whenever too many calls to the API are made in quick succession.
51
51
  */
52
52
  export declare class MindeeHttp429Error extends MindeeHttpError {
package/src/http/error.js CHANGED
@@ -168,7 +168,7 @@ class MindeeHttp413Error extends MindeeHttpError {
168
168
  }
169
169
  exports.MindeeHttp413Error = MindeeHttp413Error;
170
170
  /**
171
- * Usually contains TooManyRequests errors.
171
+ * Usually corresponds to TooManyRequests errors.
172
172
  * Arises whenever too many calls to the API are made in quick succession.
173
173
  */
174
174
  class MindeeHttp429Error extends MindeeHttpError {
@@ -195,7 +195,7 @@ exports.MindeeHttp500Error = MindeeHttp500Error;
195
195
  class MindeeHttp504Error extends MindeeHttpError {
196
196
  constructor(httpError, url, code) {
197
197
  super(httpError, url, code);
198
- this.name = "MindeeHttp500Error";
198
+ this.name = "MindeeHttp504Error";
199
199
  }
200
200
  }
201
201
  exports.MindeeHttp504Error = MindeeHttp504Error;
@@ -3,6 +3,7 @@ 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
+ const ocr_1 = require("./ocr");
6
7
  /**
7
8
  * Document prediction wrapper class. Holds the results of a parsed document.
8
9
  * @typeParam T an extension of an `Inference`. Mandatory in order to properly create an inference.
@@ -16,7 +17,7 @@ class Document {
16
17
  constructor(inferenceClass, httpResponse) {
17
18
  this.id = httpResponse?.id ?? "";
18
19
  this.filename = httpResponse?.name ?? "";
19
- this.ocr = httpResponse?.ocr ?? undefined;
20
+ this.ocr = httpResponse.ocr && Object.keys(httpResponse.ocr).length > 0 ? new ocr_1.Ocr(httpResponse.ocr) : undefined;
20
21
  this.inference = new inferenceClass(httpResponse["inference"]);
21
22
  // Note: this is a convoluted but functional way of being able to implement/use Extras fields
22
23
  // as an extension of a Map object (like having an adapted toString() method, for instance).
@@ -28,8 +28,7 @@ class Inference {
28
28
 
29
29
  Prediction
30
30
  ==========
31
- ${this.prediction.toString() || ""}
32
-
31
+ ${this.prediction.toString().length === 0 ? "" : this.prediction.toString() + "\n"}
33
32
  Page Predictions
34
33
  ================
35
34
 
@@ -16,8 +16,8 @@ export declare class BaseField {
16
16
  pageId?: number;
17
17
  /**
18
18
  * @param {Object} prediction - Prediction object from HTTP response
19
- * @param {String} valueKey - Key to use in the prediction dict
20
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
19
+ * @param valueKey - Key to use in the prediction dict
20
+ * @param reconstructed - Is the object reconstructed (not extracted by the API)
21
21
  */
22
22
  constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
23
23
  compare(other: BaseField): boolean;
@@ -7,8 +7,8 @@ exports.BaseField = void 0;
7
7
  class BaseField {
8
8
  /**
9
9
  * @param {Object} prediction - Prediction object from HTTP response
10
- * @param {String} valueKey - Key to use in the prediction dict
11
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
10
+ * @param valueKey - Key to use in the prediction dict
11
+ * @param reconstructed - Is the object reconstructed (not extracted by the API)
12
12
  */
13
13
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
14
14
  /** The value. */
@@ -24,23 +24,23 @@ export declare class Field extends BaseField {
24
24
  /** The confidence score of the prediction. */
25
25
  confidence: number;
26
26
  /**
27
- * @param {Object} prediction - Prediction object from HTTP response
28
- * @param {String} valueKey - Key to use in the prediction dict
29
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
30
- * @param {Integer} pageId - Page ID for multi-page document
31
- * @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
27
+ * @param prediction - Prediction object from HTTP response
28
+ * @param valueKey - Key to use in the prediction dict
29
+ * @param reconstructed - Does the object is reconstructed (not extracted by the API)
30
+ * @param pageId - Page ID for multi-page document
31
+ * @param extraFields - Extra fields to get from the prediction and to set as attribute of the Field
32
32
  */
33
33
  constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
34
34
  /**
35
- @param {Field[]} array1 - first Array of Fields
36
- @param {Field[]} array2 - second Array of Fields
37
- @param {String} attr - Attribute to compare
38
- @returns {Boolean} - true if all elements in array1 exist in array2 and vice-versa, false otherwise
35
+ @param array1 first Array of Fields
36
+ @param array2 second Array of Fields
37
+ @param attr Attribute to compare
38
+ @returns true if all elements in array1 exist in array2 and vice-versa, false otherwise
39
39
  */
40
40
  static compareArrays(array1: Field[], array2: Field[], attr?: string): boolean;
41
41
  /**
42
42
  * @param {Field[]} array - Array of Fields
43
- * @returns {Number} product of all the fields probaility
43
+ * @returns {Number} product of all the fields probability
44
44
  */
45
45
  static arrayConfidence(array: Field[]): number;
46
46
  }
@@ -8,11 +8,11 @@ const geometry_1 = require("../../geometry");
8
8
  */
9
9
  class Field extends base_1.BaseField {
10
10
  /**
11
- * @param {Object} prediction - Prediction object from HTTP response
12
- * @param {String} valueKey - Key to use in the prediction dict
13
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
14
- * @param {Integer} pageId - Page ID for multi-page document
15
- * @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
11
+ * @param prediction - Prediction object from HTTP response
12
+ * @param valueKey - Key to use in the prediction dict
13
+ * @param reconstructed - Does the object is reconstructed (not extracted by the API)
14
+ * @param pageId - Page ID for multi-page document
15
+ * @param extraFields - Extra fields to get from the prediction and to set as attribute of the Field
16
16
  */
17
17
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
18
18
  super({ prediction, valueKey, reconstructed, pageId });
@@ -28,10 +28,10 @@ class Field extends base_1.BaseField {
28
28
  this.boundingBox = (0, geometry_1.getBoundingBox)(this.polygon);
29
29
  }
30
30
  /**
31
- @param {Field[]} array1 - first Array of Fields
32
- @param {Field[]} array2 - second Array of Fields
33
- @param {String} attr - Attribute to compare
34
- @returns {Boolean} - true if all elements in array1 exist in array2 and vice-versa, false otherwise
31
+ @param array1 first Array of Fields
32
+ @param array2 second Array of Fields
33
+ @param attr Attribute to compare
34
+ @returns true if all elements in array1 exist in array2 and vice-versa, false otherwise
35
35
  */
36
36
  static compareArrays(array1, array2, attr = "value") {
37
37
  const list1 = array1.map((item) => item[attr]);
@@ -46,7 +46,7 @@ class Field extends base_1.BaseField {
46
46
  }
47
47
  /**
48
48
  * @param {Field[]} array - Array of Fields
49
- * @returns {Number} product of all the fields probaility
49
+ * @returns {Number} product of all the fields probability
50
50
  */
51
51
  static arrayConfidence(array) {
52
52
  let total = 1.0;
@@ -16,7 +16,18 @@ class PositionField {
16
16
  * Default string representation.
17
17
  */
18
18
  toString() {
19
- return `Polygon with ${this.polygon.length} points.`;
19
+ if (this.polygon && this.polygon.length > 0)
20
+ return `Polygon with ${this.polygon.length} points.`;
21
+ if (this.boundingBox && this.boundingBox.length > 0) {
22
+ return `Polygon with ${this.boundingBox.length} points.`;
23
+ }
24
+ if (this.rectangle && this.rectangle.length > 0) {
25
+ return `Polygon with ${this.rectangle.length} points.`;
26
+ }
27
+ if (this.quadrangle && this.quadrangle.length > 0) {
28
+ return `Polygon with ${this.quadrangle.length} points.`;
29
+ }
30
+ return "";
20
31
  }
21
32
  }
22
33
  exports.PositionField = PositionField;
@@ -0,0 +1,16 @@
1
+ import { Inference, StringDict, Page } from "../../parsing/common";
2
+ import { BarcodeReaderV1Document } from "./barcodeReaderV1Document";
3
+ /**
4
+ * Inference prediction for Barcode Reader, API version 1.
5
+ */
6
+ export declare class BarcodeReaderV1 extends Inference {
7
+ /** The endpoint's name. */
8
+ endpointName: string;
9
+ /** The endpoint's version. */
10
+ endpointVersion: string;
11
+ /** The document-level prediction. */
12
+ prediction: BarcodeReaderV1Document;
13
+ /** The document's pages. */
14
+ pages: Page<BarcodeReaderV1Document>[];
15
+ constructor(rawPrediction: StringDict);
16
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BarcodeReaderV1 = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const barcodeReaderV1Document_1 = require("./barcodeReaderV1Document");
6
+ /**
7
+ * Inference prediction for Barcode Reader, API version 1.
8
+ */
9
+ class BarcodeReaderV1 extends common_1.Inference {
10
+ constructor(rawPrediction) {
11
+ super(rawPrediction);
12
+ /** The endpoint's name. */
13
+ this.endpointName = "barcode_reader";
14
+ /** The endpoint's version. */
15
+ this.endpointVersion = "1";
16
+ /** The document's pages. */
17
+ this.pages = [];
18
+ this.prediction = new barcodeReaderV1Document_1.BarcodeReaderV1Document(rawPrediction["prediction"]);
19
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(barcodeReaderV1Document_1.BarcodeReaderV1Document, page, page["id"], page["orientation"]));
20
+ }
21
+ }
22
+ exports.BarcodeReaderV1 = BarcodeReaderV1;
@@ -0,0 +1,16 @@
1
+ import { Prediction, StringDict } from "../../parsing/common";
2
+ import { StringField } from "../../parsing/standard";
3
+ /**
4
+ * Document data for Barcode Reader, API version 1.
5
+ */
6
+ export declare class BarcodeReaderV1Document implements Prediction {
7
+ /** List of decoded 1D barcodes. */
8
+ codes1D: StringField[];
9
+ /** List of decoded 2D barcodes. */
10
+ codes2D: StringField[];
11
+ constructor(rawPrediction: StringDict, pageId?: number);
12
+ /**
13
+ * Default string representation.
14
+ */
15
+ toString(): string;
16
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BarcodeReaderV1Document = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const standard_1 = require("../../parsing/standard");
6
+ /**
7
+ * Document data for Barcode Reader, API version 1.
8
+ */
9
+ class BarcodeReaderV1Document {
10
+ constructor(rawPrediction, pageId) {
11
+ /** List of decoded 1D barcodes. */
12
+ this.codes1D = [];
13
+ /** List of decoded 2D barcodes. */
14
+ this.codes2D = [];
15
+ rawPrediction["codes_1d"] &&
16
+ rawPrediction["codes_1d"].map((itemPrediction) => this.codes1D.push(new standard_1.StringField({
17
+ prediction: itemPrediction,
18
+ pageId: pageId,
19
+ })));
20
+ rawPrediction["codes_2d"] &&
21
+ rawPrediction["codes_2d"].map((itemPrediction) => this.codes2D.push(new standard_1.StringField({
22
+ prediction: itemPrediction,
23
+ pageId: pageId,
24
+ })));
25
+ }
26
+ /**
27
+ * Default string representation.
28
+ */
29
+ toString() {
30
+ const codes1D = this.codes1D.join("\n ");
31
+ const codes2D = this.codes2D.join("\n ");
32
+ const outStr = `:Barcodes 1D: ${codes1D}
33
+ :Barcodes 2D: ${codes2D}`.trimEnd();
34
+ return (0, common_1.cleanOutString)(outStr);
35
+ }
36
+ }
37
+ exports.BarcodeReaderV1Document = BarcodeReaderV1Document;
@@ -0,0 +1,2 @@
1
+ export { BarcodeReaderV1 } from "./barcodeReaderV1";
2
+ export { BarcodeReaderV1Document } from "./barcodeReaderV1Document";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BarcodeReaderV1Document = exports.BarcodeReaderV1 = void 0;
4
+ var barcodeReaderV1_1 = require("./barcodeReaderV1");
5
+ Object.defineProperty(exports, "BarcodeReaderV1", { enumerable: true, get: function () { return barcodeReaderV1_1.BarcodeReaderV1; } });
6
+ var barcodeReaderV1Document_1 = require("./barcodeReaderV1Document");
7
+ Object.defineProperty(exports, "BarcodeReaderV1Document", { enumerable: true, get: function () { return barcodeReaderV1Document_1.BarcodeReaderV1Document; } });
@@ -1,7 +1,8 @@
1
- import { Inference, Page, StringDict } from "../../parsing/common";
1
+ import { Inference, StringDict, Page } from "../../parsing/common";
2
2
  import { CropperV1Document } from "./cropperV1Document";
3
+ import { CropperV1Page } from "./cropperV1Page";
3
4
  /**
4
- * Inference prediction for Cropper API, version 1.
5
+ * Inference prediction for Cropper, API version 1.
5
6
  */
6
7
  export declare class CropperV1 extends Inference {
7
8
  /** The endpoint's name. */
@@ -11,6 +12,6 @@ export declare class CropperV1 extends Inference {
11
12
  /** The document-level prediction. */
12
13
  prediction: CropperV1Document;
13
14
  /** The document's pages. */
14
- pages: Page<CropperV1Document>[];
15
+ pages: Page<CropperV1Page>[];
15
16
  constructor(rawPrediction: StringDict);
16
17
  }
@@ -3,8 +3,9 @@ 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
+ const cropperV1Page_1 = require("./cropperV1Page");
6
7
  /**
7
- * Inference prediction for Cropper API, version 1.
8
+ * Inference prediction for Cropper, API version 1.
8
9
  */
9
10
  class CropperV1 extends common_1.Inference {
10
11
  constructor(rawPrediction) {
@@ -15,8 +16,8 @@ class CropperV1 extends common_1.Inference {
15
16
  this.endpointVersion = "1";
16
17
  /** The document's pages. */
17
18
  this.pages = [];
18
- this.prediction = new cropperV1Document_1.CropperV1Document(rawPrediction["prediction"]);
19
- this.pages = rawPrediction["pages"].map((page) => new common_1.Page(cropperV1Document_1.CropperV1Document, page, page["id"], page["orientation"]));
19
+ this.prediction = new cropperV1Document_1.CropperV1Document();
20
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(cropperV1Page_1.CropperV1Page, page, page["id"], page["orientation"]));
20
21
  }
21
22
  }
22
23
  exports.CropperV1 = CropperV1;
@@ -1,12 +1,8 @@
1
- import { Prediction, StringDict } from "../../parsing/common";
2
- import { PositionField } from "../../parsing/standard";
1
+ import { Prediction } from "../../parsing/common";
3
2
  /**
4
- * Document data for Cropper API, version 1.
3
+ * Document data for Cropper, API version 1.
5
4
  */
6
5
  export declare class CropperV1Document implements Prediction {
7
- /** A list of cropped positions. */
8
- cropping: PositionField[];
9
- constructor(rawPrediction: StringDict, pageId?: number);
10
6
  /**
11
7
  * Default string representation.
12
8
  */
@@ -1,32 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CropperV1Document = void 0;
4
- const summaryHelper_1 = require("../../parsing/common/summaryHelper");
5
- const standard_1 = require("../../parsing/standard");
6
4
  /**
7
- * Document data for Cropper API, version 1.
5
+ * Document data for Cropper, API version 1.
8
6
  */
9
7
  class CropperV1Document {
10
- constructor(rawPrediction, pageId) {
11
- /** A list of cropped positions. */
12
- this.cropping = [];
13
- rawPrediction["cropping"] &&
14
- rawPrediction["cropping"].forEach((crop) => {
15
- this.cropping.push(new standard_1.PositionField({
16
- prediction: crop,
17
- pageId: pageId,
18
- }));
19
- });
20
- }
21
8
  /**
22
9
  * Default string representation.
23
10
  */
24
11
  toString() {
25
- const cropping = this.cropping
26
- .map((crop) => crop.toString())
27
- .join("\n ");
28
- const outStr = `:Cropping: ${cropping}`.trim();
29
- return (0, summaryHelper_1.cleanOutString)(outStr);
12
+ return "";
30
13
  }
31
14
  }
32
15
  exports.CropperV1Document = CropperV1Document;
@@ -0,0 +1,12 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { PositionField } from "../../parsing/standard";
3
+ import { CropperV1Document } from "./cropperV1Document";
4
+ /**
5
+ * Page data for Cropper, API version 1.
6
+ */
7
+ export declare class CropperV1Page extends CropperV1Document {
8
+ /** List of documents found in the image. */
9
+ cropping: PositionField[];
10
+ constructor(rawPrediction: StringDict, pageId?: number);
11
+ toString(): string;
12
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CropperV1Page = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const standard_1 = require("../../parsing/standard");
6
+ const cropperV1Document_1 = require("./cropperV1Document");
7
+ /**
8
+ * Page data for Cropper, API version 1.
9
+ */
10
+ class CropperV1Page extends cropperV1Document_1.CropperV1Document {
11
+ constructor(rawPrediction, pageId) {
12
+ super();
13
+ /** List of documents found in the image. */
14
+ this.cropping = [];
15
+ rawPrediction["cropping"].map((itemPrediction) => this.cropping.push(new standard_1.PositionField({
16
+ prediction: itemPrediction,
17
+ pageId: pageId,
18
+ })));
19
+ }
20
+ toString() {
21
+ const cropping = this.cropping.join("\n ");
22
+ const outStr = `:Document Cropper: ${cropping}`.trimEnd();
23
+ return (0, common_1.cleanOutString)(outStr);
24
+ }
25
+ }
26
+ exports.CropperV1Page = CropperV1Page;
@@ -1,2 +1,3 @@
1
1
  export { CropperV1 } from "./cropperV1";
2
2
  export { CropperV1Document } from "./cropperV1Document";
3
+ export { CropperV1Page } from "./cropperV1Page";
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CropperV1Document = exports.CropperV1 = void 0;
3
+ exports.CropperV1Page = exports.CropperV1Document = exports.CropperV1 = void 0;
4
4
  var cropperV1_1 = require("./cropperV1");
5
5
  Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return cropperV1_1.CropperV1; } });
6
6
  var cropperV1Document_1 = require("./cropperV1Document");
7
7
  Object.defineProperty(exports, "CropperV1Document", { enumerable: true, get: function () { return cropperV1Document_1.CropperV1Document; } });
8
+ var cropperV1Page_1 = require("./cropperV1Page");
9
+ Object.defineProperty(exports, "CropperV1Page", { enumerable: true, get: function () { return cropperV1Page_1.CropperV1Page; } });
@@ -32,7 +32,7 @@ class CarteVitaleV1Document {
32
32
  * Default string representation.
33
33
  */
34
34
  toString() {
35
- const givenNames = this.givenNames.join("\n ");
35
+ const givenNames = this.givenNames.join("\n ");
36
36
  const outStr = `:Given Name(s): ${givenNames}
37
37
  :Surname: ${this.surname}
38
38
  :Social Security Number: ${this.socialSecurity}
@@ -56,7 +56,7 @@ class IdCardV1Document {
56
56
  * Default string representation.
57
57
  */
58
58
  toString() {
59
- const givenNames = this.givenNames.join("\n ");
59
+ const givenNames = this.givenNames.join("\n ");
60
60
  const outStr = `:Identity Number: ${this.idNumber}
61
61
  :Given Name(s): ${givenNames}
62
62
  :Surname: ${this.surname}
@@ -0,0 +1,17 @@
1
+ import { Inference, StringDict, Page } from "../../../parsing/common";
2
+ import { IdCardV2Document } from "./idCardV2Document";
3
+ import { IdCardV2Page } from "./idCardV2Page";
4
+ /**
5
+ * Inference prediction for Carte Nationale d'Identité, API version 2.
6
+ */
7
+ export declare class IdCardV2 extends Inference {
8
+ /** The endpoint's name. */
9
+ endpointName: string;
10
+ /** The endpoint's version. */
11
+ endpointVersion: string;
12
+ /** The document-level prediction. */
13
+ prediction: IdCardV2Document;
14
+ /** The document's pages. */
15
+ pages: Page<IdCardV2Page>[];
16
+ constructor(rawPrediction: StringDict);
17
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdCardV2 = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const idCardV2Document_1 = require("./idCardV2Document");
6
+ const idCardV2Page_1 = require("./idCardV2Page");
7
+ /**
8
+ * Inference prediction for Carte Nationale d'Identité, API version 2.
9
+ */
10
+ class IdCardV2 extends common_1.Inference {
11
+ constructor(rawPrediction) {
12
+ super(rawPrediction);
13
+ /** The endpoint's name. */
14
+ this.endpointName = "idcard_fr";
15
+ /** The endpoint's version. */
16
+ this.endpointVersion = "2";
17
+ /** The document's pages. */
18
+ this.pages = [];
19
+ this.prediction = new idCardV2Document_1.IdCardV2Document(rawPrediction["prediction"]);
20
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(idCardV2Page_1.IdCardV2Page, page, page["id"], page["orientation"]));
21
+ }
22
+ }
23
+ exports.IdCardV2 = IdCardV2;