mindee 4.3.2 → 4.4.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 (75) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +4 -3
  3. package/src/cli.js +52 -16
  4. package/src/client.d.ts +35 -6
  5. package/src/client.js +47 -16
  6. package/src/http/apiSettings.d.ts +15 -0
  7. package/src/http/{mindeeApi.js → apiSettings.js} +10 -13
  8. package/src/http/baseEndpoint.d.ts +27 -0
  9. package/src/http/baseEndpoint.js +65 -0
  10. package/src/http/endpoint.d.ts +27 -38
  11. package/src/http/endpoint.js +46 -60
  12. package/src/http/error.d.ts +11 -11
  13. package/src/http/error.js +29 -29
  14. package/src/http/index.d.ts +3 -2
  15. package/src/http/index.js +5 -5
  16. package/src/input/base.d.ts +7 -6
  17. package/src/input/base.js +1 -4
  18. package/src/parsing/common/apiResponse.d.ts +1 -1
  19. package/src/parsing/common/apiResponse.js +1 -1
  20. package/src/parsing/common/asyncPredictResponse.d.ts +4 -4
  21. package/src/parsing/common/asyncPredictResponse.js +8 -8
  22. package/src/parsing/common/document.d.ts +2 -0
  23. package/src/parsing/common/document.js +1 -0
  24. package/src/parsing/common/feedback/feedbackResponse.d.ts +15 -0
  25. package/src/parsing/common/feedback/feedbackResponse.js +19 -0
  26. package/src/parsing/common/index.d.ts +1 -0
  27. package/src/parsing/common/index.js +3 -1
  28. package/src/parsing/common/inference.js +9 -5
  29. package/src/parsing/common/orientation.d.ts +1 -4
  30. package/src/parsing/common/orientation.js +1 -4
  31. package/src/parsing/common/page.d.ts +2 -3
  32. package/src/parsing/common/page.js +2 -3
  33. package/src/parsing/common/predictResponse.d.ts +3 -3
  34. package/src/parsing/common/predictResponse.js +5 -5
  35. package/src/parsing/custom/listField.d.ts +8 -5
  36. package/src/parsing/custom/listField.js +11 -3
  37. package/src/parsing/standard/amount.d.ts +4 -6
  38. package/src/parsing/standard/amount.js +1 -4
  39. package/src/parsing/standard/base.d.ts +9 -4
  40. package/src/parsing/standard/base.js +2 -4
  41. package/src/parsing/standard/companyRegistration.d.ts +3 -2
  42. package/src/parsing/standard/date.d.ts +4 -6
  43. package/src/parsing/standard/date.js +1 -4
  44. package/src/parsing/standard/field.d.ts +4 -15
  45. package/src/parsing/standard/field.js +2 -6
  46. package/src/parsing/standard/index.d.ts +1 -1
  47. package/src/parsing/standard/locale.d.ts +1 -3
  48. package/src/parsing/standard/locale.js +1 -3
  49. package/src/parsing/standard/paymentDetails.d.ts +11 -8
  50. package/src/parsing/standard/paymentDetails.js +1 -8
  51. package/src/parsing/standard/position.js +4 -4
  52. package/src/parsing/standard/tax.d.ts +8 -12
  53. package/src/parsing/standard/tax.js +1 -7
  54. package/src/product/financialDocument/financialDocumentV1Document.js +2 -2
  55. package/src/product/fr/carteGrise/carteGriseV1.d.ts +16 -0
  56. package/src/product/fr/carteGrise/carteGriseV1.js +22 -0
  57. package/src/product/fr/carteGrise/carteGriseV1Document.d.ts +94 -0
  58. package/src/product/fr/carteGrise/carteGriseV1Document.js +224 -0
  59. package/src/product/fr/carteGrise/internal.d.ts +2 -0
  60. package/src/product/fr/carteGrise/internal.js +7 -0
  61. package/src/product/fr/index.d.ts +1 -0
  62. package/src/product/fr/index.js +3 -1
  63. package/src/product/fr/internal.d.ts +1 -0
  64. package/src/product/fr/internal.js +2 -1
  65. package/src/product/invoice/invoiceV4Document.d.ts +33 -32
  66. package/src/product/invoice/invoiceV4Document.js +89 -104
  67. package/src/product/invoice/invoiceV4LineItem.d.ts +16 -16
  68. package/src/product/invoice/invoiceV4LineItem.js +58 -60
  69. package/src/product/us/w9/w9V1.d.ts +1 -1
  70. package/src/product/us/w9/w9V1.js +1 -1
  71. package/src/product/us/w9/w9V1Document.d.ts +1 -1
  72. package/src/product/us/w9/w9V1Document.js +1 -1
  73. package/src/product/us/w9/w9V1Page.d.ts +1 -1
  74. package/src/product/us/w9/w9V1Page.js +1 -1
  75. package/src/http/mindeeApi.d.ts +0 -20
@@ -7,10 +7,7 @@ const standard_1 = require("../standard");
7
7
  */
8
8
  class OrientationField extends standard_1.BaseField {
9
9
  /**
10
- * @param {Object} prediction - Prediction object from HTTP response
11
- * @param {String} valueKey - Key to use in the prediction dict
12
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
13
- * @param {Integer} pageId - Page ID for multi-page document
10
+ * @param {OrientationFieldConstructor} constructor Constructor parameters.
14
11
  */
15
12
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
16
13
  super({ prediction, valueKey, reconstructed });
@@ -17,9 +17,8 @@ export declare class Page<T extends Prediction> {
17
17
  /** Potential `Extras` fields sent back along with the prediction. */
18
18
  extras?: Extras;
19
19
  /**
20
- *
21
- * @param inferenceClass constructor signature for an inference.
22
- * @param httpResponse raw http response.
20
+ * @param predictionType constructor signature for an inference.
21
+ * @param rawPrediction raw http response.
23
22
  * @param pageId the page's index (identifier).
24
23
  * @param orientation the page's orientation.
25
24
  */
@@ -11,9 +11,8 @@ const orientation_1 = require("./orientation");
11
11
  */
12
12
  class Page {
13
13
  /**
14
- *
15
- * @param inferenceClass constructor signature for an inference.
16
- * @param httpResponse raw http response.
14
+ * @param predictionType constructor signature for an inference.
15
+ * @param rawPrediction raw http response.
17
16
  * @param pageId the page's index (identifier).
18
17
  * @param orientation the page's orientation.
19
18
  */
@@ -4,14 +4,14 @@ import { Document, Inference, StringDict } from ".";
4
4
  *
5
5
  * @category API Response
6
6
  * @category Synchronous
7
- */
7
+ */
8
8
  export declare class PredictResponse<T extends Inference> extends ApiResponse {
9
9
  /** A document prediction response. */
10
10
  document: Document<T>;
11
11
  /**
12
12
  *
13
13
  * @param inferenceClass constructor signature for an inference.
14
- * @param rawPrediction raw http response.
14
+ * @param serverResponse raw http response.
15
15
  */
16
- constructor(inferenceClass: new (rawPrediction: StringDict) => T, rawPrediction: StringDict);
16
+ constructor(inferenceClass: new (serverResponse: StringDict) => T, serverResponse: StringDict);
17
17
  }
@@ -7,16 +7,16 @@ const _1 = require(".");
7
7
  *
8
8
  * @category API Response
9
9
  * @category Synchronous
10
- */
10
+ */
11
11
  class PredictResponse extends apiResponse_1.ApiResponse {
12
12
  /**
13
13
  *
14
14
  * @param inferenceClass constructor signature for an inference.
15
- * @param rawPrediction raw http response.
15
+ * @param serverResponse raw http response.
16
16
  */
17
- constructor(inferenceClass, rawPrediction) {
18
- super(rawPrediction);
19
- this.document = new _1.Document(inferenceClass, rawPrediction["document"]);
17
+ constructor(inferenceClass, serverResponse) {
18
+ super(serverResponse);
19
+ this.document = new _1.Document(inferenceClass, serverResponse["document"]);
20
20
  }
21
21
  }
22
22
  exports.PredictResponse = PredictResponse;
@@ -1,4 +1,4 @@
1
- import { FieldConstructor } from "../standard";
1
+ import { BaseFieldConstructor } from "../standard";
2
2
  import { Polygon } from "../../geometry";
3
3
  import { StringDict } from "../common";
4
4
  export declare class ListFieldValue {
@@ -19,7 +19,9 @@ export declare class ListFieldValue {
19
19
  * the word in the document.
20
20
  */
21
21
  polygon: Polygon;
22
- constructor(prediction: StringDict);
22
+ /** The document page on which the information was found. */
23
+ pageId?: number;
24
+ constructor(prediction: StringDict, pageId?: number);
23
25
  /**
24
26
  * Default string representation.
25
27
  */
@@ -30,9 +32,10 @@ export declare class ListField {
30
32
  confidence: number;
31
33
  /** True if the field was reconstructed or computed using other fields. */
32
34
  reconstructed: boolean;
33
- /** The document page on which the information was found. */
34
- pageId: number;
35
- constructor({ prediction, reconstructed, pageId, }: FieldConstructor);
35
+ /**
36
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
37
+ */
38
+ constructor({ prediction, reconstructed, pageId, }: BaseFieldConstructor);
36
39
  contentsList(): Array<string | number>;
37
40
  contentsString(separator?: string): string;
38
41
  /**
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ListField = exports.ListFieldValue = void 0;
4
4
  const geometry_1 = require("../../geometry");
5
5
  class ListFieldValue {
6
- constructor(prediction) {
6
+ constructor(prediction, pageId) {
7
7
  /**
8
8
  * Contains exactly 4 relative vertices coordinates (points) of a right
9
9
  * rectangle containing the word in the document.
@@ -20,6 +20,9 @@ class ListFieldValue {
20
20
  this.polygon = prediction["polygon"];
21
21
  this.bbox = (0, geometry_1.getBoundingBox)(prediction["polygon"]);
22
22
  }
23
+ if (pageId !== undefined) {
24
+ this.pageId = pageId;
25
+ }
23
26
  }
24
27
  /**
25
28
  * Default string representation.
@@ -30,14 +33,19 @@ class ListFieldValue {
30
33
  }
31
34
  exports.ListFieldValue = ListFieldValue;
32
35
  class ListField {
36
+ /**
37
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
38
+ */
33
39
  constructor({ prediction = {}, reconstructed = false, pageId, }) {
34
40
  this.values = [];
35
41
  this.confidence = prediction["confidence"];
36
42
  this.reconstructed = reconstructed;
37
- this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
38
43
  if (prediction["values"] !== undefined) {
39
44
  prediction["values"].forEach((field) => {
40
- this.values.push(new ListFieldValue(field));
45
+ if (pageId === undefined) {
46
+ pageId = field["page_id"];
47
+ }
48
+ this.values.push(new ListFieldValue(field, pageId));
41
49
  });
42
50
  }
43
51
  }
@@ -1,4 +1,5 @@
1
- import { Field, FieldConstructor } from "./field";
1
+ import { Field } from "./field";
2
+ import { BaseFieldConstructor } from "./base";
2
3
  export declare function floatToString(value: number): string;
3
4
  /**
4
5
  * A field containing an amount value.
@@ -7,12 +8,9 @@ export declare class AmountField extends Field {
7
8
  /** The value. */
8
9
  value?: number;
9
10
  /**
10
- * @param {Object} prediction - Prediction object from HTTP response
11
- * @param {String} valueKey - Key to use in the prediction dict
12
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
13
- * @param {Integer} pageId - Page ID for multi-page document
11
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
14
12
  */
15
- constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
13
+ constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
16
14
  /**
17
15
  * Default string representation.
18
16
  */
@@ -15,10 +15,7 @@ exports.floatToString = floatToString;
15
15
  */
16
16
  class AmountField extends field_1.Field {
17
17
  /**
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)
21
- * @param {Integer} pageId - Page ID for multi-page document
18
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
22
19
  */
23
20
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
24
21
  super({ prediction, valueKey, reconstructed, pageId });
@@ -1,4 +1,10 @@
1
1
  import { StringDict } from "../common";
2
+ /**
3
+ * @property {object} prediction - Prediction object from HTTP response.
4
+ * @property {string} valueKey - Key to use in the prediction dict.
5
+ * @property {boolean} reconstructed - Is the object reconstructed (not extracted by the API).
6
+ * @property {number} pageId - Page ID for multi-page document.
7
+ */
2
8
  export interface BaseFieldConstructor {
3
9
  prediction: StringDict;
4
10
  valueKey?: string;
@@ -13,17 +19,16 @@ export declare class BaseField {
13
19
  value?: string | number;
14
20
  /** `true` when the field was reconstructed or computed using other fields. */
15
21
  reconstructed: boolean;
22
+ /** Page ID for multi-page document. */
16
23
  pageId?: number;
17
24
  /**
18
- * @param {Object} prediction - Prediction object from HTTP response
19
- * @param valueKey - Key to use in the prediction dict
20
- * @param reconstructed - Is the object reconstructed (not extracted by the API)
25
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
21
26
  */
22
27
  constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
23
28
  compare(other: BaseField): boolean;
24
29
  /**
25
30
  * @param {BaseField[]} array - Array of Fields
26
- * @returns {Number} Sum of all the Fields values in the array
31
+ * @returns {number} Sum of all the Fields values in the array
27
32
  */
28
33
  static arraySum(array: BaseField[]): number;
29
34
  /**
@@ -6,9 +6,7 @@ exports.BaseField = void 0;
6
6
  */
7
7
  class BaseField {
8
8
  /**
9
- * @param {Object} prediction - Prediction object from HTTP response
10
- * @param valueKey - Key to use in the prediction dict
11
- * @param reconstructed - Is the object reconstructed (not extracted by the API)
9
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
12
10
  */
13
11
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId = undefined, }) {
14
12
  /** The value. */
@@ -34,7 +32,7 @@ class BaseField {
34
32
  }
35
33
  /**
36
34
  * @param {BaseField[]} array - Array of Fields
37
- * @returns {Number} Sum of all the Fields values in the array
35
+ * @returns {number} Sum of all the Fields values in the array
38
36
  */
39
37
  static arraySum(array) {
40
38
  let total = 0.0;
@@ -1,4 +1,5 @@
1
- import { Field, FieldConstructor } from "./field";
1
+ import { Field } from "./field";
2
+ import { BaseFieldConstructor } from "./base";
2
3
  /**
3
4
  * A company registration item.
4
5
  */
@@ -7,5 +8,5 @@ export declare class CompanyRegistrationField extends Field {
7
8
  value?: string;
8
9
  /** Type of company registration. */
9
10
  type: string;
10
- constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
11
+ constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
11
12
  }
@@ -1,4 +1,5 @@
1
- import { Field, FieldConstructor } from "./field";
1
+ import { Field } from "./field";
2
+ import { BaseFieldConstructor } from "./base";
2
3
  /**
3
4
  * A field containing a date value.
4
5
  */
@@ -8,11 +9,8 @@ export declare class DateField extends Field {
8
9
  /** Date as a standard JavaScript `Date` object. */
9
10
  dateObject?: Date;
10
11
  /**
11
- * @param {Object} prediction - Prediction object from HTTP response
12
- * @param {String} valueKey - Key to use in the prediction dict
13
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
14
- * @param {Integer} pageId - Page ID for multi-page document
12
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
15
13
  */
16
- constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
14
+ constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
17
15
  static compareDates(date1: Date, date2: Date): boolean;
18
16
  }
@@ -7,10 +7,7 @@ const field_1 = require("./field");
7
7
  */
8
8
  class DateField extends field_1.Field {
9
9
  /**
10
- * @param {Object} prediction - Prediction object from HTTP response
11
- * @param {String} valueKey - Key to use in the prediction dict
12
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
13
- * @param {Integer} pageId - Page ID for multi-page document
10
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
14
11
  */
15
12
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
16
13
  super({ prediction, valueKey, reconstructed, pageId });
@@ -1,12 +1,5 @@
1
- import { BaseField } from "./base";
1
+ import { BaseField, BaseFieldConstructor } from "./base";
2
2
  import { Polygon, BoundingBox } from "../../geometry";
3
- import { StringDict } from "../common";
4
- export interface FieldConstructor {
5
- prediction: StringDict;
6
- valueKey?: string;
7
- reconstructed?: boolean;
8
- pageId?: number | undefined;
9
- }
10
3
  /**
11
4
  * A basic field with position and page information.
12
5
  */
@@ -24,13 +17,9 @@ export declare class Field extends BaseField {
24
17
  /** The confidence score of the prediction. */
25
18
  confidence: number;
26
19
  /**
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
20
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
32
21
  */
33
- constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
22
+ constructor({ prediction, valueKey, reconstructed, pageId, }: BaseFieldConstructor);
34
23
  /**
35
24
  @param array1 first Array of Fields
36
25
  @param array2 second Array of Fields
@@ -40,7 +29,7 @@ export declare class Field extends BaseField {
40
29
  static compareArrays(array1: Field[], array2: Field[], attr?: string): boolean;
41
30
  /**
42
31
  * @param {Field[]} array - Array of Fields
43
- * @returns {Number} product of all the fields probability
32
+ * @returns {number} product of all the fields probability
44
33
  */
45
34
  static arrayConfidence(array: Field[]): number;
46
35
  }
@@ -8,11 +8,7 @@ const geometry_1 = require("../../geometry");
8
8
  */
9
9
  class Field extends base_1.BaseField {
10
10
  /**
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
11
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
16
12
  */
17
13
  constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
18
14
  super({ prediction, valueKey, reconstructed, pageId });
@@ -46,7 +42,7 @@ class Field extends base_1.BaseField {
46
42
  }
47
43
  /**
48
44
  * @param {Field[]} array - Array of Fields
49
- * @returns {Number} product of all the fields probability
45
+ * @returns {number} product of all the fields probability
50
46
  */
51
47
  static arrayConfidence(array) {
52
48
  let total = 1.0;
@@ -9,4 +9,4 @@ export { Word } from "./word";
9
9
  export { CompanyRegistrationField } from "./companyRegistration";
10
10
  export { PositionField } from "./position";
11
11
  export { StringField } from "./text";
12
- export { Field, FieldConstructor } from "./field";
12
+ export { Field } from "./field";
@@ -14,9 +14,7 @@ export declare class LocaleField extends BaseField {
14
14
  /** ISO 4217 currency code */
15
15
  currency?: string;
16
16
  /**
17
- * @param {Object} prediction - Prediction object from HTTP response
18
- * @param {String} valueKey - Key to use in the prediction dict
19
- * @param {boolean} reconstructed - Is the object reconstructed (not extracted by the API)
17
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
20
18
  */
21
19
  constructor({ prediction, reconstructed, pageId, }: BaseFieldConstructor);
22
20
  /**
@@ -7,9 +7,7 @@ const base_1 = require("./base");
7
7
  */
8
8
  class LocaleField extends base_1.BaseField {
9
9
  /**
10
- * @param {Object} prediction - Prediction object from HTTP response
11
- * @param {String} valueKey - Key to use in the prediction dict
12
- * @param {boolean} reconstructed - Is the object reconstructed (not extracted by the API)
10
+ * @param {BaseFieldConstructor} constructor Constructor parameters.
13
11
  */
14
12
  constructor({ prediction = {}, reconstructed = false, pageId = undefined, }) {
15
13
  const valueKey = prediction["value"] !== undefined ? "value" : "language";
@@ -1,5 +1,15 @@
1
1
  import { StringDict } from "../common";
2
2
  import { Field } from "./field";
3
+ /**
4
+ * @property {StringDict} constructor.prediction - Prediction object from HTTP response
5
+ * @property {string} constructor.valueKey - Key to use in the prediction dict to get the iban.
6
+ * @property {string} constructor.accountNumberKey - Key to use to get the account number in the prediction dict.
7
+ * @property {string} constructor.ibanKey - Key to use to get the IBAN in the prediction dict.
8
+ * @property {string} constructor.routingNumberKey - Key to use to get the routing number in the prediction dict.
9
+ * @property {string} constructor.swiftKey - Key to use to get the SWIFT in the prediction dict.
10
+ * @property {boolean} constructor.reconstructed - Is the object reconstructed (not extracted by the API).
11
+ * @property {number} constructor.pageId - Page ID for multi-page document.
12
+ */
3
13
  interface PaymentDetailsConstructor {
4
14
  prediction: StringDict;
5
15
  valueKey?: string;
@@ -26,14 +36,7 @@ export declare class PaymentDetailsField extends Field {
26
36
  /** The bank's SWIFT Business Identifier Code (BIC). */
27
37
  swift: string | undefined;
28
38
  /**
29
- * @param {Object} prediction - Prediction object from HTTP response
30
- * @param {String} valueKey - Key to use in the prediction dict to get the iban
31
- * @param {String} accountNumberKey - Key to use to get the account number in the prediction dict
32
- * @param {String} ibanKey - Key to use to get the IBAN in the prediction dict
33
- * @param {String} routingNumberKey - Key to use to get the routing number in the prediction dict
34
- * @param {String} swiftKey - Key to use to get the SWIFT in the prediction dict
35
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
36
- * @param {Integer} pageId - Page ID for multi-page document
39
+ * @param {PaymentDetailsConstructor} constructor Constructor parameters.
37
40
  */
38
41
  constructor({ prediction, valueKey, accountNumberKey, ibanKey, routingNumberKey, swiftKey, reconstructed, pageId, }: PaymentDetailsConstructor);
39
42
  /**
@@ -13,14 +13,7 @@ const field_1 = require("./field");
13
13
  */
14
14
  class PaymentDetailsField extends field_1.Field {
15
15
  /**
16
- * @param {Object} prediction - Prediction object from HTTP response
17
- * @param {String} valueKey - Key to use in the prediction dict to get the iban
18
- * @param {String} accountNumberKey - Key to use to get the account number in the prediction dict
19
- * @param {String} ibanKey - Key to use to get the IBAN in the prediction dict
20
- * @param {String} routingNumberKey - Key to use to get the routing number in the prediction dict
21
- * @param {String} swiftKey - Key to use to get the SWIFT in the prediction dict
22
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
23
- * @param {Integer} pageId - Page ID for multi-page document
16
+ * @param {PaymentDetailsConstructor} constructor Constructor parameters.
24
17
  */
25
18
  constructor({ prediction = {}, valueKey = "iban", accountNumberKey = "account_number", ibanKey = "iban", routingNumberKey = "routing_number", swiftKey = "swift", reconstructed = false, pageId = undefined, }) {
26
19
  super({ prediction, valueKey, reconstructed, pageId });
@@ -7,10 +7,10 @@ exports.PositionField = void 0;
7
7
  class PositionField {
8
8
  constructor({ prediction = {}, pageId }) {
9
9
  this.pageId = pageId;
10
- this.boundingBox = prediction["bounding_box"];
11
- this.polygon = prediction["polygon"];
12
- this.quadrangle = prediction["quadrangle"];
13
- this.rectangle = prediction["rectangle"];
10
+ this.boundingBox = "bounding_box" in prediction ? prediction["bounding_box"] : [];
11
+ this.polygon = "polygon" in prediction ? prediction["polygon"] : [];
12
+ this.quadrangle = "quadrangle" in prediction ? prediction["quadrangle"] : [];
13
+ this.rectangle = "rectangle" in prediction ? prediction["rectangle"] : [];
14
14
  }
15
15
  /**
16
16
  * Default string representation.
@@ -1,13 +1,15 @@
1
1
  import { StringDict } from "../common";
2
2
  import { Field } from "./field";
3
- interface TaxConstructor {
4
- prediction: StringDict;
5
- valueKey?: string;
3
+ import { BaseFieldConstructor } from "./base";
4
+ /**
5
+ * @property {string} constructor.rateKey - Key to use to get the tax rate in the prediction dict.
6
+ * @property {string} constructor.codeKey - Key to use to get the tax code in the prediction dict.
7
+ * @property {string} constructor.baseKey - Key to use to get the base tax in the prediction dict.
8
+ */
9
+ interface TaxConstructor extends BaseFieldConstructor {
6
10
  rateKey?: string;
7
11
  codeKey?: string;
8
12
  baseKey?: string;
9
- reconstructed?: boolean;
10
- pageId?: number;
11
13
  }
12
14
  /**
13
15
  * Represent a single tax line.
@@ -25,13 +27,7 @@ export declare class TaxField extends Field {
25
27
  /** The document page on which the information was found. */
26
28
  pageId: number;
27
29
  /**
28
- * @param {Object} prediction - Prediction object from HTTP response
29
- * @param {String} valueKey - Key to use in the prediction dict to get the tax value
30
- * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
31
- * @param {String} codeKey - Key to use to get the tax code in the prediction dict
32
- * @param {String} baseKey - Key to use to get the base tax in the prediction dict
33
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
34
- * @param {Integer} pageNumber - Page ID for multi-page document
30
+ * @param {TaxConstructor} constructor Constructor parameters.
35
31
  */
36
32
  constructor({ prediction, valueKey, rateKey, codeKey, baseKey, reconstructed, pageId, }: TaxConstructor);
37
33
  /**
@@ -14,13 +14,7 @@ const amount_1 = require("./amount");
14
14
  */
15
15
  class TaxField extends field_1.Field {
16
16
  /**
17
- * @param {Object} prediction - Prediction object from HTTP response
18
- * @param {String} valueKey - Key to use in the prediction dict to get the tax value
19
- * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
20
- * @param {String} codeKey - Key to use to get the tax code in the prediction dict
21
- * @param {String} baseKey - Key to use to get the base tax in the prediction dict
22
- * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
23
- * @param {Integer} pageNumber - Page ID for multi-page document
17
+ * @param {TaxConstructor} constructor Constructor parameters.
24
18
  */
25
19
  constructor({ prediction = {}, valueKey = "value", rateKey = "rate", codeKey = "code", baseKey = "base", reconstructed = false, pageId = undefined, }) {
26
20
  super({ prediction, valueKey, reconstructed, pageId });
@@ -141,11 +141,11 @@ class FinancialDocumentV1Document {
141
141
  :Total Amount: ${this.totalAmount}
142
142
  :Taxes: ${this.taxes}
143
143
  :Supplier Payment Details: ${supplierPaymentDetails}
144
- :Supplier name: ${this.supplierName}
144
+ :Supplier Name: ${this.supplierName}
145
145
  :Supplier Company Registrations: ${supplierCompanyRegistrations}
146
146
  :Supplier Address: ${this.supplierAddress}
147
147
  :Supplier Phone Number: ${this.supplierPhoneNumber}
148
- :Customer name: ${this.customerName}
148
+ :Customer Name: ${this.customerName}
149
149
  :Customer Company Registrations: ${customerCompanyRegistrations}
150
150
  :Customer Address: ${this.customerAddress}
151
151
  :Document Type: ${this.documentType}
@@ -0,0 +1,16 @@
1
+ import { Inference, StringDict, Page } from "../../../parsing/common";
2
+ import { CarteGriseV1Document } from "./carteGriseV1Document";
3
+ /**
4
+ * Inference prediction for Carte Grise, API version 1.
5
+ */
6
+ export declare class CarteGriseV1 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: CarteGriseV1Document;
13
+ /** The document's pages. */
14
+ pages: Page<CarteGriseV1Document>[];
15
+ constructor(rawPrediction: StringDict);
16
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarteGriseV1 = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const carteGriseV1Document_1 = require("./carteGriseV1Document");
6
+ /**
7
+ * Inference prediction for Carte Grise, API version 1.
8
+ */
9
+ class CarteGriseV1 extends common_1.Inference {
10
+ constructor(rawPrediction) {
11
+ super(rawPrediction);
12
+ /** The endpoint's name. */
13
+ this.endpointName = "carte_grise";
14
+ /** The endpoint's version. */
15
+ this.endpointVersion = "1";
16
+ /** The document's pages. */
17
+ this.pages = [];
18
+ this.prediction = new carteGriseV1Document_1.CarteGriseV1Document(rawPrediction["prediction"]);
19
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(carteGriseV1Document_1.CarteGriseV1Document, page, page["id"], page["orientation"]));
20
+ }
21
+ }
22
+ exports.CarteGriseV1 = CarteGriseV1;