mindee 4.3.3 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.4.0 - 2023-11-17
4
+ ### Changes
5
+ * :sparkles: add support for Carte Grise V1
6
+ * :sparkles: add page nubmer attribute to doc
7
+ * :arrow_up: update product tests & doc
8
+ ### Fixes
9
+ * :bug: fix broken `page_id` attribute for newer custom builds
10
+
11
+
3
12
  ## v4.3.2 - 2023-11-07
4
13
  ### Changes
5
14
  * :recycle: update invoice splitter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.3.3",
3
+ "version": "4.4.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -17,6 +17,8 @@ export declare class Document<T extends Inference> {
17
17
  extras?: Extras;
18
18
  /** Raw-text response for `allWords` parsing. */
19
19
  ocr?: Ocr;
20
+ /** Page number as sent back by the API. */
21
+ nPages: number;
20
22
  /**
21
23
  *
22
24
  * @param inferenceClass constructor signature for an inference.
@@ -32,6 +32,7 @@ class Document {
32
32
  });
33
33
  this.extras = new extras_1.Extras(extras);
34
34
  }
35
+ this.nPages = httpResponse["n_pages"];
35
36
  }
36
37
  /**
37
38
  * Default string representation.
@@ -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,8 +32,6 @@ 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
35
  /**
36
36
  * @param {BaseFieldConstructor} constructor Constructor parameters.
37
37
  */
@@ -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.
@@ -37,10 +40,12 @@ class ListField {
37
40
  this.values = [];
38
41
  this.confidence = prediction["confidence"];
39
42
  this.reconstructed = reconstructed;
40
- this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
41
43
  if (prediction["values"] !== undefined) {
42
44
  prediction["values"].forEach((field) => {
43
- this.values.push(new ListFieldValue(field));
45
+ if (pageId === undefined) {
46
+ pageId = field["page_id"];
47
+ }
48
+ this.values.push(new ListFieldValue(field, pageId));
44
49
  });
45
50
  }
46
51
  }
@@ -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.
@@ -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;
@@ -0,0 +1,94 @@
1
+ import { Prediction, StringDict } from "../../../parsing/common";
2
+ import { DateField, StringField } from "../../../parsing/standard";
3
+ /**
4
+ * Document data for Carte Grise, API version 1.
5
+ */
6
+ export declare class CarteGriseV1Document implements Prediction {
7
+ /** The vehicle's license plate number. */
8
+ a: StringField;
9
+ /** The vehicle's first release date. */
10
+ b: DateField;
11
+ /** The vehicle owner's full name including maiden name. */
12
+ c1: StringField;
13
+ /** The vehicle owner's address. */
14
+ c3: StringField;
15
+ /** Number of owners of the license certificate. */
16
+ c41: StringField;
17
+ /** Mentions about the ownership of the vehicle. */
18
+ c4A: StringField;
19
+ /** The vehicle's brand. */
20
+ d1: StringField;
21
+ /** The vehicle's commercial name. */
22
+ d3: StringField;
23
+ /** The Vehicle Identification Number (VIN). */
24
+ e: StringField;
25
+ /** The vehicle's maximum admissible weight. */
26
+ f1: StringField;
27
+ /** The vehicle's maximum admissible weight within the license's state. */
28
+ f2: StringField;
29
+ /** The vehicle's maximum authorized weight with coupling. */
30
+ f3: StringField;
31
+ /** The document's formula number. */
32
+ formulaNumber: StringField;
33
+ /** The vehicle's weight with coupling if tractor different than category M1. */
34
+ g: StringField;
35
+ /** The vehicle's national empty weight. */
36
+ g1: StringField;
37
+ /** The car registration date of the given certificate. */
38
+ i: DateField;
39
+ /** The vehicle's category. */
40
+ j: StringField;
41
+ /** The vehicle's national type. */
42
+ j1: StringField;
43
+ /** The vehicle's body type (CE). */
44
+ j2: StringField;
45
+ /** The vehicle's body type (National designation). */
46
+ j3: StringField;
47
+ /** Machine Readable Zone, first line. */
48
+ mrz1: StringField;
49
+ /** Machine Readable Zone, second line. */
50
+ mrz2: StringField;
51
+ /** The vehicle's owner first name. */
52
+ ownerFirstName: StringField;
53
+ /** The vehicle's owner surname. */
54
+ ownerSurname: StringField;
55
+ /** The vehicle engine's displacement (cm3). */
56
+ p1: StringField;
57
+ /** The vehicle's maximum net power (kW). */
58
+ p2: StringField;
59
+ /** The vehicle's fuel type or energy source. */
60
+ p3: StringField;
61
+ /** The vehicle's administrative power (fiscal horsepower). */
62
+ p6: StringField;
63
+ /** The vehicle's power to weight ratio. */
64
+ q: StringField;
65
+ /** The vehicle's number of seats. */
66
+ s1: StringField;
67
+ /** The vehicle's number of standing rooms (person). */
68
+ s2: StringField;
69
+ /** The vehicle's sound level (dB). */
70
+ u1: StringField;
71
+ /** The vehicle engine's rotation speed (RPM). */
72
+ u2: StringField;
73
+ /** The vehicle's CO2 emission (g/km). */
74
+ v7: StringField;
75
+ /** Next technical control date. */
76
+ x1: StringField;
77
+ /** Amount of the regional proportional tax of the registration (in euros). */
78
+ y1: StringField;
79
+ /** Amount of the additional parafiscal tax of the registration (in euros). */
80
+ y2: StringField;
81
+ /** Amount of the additional CO2 tax of the registration (in euros). */
82
+ y3: StringField;
83
+ /** Amount of the fee for managing the registration (in euros). */
84
+ y4: StringField;
85
+ /** Amount of the fee for delivery of the registration certificate in euros. */
86
+ y5: StringField;
87
+ /** Total amount of registration fee to be paid in euros. */
88
+ y6: StringField;
89
+ constructor(rawPrediction: StringDict, pageId?: number);
90
+ /**
91
+ * Default string representation.
92
+ */
93
+ toString(): string;
94
+ }
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarteGriseV1Document = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const standard_1 = require("../../../parsing/standard");
6
+ /**
7
+ * Document data for Carte Grise, API version 1.
8
+ */
9
+ class CarteGriseV1Document {
10
+ constructor(rawPrediction, pageId) {
11
+ this.a = new standard_1.StringField({
12
+ prediction: rawPrediction["a"],
13
+ pageId: pageId,
14
+ });
15
+ this.b = new standard_1.DateField({
16
+ prediction: rawPrediction["b"],
17
+ pageId: pageId,
18
+ });
19
+ this.c1 = new standard_1.StringField({
20
+ prediction: rawPrediction["c1"],
21
+ pageId: pageId,
22
+ });
23
+ this.c3 = new standard_1.StringField({
24
+ prediction: rawPrediction["c3"],
25
+ pageId: pageId,
26
+ });
27
+ this.c41 = new standard_1.StringField({
28
+ prediction: rawPrediction["c41"],
29
+ pageId: pageId,
30
+ });
31
+ this.c4A = new standard_1.StringField({
32
+ prediction: rawPrediction["c4a"],
33
+ pageId: pageId,
34
+ });
35
+ this.d1 = new standard_1.StringField({
36
+ prediction: rawPrediction["d1"],
37
+ pageId: pageId,
38
+ });
39
+ this.d3 = new standard_1.StringField({
40
+ prediction: rawPrediction["d3"],
41
+ pageId: pageId,
42
+ });
43
+ this.e = new standard_1.StringField({
44
+ prediction: rawPrediction["e"],
45
+ pageId: pageId,
46
+ });
47
+ this.f1 = new standard_1.StringField({
48
+ prediction: rawPrediction["f1"],
49
+ pageId: pageId,
50
+ });
51
+ this.f2 = new standard_1.StringField({
52
+ prediction: rawPrediction["f2"],
53
+ pageId: pageId,
54
+ });
55
+ this.f3 = new standard_1.StringField({
56
+ prediction: rawPrediction["f3"],
57
+ pageId: pageId,
58
+ });
59
+ this.formulaNumber = new standard_1.StringField({
60
+ prediction: rawPrediction["formula_number"],
61
+ pageId: pageId,
62
+ });
63
+ this.g = new standard_1.StringField({
64
+ prediction: rawPrediction["g"],
65
+ pageId: pageId,
66
+ });
67
+ this.g1 = new standard_1.StringField({
68
+ prediction: rawPrediction["g1"],
69
+ pageId: pageId,
70
+ });
71
+ this.i = new standard_1.DateField({
72
+ prediction: rawPrediction["i"],
73
+ pageId: pageId,
74
+ });
75
+ this.j = new standard_1.StringField({
76
+ prediction: rawPrediction["j"],
77
+ pageId: pageId,
78
+ });
79
+ this.j1 = new standard_1.StringField({
80
+ prediction: rawPrediction["j1"],
81
+ pageId: pageId,
82
+ });
83
+ this.j2 = new standard_1.StringField({
84
+ prediction: rawPrediction["j2"],
85
+ pageId: pageId,
86
+ });
87
+ this.j3 = new standard_1.StringField({
88
+ prediction: rawPrediction["j3"],
89
+ pageId: pageId,
90
+ });
91
+ this.mrz1 = new standard_1.StringField({
92
+ prediction: rawPrediction["mrz1"],
93
+ pageId: pageId,
94
+ });
95
+ this.mrz2 = new standard_1.StringField({
96
+ prediction: rawPrediction["mrz2"],
97
+ pageId: pageId,
98
+ });
99
+ this.ownerFirstName = new standard_1.StringField({
100
+ prediction: rawPrediction["owner_first_name"],
101
+ pageId: pageId,
102
+ });
103
+ this.ownerSurname = new standard_1.StringField({
104
+ prediction: rawPrediction["owner_surname"],
105
+ pageId: pageId,
106
+ });
107
+ this.p1 = new standard_1.StringField({
108
+ prediction: rawPrediction["p1"],
109
+ pageId: pageId,
110
+ });
111
+ this.p2 = new standard_1.StringField({
112
+ prediction: rawPrediction["p2"],
113
+ pageId: pageId,
114
+ });
115
+ this.p3 = new standard_1.StringField({
116
+ prediction: rawPrediction["p3"],
117
+ pageId: pageId,
118
+ });
119
+ this.p6 = new standard_1.StringField({
120
+ prediction: rawPrediction["p6"],
121
+ pageId: pageId,
122
+ });
123
+ this.q = new standard_1.StringField({
124
+ prediction: rawPrediction["q"],
125
+ pageId: pageId,
126
+ });
127
+ this.s1 = new standard_1.StringField({
128
+ prediction: rawPrediction["s1"],
129
+ pageId: pageId,
130
+ });
131
+ this.s2 = new standard_1.StringField({
132
+ prediction: rawPrediction["s2"],
133
+ pageId: pageId,
134
+ });
135
+ this.u1 = new standard_1.StringField({
136
+ prediction: rawPrediction["u1"],
137
+ pageId: pageId,
138
+ });
139
+ this.u2 = new standard_1.StringField({
140
+ prediction: rawPrediction["u2"],
141
+ pageId: pageId,
142
+ });
143
+ this.v7 = new standard_1.StringField({
144
+ prediction: rawPrediction["v7"],
145
+ pageId: pageId,
146
+ });
147
+ this.x1 = new standard_1.StringField({
148
+ prediction: rawPrediction["x1"],
149
+ pageId: pageId,
150
+ });
151
+ this.y1 = new standard_1.StringField({
152
+ prediction: rawPrediction["y1"],
153
+ pageId: pageId,
154
+ });
155
+ this.y2 = new standard_1.StringField({
156
+ prediction: rawPrediction["y2"],
157
+ pageId: pageId,
158
+ });
159
+ this.y3 = new standard_1.StringField({
160
+ prediction: rawPrediction["y3"],
161
+ pageId: pageId,
162
+ });
163
+ this.y4 = new standard_1.StringField({
164
+ prediction: rawPrediction["y4"],
165
+ pageId: pageId,
166
+ });
167
+ this.y5 = new standard_1.StringField({
168
+ prediction: rawPrediction["y5"],
169
+ pageId: pageId,
170
+ });
171
+ this.y6 = new standard_1.StringField({
172
+ prediction: rawPrediction["y6"],
173
+ pageId: pageId,
174
+ });
175
+ }
176
+ /**
177
+ * Default string representation.
178
+ */
179
+ toString() {
180
+ const outStr = `:a: ${this.a}
181
+ :b: ${this.b}
182
+ :c1: ${this.c1}
183
+ :c3: ${this.c3}
184
+ :c41: ${this.c41}
185
+ :c4a: ${this.c4A}
186
+ :d1: ${this.d1}
187
+ :d3: ${this.d3}
188
+ :e: ${this.e}
189
+ :f1: ${this.f1}
190
+ :f2: ${this.f2}
191
+ :f3: ${this.f3}
192
+ :g: ${this.g}
193
+ :g1: ${this.g1}
194
+ :i: ${this.i}
195
+ :j: ${this.j}
196
+ :j1: ${this.j1}
197
+ :j2: ${this.j2}
198
+ :j3: ${this.j3}
199
+ :p1: ${this.p1}
200
+ :p2: ${this.p2}
201
+ :p3: ${this.p3}
202
+ :p6: ${this.p6}
203
+ :q: ${this.q}
204
+ :s1: ${this.s1}
205
+ :s2: ${this.s2}
206
+ :u1: ${this.u1}
207
+ :u2: ${this.u2}
208
+ :v7: ${this.v7}
209
+ :x1: ${this.x1}
210
+ :y1: ${this.y1}
211
+ :y2: ${this.y2}
212
+ :y3: ${this.y3}
213
+ :y4: ${this.y4}
214
+ :y5: ${this.y5}
215
+ :y6: ${this.y6}
216
+ :Formula Number: ${this.formulaNumber}
217
+ :Owner's First Name: ${this.ownerFirstName}
218
+ :Owner's Surname: ${this.ownerSurname}
219
+ :MRZ Line 1: ${this.mrz1}
220
+ :MRZ Line 2: ${this.mrz2}`.trimEnd();
221
+ return (0, common_1.cleanOutString)(outStr);
222
+ }
223
+ }
224
+ exports.CarteGriseV1Document = CarteGriseV1Document;
@@ -0,0 +1,2 @@
1
+ export { CarteGriseV1 } from "./carteGriseV1";
2
+ export { CarteGriseV1Document } from "./carteGriseV1Document";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarteGriseV1Document = exports.CarteGriseV1 = void 0;
4
+ var carteGriseV1_1 = require("./carteGriseV1");
5
+ Object.defineProperty(exports, "CarteGriseV1", { enumerable: true, get: function () { return carteGriseV1_1.CarteGriseV1; } });
6
+ var carteGriseV1Document_1 = require("./carteGriseV1Document");
7
+ Object.defineProperty(exports, "CarteGriseV1Document", { enumerable: true, get: function () { return carteGriseV1Document_1.CarteGriseV1Document; } });
@@ -1,5 +1,6 @@
1
1
  export { IdCardV1 } from "./idCard/idCardV1";
2
2
  export { IdCardV2 } from "./idCard/idCardV2";
3
+ export { CarteGriseV1 } from "./carteGrise/carteGriseV1";
3
4
  export { BankAccountDetailsV1 } from "./bankAccountDetails/bankAccountDetailsV1";
4
5
  export { BankAccountDetailsV2 } from "./bankAccountDetails/bankAccountDetailsV2";
5
6
  export { CarteVitaleV1 } from "./carteVitale/carteVitaleV1";
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CarteVitaleV1 = exports.BankAccountDetailsV2 = exports.BankAccountDetailsV1 = exports.IdCardV2 = exports.IdCardV1 = void 0;
3
+ exports.CarteVitaleV1 = exports.BankAccountDetailsV2 = exports.BankAccountDetailsV1 = exports.CarteGriseV1 = exports.IdCardV2 = exports.IdCardV1 = void 0;
4
4
  var idCardV1_1 = require("./idCard/idCardV1");
5
5
  Object.defineProperty(exports, "IdCardV1", { enumerable: true, get: function () { return idCardV1_1.IdCardV1; } });
6
6
  var idCardV2_1 = require("./idCard/idCardV2");
7
7
  Object.defineProperty(exports, "IdCardV2", { enumerable: true, get: function () { return idCardV2_1.IdCardV2; } });
8
+ var carteGriseV1_1 = require("./carteGrise/carteGriseV1");
9
+ Object.defineProperty(exports, "CarteGriseV1", { enumerable: true, get: function () { return carteGriseV1_1.CarteGriseV1; } });
8
10
  var bankAccountDetailsV1_1 = require("./bankAccountDetails/bankAccountDetailsV1");
9
11
  Object.defineProperty(exports, "BankAccountDetailsV1", { enumerable: true, get: function () { return bankAccountDetailsV1_1.BankAccountDetailsV1; } });
10
12
  var bankAccountDetailsV2_1 = require("./bankAccountDetails/bankAccountDetailsV2");
@@ -1,3 +1,4 @@
1
1
  export * as bankAccountDetails from "./bankAccountDetails/internal";
2
2
  export * as carteVitale from "./carteVitale/internal";
3
3
  export * as idCard from "./idCard/internal";
4
+ export * as carteGrise from "./carteGrise/internal";
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.idCard = exports.carteVitale = exports.bankAccountDetails = void 0;
26
+ exports.carteGrise = exports.idCard = exports.carteVitale = exports.bankAccountDetails = void 0;
27
27
  exports.bankAccountDetails = __importStar(require("./bankAccountDetails/internal"));
28
28
  exports.carteVitale = __importStar(require("./carteVitale/internal"));
29
29
  exports.idCard = __importStar(require("./idCard/internal"));
30
+ exports.carteGrise = __importStar(require("./carteGrise/internal"));