mindee 2.0.0 → 2.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.
- package/CHANGELOG.md +11 -1
- package/README.md +15 -11
- package/bin/mindee.d.ts +2 -0
- package/bin/mindee.js +5 -0
- package/package.json +68 -68
- package/{dist/src → src}/api/endpoint.d.ts +4 -1
- package/{dist/src → src}/api/endpoint.js +20 -21
- package/src/api/index.d.ts +2 -0
- package/{dist/src → src}/api/index.js +3 -1
- package/{dist/src → src}/api/response.d.ts +5 -2
- package/{dist/src → src}/api/response.js +19 -5
- package/{dist/src → src}/cli.d.ts +0 -0
- package/src/cli.js +125 -0
- package/{dist/src → src}/client.d.ts +1 -0
- package/{dist/src → src}/client.js +39 -46
- package/{dist/src → src}/constants.d.ts +0 -0
- package/{dist/src → src}/constants.js +6 -0
- package/src/documents/cropper.d.ts +7 -0
- package/src/documents/cropper.js +31 -0
- package/{dist/src → src}/documents/custom.d.ts +2 -2
- package/{dist/src → src}/documents/custom.js +4 -4
- package/src/documents/document.d.ts +42 -0
- package/{dist/src → src}/documents/document.js +24 -14
- package/{dist/src → src}/documents/documentConfig.d.ts +6 -2
- package/{dist/src → src}/documents/documentConfig.js +29 -39
- package/{dist/src → src}/documents/financialDocument.d.ts +2 -9
- package/{dist/src → src}/documents/financialDocument.js +14 -13
- package/{dist/src → src}/documents/index.d.ts +3 -1
- package/{dist/src → src}/documents/index.js +4 -1
- package/{dist/src → src}/documents/invoice.d.ts +2 -9
- package/{dist/src → src}/documents/invoice.js +3 -15
- package/{dist/src → src}/documents/passport.d.ts +1 -7
- package/{dist/src → src}/documents/passport.js +13 -19
- package/src/documents/receipt.d.ts +17 -0
- package/{dist/src → src}/documents/receipt.js +4 -16
- package/{dist/src → src}/errors/handler.d.ts +0 -0
- package/{dist/src → src}/errors/handler.js +0 -0
- package/{dist/src → src}/fields/amount.d.ts +0 -0
- package/{dist/src → src}/fields/amount.js +0 -0
- package/{dist/src → src}/fields/companyRegistration.d.ts +0 -0
- package/{dist/src → src}/fields/companyRegistration.js +0 -0
- package/src/fields/cropper.d.ts +16 -0
- package/src/fields/cropper.js +18 -0
- package/{dist/src → src}/fields/customDocs.d.ts +2 -2
- package/{dist/src → src}/fields/customDocs.js +4 -4
- package/{dist/src → src}/fields/date.d.ts +0 -0
- package/{dist/src → src}/fields/date.js +0 -0
- package/{dist/src → src}/fields/field.d.ts +10 -11
- package/{dist/src → src}/fields/field.js +4 -3
- package/{dist/src → src}/fields/fullText.d.ts +0 -0
- package/{dist/src → src}/fields/fullText.js +0 -0
- package/{dist/src → src}/fields/index.d.ts +4 -4
- package/{dist/src → src}/fields/index.js +6 -5
- package/{dist/src → src}/fields/locale.d.ts +0 -0
- package/{dist/src → src}/fields/locale.js +0 -0
- package/{dist/src → src}/fields/orientation.d.ts +10 -3
- package/{dist/src → src}/fields/orientation.js +9 -7
- package/{dist/src → src}/fields/paymentDetails.d.ts +0 -0
- package/{dist/src → src}/fields/paymentDetails.js +0 -0
- package/{dist/src → src}/fields/tax.d.ts +0 -0
- package/{dist/src → src}/fields/tax.js +1 -2
- package/{dist/src → src}/geometry.d.ts +0 -0
- package/{dist/src → src}/geometry.js +0 -0
- package/{dist/src → src}/index.d.ts +1 -1
- package/{dist/src → src}/index.js +2 -1
- package/{dist/src → src}/inputs.d.ts +0 -0
- package/src/inputs.js +196 -0
- package/{dist/src → src}/logger.d.ts +0 -0
- package/{dist/src → src}/logger.js +0 -0
- package/bin/mindee +0 -3
- package/dist/package.json +0 -70
- package/dist/src/api/index.d.ts +0 -2
- package/dist/src/cli.js +0 -117
- package/dist/src/documents/document.d.ts +0 -38
- package/dist/src/documents/receipt.d.ts +0 -24
- package/dist/src/inputs.js +0 -223
|
@@ -10,20 +10,14 @@ exports.Invoice = void 0;
|
|
|
10
10
|
const document_1 = require("./document");
|
|
11
11
|
const fields_1 = require("../fields");
|
|
12
12
|
class Invoice extends document_1.Document {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param {Input} inputFile - input file given to parse the document
|
|
16
|
-
* @param {number} pageId - Page ID for multi-page document
|
|
17
|
-
* @param {FullText} fullText - full OCR extracted text
|
|
18
|
-
*/
|
|
19
|
-
constructor({ apiPrediction, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
|
|
20
|
-
super(inputFile, pageId, fullText);
|
|
13
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
|
|
14
|
+
super({ inputFile, pageId, fullText, orientation, extras });
|
|
21
15
|
_Invoice_instances.add(this);
|
|
22
16
|
this.companyRegistration = [];
|
|
23
17
|
this.taxes = [];
|
|
24
18
|
this.paymentDetails = [];
|
|
25
19
|
this.customerCompanyRegistration = [];
|
|
26
|
-
__classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_initFromApiPrediction).call(this,
|
|
20
|
+
__classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_initFromApiPrediction).call(this, prediction, pageId);
|
|
27
21
|
__classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_checklist).call(this);
|
|
28
22
|
__classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_reconstruct).call(this);
|
|
29
23
|
}
|
|
@@ -218,12 +212,6 @@ _Invoice_instances = new WeakSet(), _Invoice_initFromApiPrediction = function _I
|
|
|
218
212
|
prediction: prediction,
|
|
219
213
|
pageId: pageId,
|
|
220
214
|
})));
|
|
221
|
-
if (pageId !== undefined) {
|
|
222
|
-
this.orientation = new fields_1.Orientation({
|
|
223
|
-
prediction: apiPrediction.orientation,
|
|
224
|
-
pageId: pageId,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
215
|
}, _Invoice_checklist = function _Invoice_checklist() {
|
|
228
216
|
this.checklist = {
|
|
229
217
|
taxesMatchTotalIncl: this.taxesMatchTotalIncl(),
|
|
@@ -15,13 +15,7 @@ export declare class Passport extends Document {
|
|
|
15
15
|
givenNames: Field[];
|
|
16
16
|
fullName: Field;
|
|
17
17
|
mrz: Field;
|
|
18
|
-
|
|
19
|
-
* @param {Object} apiPrediction - Json parsed prediction from HTTP response
|
|
20
|
-
* @param {Input} inputFile - input file given to parse the document
|
|
21
|
-
* @param {number} pageId - Page ID for multi-page document
|
|
22
|
-
* @param {FullText} fullText - full OCR extracted text
|
|
23
|
-
*/
|
|
24
|
-
constructor({ apiPrediction, inputFile, pageId, }: DocumentConstructorProps);
|
|
18
|
+
constructor({ prediction, orientation, extras, inputFile, pageId, }: DocumentConstructorProps);
|
|
25
19
|
static convertMRZDateToDatetime(dateString: string): Date;
|
|
26
20
|
toString(): string;
|
|
27
21
|
isExpired(): boolean;
|
|
@@ -35,57 +35,51 @@ const fields_1 = require("../fields");
|
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
const MRZ = __importStar(require("mrz"));
|
|
37
37
|
class Passport extends document_1.Document {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @param {Input} inputFile - input file given to parse the document
|
|
41
|
-
* @param {number} pageId - Page ID for multi-page document
|
|
42
|
-
* @param {FullText} fullText - full OCR extracted text
|
|
43
|
-
*/
|
|
44
|
-
constructor({ apiPrediction, inputFile = undefined, pageId = undefined, }) {
|
|
45
|
-
super(inputFile, pageId);
|
|
38
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, pageId = undefined, }) {
|
|
39
|
+
super({ inputFile, pageId, orientation, extras });
|
|
46
40
|
_Passport_instances.add(this);
|
|
47
41
|
this.givenNames = [];
|
|
48
42
|
this.country = new fields_1.Field({
|
|
49
|
-
prediction:
|
|
43
|
+
prediction: prediction.country,
|
|
50
44
|
pageId: pageId,
|
|
51
45
|
});
|
|
52
46
|
this.idNumber = new fields_1.Field({
|
|
53
|
-
prediction:
|
|
47
|
+
prediction: prediction.id_number,
|
|
54
48
|
pageId: pageId,
|
|
55
49
|
});
|
|
56
50
|
this.birthDate = new fields_1.DateField({
|
|
57
|
-
prediction:
|
|
51
|
+
prediction: prediction.birth_date,
|
|
58
52
|
pageId: pageId,
|
|
59
53
|
});
|
|
60
54
|
this.expiryDate = new fields_1.DateField({
|
|
61
|
-
prediction:
|
|
55
|
+
prediction: prediction.expiry_date,
|
|
62
56
|
pageId: pageId,
|
|
63
57
|
});
|
|
64
58
|
this.issuanceDate = new fields_1.DateField({
|
|
65
|
-
prediction:
|
|
59
|
+
prediction: prediction.issuance_date,
|
|
66
60
|
pageId: pageId,
|
|
67
61
|
});
|
|
68
62
|
this.birthPlace = new fields_1.Field({
|
|
69
|
-
prediction:
|
|
63
|
+
prediction: prediction.birth_place,
|
|
70
64
|
pageId: pageId,
|
|
71
65
|
});
|
|
72
66
|
this.gender = new fields_1.Field({
|
|
73
|
-
prediction:
|
|
67
|
+
prediction: prediction.gender,
|
|
74
68
|
pageId: pageId,
|
|
75
69
|
});
|
|
76
70
|
this.surname = new fields_1.Field({
|
|
77
|
-
prediction:
|
|
71
|
+
prediction: prediction.surname,
|
|
78
72
|
pageId: pageId,
|
|
79
73
|
});
|
|
80
74
|
this.mrz1 = new fields_1.Field({
|
|
81
|
-
prediction:
|
|
75
|
+
prediction: prediction.mrz1,
|
|
82
76
|
pageId: pageId,
|
|
83
77
|
});
|
|
84
78
|
this.mrz2 = new fields_1.Field({
|
|
85
|
-
prediction:
|
|
79
|
+
prediction: prediction.mrz2,
|
|
86
80
|
pageId: pageId,
|
|
87
81
|
});
|
|
88
|
-
|
|
82
|
+
prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.Field({
|
|
89
83
|
prediction: prediction,
|
|
90
84
|
pageId: pageId,
|
|
91
85
|
})));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Document, DocumentConstructorProps } from "./document";
|
|
2
|
+
import { TaxField, Field, Amount, Locale, DateField } from "../fields";
|
|
3
|
+
export declare class Receipt extends Document {
|
|
4
|
+
#private;
|
|
5
|
+
locale: Locale;
|
|
6
|
+
totalIncl: Amount;
|
|
7
|
+
date: DateField;
|
|
8
|
+
/** Receipt category as seen on the receipt. */
|
|
9
|
+
category: Field;
|
|
10
|
+
merchantName: Field;
|
|
11
|
+
time: Field;
|
|
12
|
+
totalTax: Amount;
|
|
13
|
+
totalExcl: Amount;
|
|
14
|
+
taxes: TaxField[];
|
|
15
|
+
constructor({ prediction, orientation, extras, inputFile, fullText, pageId, }: DocumentConstructorProps);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
@@ -10,18 +10,12 @@ exports.Receipt = void 0;
|
|
|
10
10
|
const document_1 = require("./document");
|
|
11
11
|
const fields_1 = require("../fields");
|
|
12
12
|
class Receipt extends document_1.Document {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param {Input} inputFile - input file given to parse the document
|
|
16
|
-
* @param {number} pageId - Page ID for multi-page document
|
|
17
|
-
* @param {FullText} fullText - full OCR extracted text
|
|
18
|
-
*/
|
|
19
|
-
constructor({ apiPrediction, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
|
|
20
|
-
super(inputFile, pageId, fullText);
|
|
13
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
|
|
14
|
+
super({ inputFile, pageId, fullText, orientation, extras });
|
|
21
15
|
_Receipt_instances.add(this);
|
|
22
16
|
this.taxes = [];
|
|
23
17
|
this.locale = new fields_1.Locale({
|
|
24
|
-
prediction:
|
|
18
|
+
prediction: prediction.locale,
|
|
25
19
|
pageId: pageId,
|
|
26
20
|
});
|
|
27
21
|
this.totalTax = new fields_1.Amount({
|
|
@@ -34,7 +28,7 @@ class Receipt extends document_1.Document {
|
|
|
34
28
|
valueKey: "value",
|
|
35
29
|
pageId: pageId,
|
|
36
30
|
});
|
|
37
|
-
__classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_initFromApiPrediction).call(this,
|
|
31
|
+
__classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_initFromApiPrediction).call(this, prediction, pageId);
|
|
38
32
|
__classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_checklist).call(this);
|
|
39
33
|
__classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_reconstruct).call(this);
|
|
40
34
|
}
|
|
@@ -86,12 +80,6 @@ _Receipt_instances = new WeakSet(), _Receipt_initFromApiPrediction = function _R
|
|
|
86
80
|
rateKey: "rate",
|
|
87
81
|
codeKey: "code",
|
|
88
82
|
})));
|
|
89
|
-
if (pageId !== undefined) {
|
|
90
|
-
this.orientation = new fields_1.Orientation({
|
|
91
|
-
prediction: apiPrediction.orientation,
|
|
92
|
-
pageId,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
83
|
}, _Receipt_checklist = function _Receipt_checklist() {
|
|
96
84
|
this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_taxesMatchTotal).call(this) };
|
|
97
85
|
}, _Receipt_taxesMatchTotal = function _Receipt_taxesMatchTotal() {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseField, FieldConstructor } from "./field";
|
|
2
|
+
import { Polygon } from "../geometry";
|
|
3
|
+
export declare class CropperField extends BaseField {
|
|
4
|
+
/** Straight rectangle. */
|
|
5
|
+
boundingBox: Polygon;
|
|
6
|
+
/** Free polygon with up to 30 vertices. */
|
|
7
|
+
polygon: Polygon;
|
|
8
|
+
/** Free polygon with 4 vertices. */
|
|
9
|
+
quadrangle: Polygon;
|
|
10
|
+
/** Rectangle that may be oriented (can go beyond the canvas). */
|
|
11
|
+
rectangle: Polygon;
|
|
12
|
+
/** The document page on which the information was found. */
|
|
13
|
+
pageId: number | undefined;
|
|
14
|
+
constructor({ prediction, valueKey, pageId }: FieldConstructor);
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CropperField = void 0;
|
|
4
|
+
const field_1 = require("./field");
|
|
5
|
+
class CropperField extends field_1.BaseField {
|
|
6
|
+
constructor({ prediction, valueKey = "polygon", pageId }) {
|
|
7
|
+
super({ prediction, valueKey });
|
|
8
|
+
this.pageId = pageId;
|
|
9
|
+
this.boundingBox = prediction.bounding_box;
|
|
10
|
+
this.polygon = prediction.polygon;
|
|
11
|
+
this.quadrangle = prediction.quadrangle;
|
|
12
|
+
this.rectangle = prediction.rectangle;
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `Polygon with ${this.polygon.length} points.`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.CropperField = CropperField;
|
|
@@ -8,7 +8,7 @@ export declare class ClassificationField {
|
|
|
8
8
|
});
|
|
9
9
|
toString(): string;
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class ListFieldValue {
|
|
12
12
|
content: any;
|
|
13
13
|
/**
|
|
14
14
|
* The confidence score of the prediction.
|
|
@@ -29,7 +29,7 @@ export declare class ListFieldItem {
|
|
|
29
29
|
toString(): string;
|
|
30
30
|
}
|
|
31
31
|
export declare class ListField {
|
|
32
|
-
values:
|
|
32
|
+
readonly values: ListFieldValue[];
|
|
33
33
|
confidence: number;
|
|
34
34
|
/** True if the field was reconstructed or computed using other fields. */
|
|
35
35
|
reconstructed: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListField = exports.
|
|
3
|
+
exports.ListField = exports.ListFieldValue = exports.ClassificationField = void 0;
|
|
4
4
|
const geometry_1 = require("../geometry");
|
|
5
5
|
class ClassificationField {
|
|
6
6
|
constructor({ prediction }) {
|
|
@@ -12,7 +12,7 @@ class ClassificationField {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
exports.ClassificationField = ClassificationField;
|
|
15
|
-
class
|
|
15
|
+
class ListFieldValue {
|
|
16
16
|
constructor(prediction) {
|
|
17
17
|
/**
|
|
18
18
|
* Contains exactly 4 relative vertices coordinates (points) of a right
|
|
@@ -35,7 +35,7 @@ class ListFieldItem {
|
|
|
35
35
|
return `${this.content}`;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.
|
|
38
|
+
exports.ListFieldValue = ListFieldValue;
|
|
39
39
|
class ListField {
|
|
40
40
|
constructor({ prediction, reconstructed = false, pageId }) {
|
|
41
41
|
this.values = [];
|
|
@@ -44,7 +44,7 @@ class ListField {
|
|
|
44
44
|
this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
|
|
45
45
|
if (Object.prototype.hasOwnProperty.call(prediction, "values")) {
|
|
46
46
|
prediction["values"].forEach((field) => {
|
|
47
|
-
this.values.push(new
|
|
47
|
+
this.values.push(new ListFieldValue(field));
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -3,24 +3,28 @@ export declare type stringDict = {
|
|
|
3
3
|
[index: string]: any;
|
|
4
4
|
};
|
|
5
5
|
export interface FieldConstructor {
|
|
6
|
-
prediction:
|
|
7
|
-
[index: string]: any;
|
|
8
|
-
};
|
|
6
|
+
prediction: stringDict;
|
|
9
7
|
valueKey?: string;
|
|
10
8
|
reconstructed?: boolean;
|
|
11
9
|
pageId?: number | undefined;
|
|
12
10
|
}
|
|
13
|
-
interface BaseFieldConstructor {
|
|
11
|
+
export interface BaseFieldConstructor {
|
|
14
12
|
prediction: stringDict;
|
|
15
|
-
valueKey
|
|
13
|
+
valueKey?: string;
|
|
14
|
+
reconstructed?: boolean;
|
|
16
15
|
}
|
|
17
16
|
export declare class BaseField {
|
|
18
17
|
value?: any;
|
|
18
|
+
/**
|
|
19
|
+
* True if the field was reconstructed or computed using other fields.
|
|
20
|
+
*/
|
|
21
|
+
reconstructed: boolean;
|
|
19
22
|
/**
|
|
20
23
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
21
24
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
25
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
22
26
|
*/
|
|
23
|
-
constructor({ prediction, valueKey }: BaseFieldConstructor);
|
|
27
|
+
constructor({ prediction, valueKey, reconstructed, }: BaseFieldConstructor);
|
|
24
28
|
}
|
|
25
29
|
export declare class Field extends BaseField {
|
|
26
30
|
/**
|
|
@@ -39,10 +43,6 @@ export declare class Field extends BaseField {
|
|
|
39
43
|
* The confidence score of the prediction.
|
|
40
44
|
*/
|
|
41
45
|
confidence: number;
|
|
42
|
-
/**
|
|
43
|
-
* True if the field was reconstructed or computed using other fields.
|
|
44
|
-
*/
|
|
45
|
-
reconstructed: boolean;
|
|
46
46
|
/**
|
|
47
47
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
48
48
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
@@ -71,4 +71,3 @@ export declare class Field extends BaseField {
|
|
|
71
71
|
static arraySum(array: any): number;
|
|
72
72
|
toString(): string;
|
|
73
73
|
}
|
|
74
|
-
export {};
|
|
@@ -6,9 +6,11 @@ class BaseField {
|
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
8
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
9
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
9
10
|
*/
|
|
10
|
-
constructor({ prediction, valueKey }) {
|
|
11
|
+
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
11
12
|
this.value = undefined;
|
|
13
|
+
this.reconstructed = reconstructed;
|
|
12
14
|
if (valueKey in prediction && prediction[valueKey] !== null) {
|
|
13
15
|
this.value = prediction[valueKey];
|
|
14
16
|
}
|
|
@@ -24,7 +26,7 @@ class Field extends BaseField {
|
|
|
24
26
|
* @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
|
|
25
27
|
*/
|
|
26
28
|
constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
|
|
27
|
-
super({ prediction, valueKey });
|
|
29
|
+
super({ prediction, valueKey, reconstructed });
|
|
28
30
|
/**
|
|
29
31
|
* Contains exactly 4 relative vertices coordinates (points) of a right
|
|
30
32
|
* rectangle containing the field in the document.
|
|
@@ -36,7 +38,6 @@ class Field extends BaseField {
|
|
|
36
38
|
*/
|
|
37
39
|
this.polygon = [];
|
|
38
40
|
this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
|
|
39
|
-
this.reconstructed = reconstructed;
|
|
40
41
|
this.confidence = prediction.confidence ? prediction.confidence : 0.0;
|
|
41
42
|
if (prediction.polygon) {
|
|
42
43
|
this.polygon = prediction.polygon;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { TaxField } from "./tax";
|
|
2
2
|
export { PaymentDetails } from "./paymentDetails";
|
|
3
|
-
export {
|
|
3
|
+
export { OrientationField } from "./orientation";
|
|
4
4
|
export { Locale } from "./locale";
|
|
5
5
|
export { Amount } from "./amount";
|
|
6
6
|
export { DateField } from "./date";
|
|
7
|
-
export { BaseField } from "./field";
|
|
8
|
-
export {
|
|
9
|
-
export { ListField, ListFieldItem, ClassificationField } from "./customDocs";
|
|
7
|
+
export { BaseField, stringDict, Field } from "./field";
|
|
8
|
+
export { ListField, ListFieldValue, ClassificationField } from "./customDocs";
|
|
10
9
|
export { FullText } from "./fullText";
|
|
11
10
|
export { CompanyRegistration } from "./companyRegistration";
|
|
11
|
+
export { CropperField } from "./cropper";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompanyRegistration = exports.FullText = exports.ClassificationField = exports.
|
|
3
|
+
exports.CropperField = exports.CompanyRegistration = exports.FullText = exports.ClassificationField = exports.ListFieldValue = exports.ListField = exports.Field = exports.BaseField = exports.DateField = exports.Amount = exports.Locale = exports.OrientationField = exports.PaymentDetails = exports.TaxField = void 0;
|
|
4
4
|
var tax_1 = require("./tax");
|
|
5
5
|
Object.defineProperty(exports, "TaxField", { enumerable: true, get: function () { return tax_1.TaxField; } });
|
|
6
6
|
var paymentDetails_1 = require("./paymentDetails");
|
|
7
7
|
Object.defineProperty(exports, "PaymentDetails", { enumerable: true, get: function () { return paymentDetails_1.PaymentDetails; } });
|
|
8
8
|
var orientation_1 = require("./orientation");
|
|
9
|
-
Object.defineProperty(exports, "
|
|
9
|
+
Object.defineProperty(exports, "OrientationField", { enumerable: true, get: function () { return orientation_1.OrientationField; } });
|
|
10
10
|
var locale_1 = require("./locale");
|
|
11
11
|
Object.defineProperty(exports, "Locale", { enumerable: true, get: function () { return locale_1.Locale; } });
|
|
12
12
|
var amount_1 = require("./amount");
|
|
@@ -15,13 +15,14 @@ var date_1 = require("./date");
|
|
|
15
15
|
Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return date_1.DateField; } });
|
|
16
16
|
var field_1 = require("./field");
|
|
17
17
|
Object.defineProperty(exports, "BaseField", { enumerable: true, get: function () { return field_1.BaseField; } });
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return field_2.Field; } });
|
|
18
|
+
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return field_1.Field; } });
|
|
20
19
|
var customDocs_1 = require("./customDocs");
|
|
21
20
|
Object.defineProperty(exports, "ListField", { enumerable: true, get: function () { return customDocs_1.ListField; } });
|
|
22
|
-
Object.defineProperty(exports, "
|
|
21
|
+
Object.defineProperty(exports, "ListFieldValue", { enumerable: true, get: function () { return customDocs_1.ListFieldValue; } });
|
|
23
22
|
Object.defineProperty(exports, "ClassificationField", { enumerable: true, get: function () { return customDocs_1.ClassificationField; } });
|
|
24
23
|
var fullText_1 = require("./fullText");
|
|
25
24
|
Object.defineProperty(exports, "FullText", { enumerable: true, get: function () { return fullText_1.FullText; } });
|
|
26
25
|
var companyRegistration_1 = require("./companyRegistration");
|
|
27
26
|
Object.defineProperty(exports, "CompanyRegistration", { enumerable: true, get: function () { return companyRegistration_1.CompanyRegistration; } });
|
|
27
|
+
var cropper_1 = require("./cropper");
|
|
28
|
+
Object.defineProperty(exports, "CropperField", { enumerable: true, get: function () { return cropper_1.CropperField; } });
|
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BaseField, BaseFieldConstructor } from "./field";
|
|
2
|
+
interface OrientationFieldConstructor extends BaseFieldConstructor {
|
|
3
|
+
pageId: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class OrientationField extends BaseField {
|
|
6
|
+
value: number;
|
|
7
|
+
pageId: number;
|
|
3
8
|
/**
|
|
4
9
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
5
10
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
6
11
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
7
12
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
8
13
|
*/
|
|
9
|
-
constructor({ prediction, valueKey, reconstructed, pageId, }:
|
|
14
|
+
constructor({ prediction, valueKey, reconstructed, pageId, }: OrientationFieldConstructor);
|
|
15
|
+
toString(): string;
|
|
10
16
|
}
|
|
17
|
+
export {};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OrientationField = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
|
-
class
|
|
5
|
+
class OrientationField extends field_1.BaseField {
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
8
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
9
9
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
10
10
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
11
11
|
*/
|
|
12
|
-
constructor({ prediction, valueKey = "
|
|
12
|
+
constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
|
|
13
|
+
super({ prediction, valueKey, reconstructed });
|
|
13
14
|
const orientations = [0, 90, 180, 270];
|
|
14
|
-
|
|
15
|
+
this.pageId = pageId;
|
|
15
16
|
this.value = parseInt(prediction[valueKey]);
|
|
16
|
-
if (isNaN(this.value))
|
|
17
|
-
this.confidence = 0.0;
|
|
18
17
|
if (!orientations.includes(this.value))
|
|
19
18
|
this.value = 0;
|
|
20
19
|
}
|
|
20
|
+
toString() {
|
|
21
|
+
return `${this.value} degrees`;
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
|
-
exports.
|
|
24
|
+
exports.OrientationField = OrientationField;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,7 +13,6 @@ class TaxField extends field_1.Field {
|
|
|
13
13
|
* @param {Integer} pageNumber - Page ID for multi-page document
|
|
14
14
|
*/
|
|
15
15
|
constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code", reconstructed = false, pageId = undefined, }) {
|
|
16
|
-
var _a;
|
|
17
16
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
18
17
|
/** The tax amount. */
|
|
19
18
|
this.value = undefined;
|
|
@@ -24,7 +23,7 @@ class TaxField extends field_1.Field {
|
|
|
24
23
|
this.rate = +parseFloat(prediction[rateKey]);
|
|
25
24
|
if (isNaN(this.rate))
|
|
26
25
|
this.rate = undefined;
|
|
27
|
-
this.code =
|
|
26
|
+
this.code = prediction[codeKey]?.toString();
|
|
28
27
|
if (this.code === "N/A" || this.code === "None") {
|
|
29
28
|
this.code = undefined;
|
|
30
29
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Response, FinancialDocResponse, InvoiceResponse, PassportResponse, ReceiptResponse, CustomResponse, } from "./api";
|
|
1
|
+
export { Response, FinancialDocResponse, InvoiceResponse, PassportResponse, ReceiptResponse, CustomResponse, CropperResponse, } from "./api";
|
|
2
2
|
export { Client } from "./client";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = exports.CustomResponse = exports.ReceiptResponse = exports.PassportResponse = exports.InvoiceResponse = exports.FinancialDocResponse = exports.Response = void 0;
|
|
3
|
+
exports.Client = exports.CropperResponse = exports.CustomResponse = exports.ReceiptResponse = exports.PassportResponse = exports.InvoiceResponse = exports.FinancialDocResponse = exports.Response = void 0;
|
|
4
4
|
var api_1 = require("./api");
|
|
5
5
|
Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return api_1.Response; } });
|
|
6
6
|
Object.defineProperty(exports, "FinancialDocResponse", { enumerable: true, get: function () { return api_1.FinancialDocResponse; } });
|
|
@@ -8,5 +8,6 @@ Object.defineProperty(exports, "InvoiceResponse", { enumerable: true, get: funct
|
|
|
8
8
|
Object.defineProperty(exports, "PassportResponse", { enumerable: true, get: function () { return api_1.PassportResponse; } });
|
|
9
9
|
Object.defineProperty(exports, "ReceiptResponse", { enumerable: true, get: function () { return api_1.ReceiptResponse; } });
|
|
10
10
|
Object.defineProperty(exports, "CustomResponse", { enumerable: true, get: function () { return api_1.CustomResponse; } });
|
|
11
|
+
Object.defineProperty(exports, "CropperResponse", { enumerable: true, get: function () { return api_1.CropperResponse; } });
|
|
11
12
|
var client_1 = require("./client");
|
|
12
13
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
File without changes
|