mindee 3.4.0 → 3.4.1
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 +9 -0
- package/README.md +5 -0
- package/package.json +19 -19
- package/src/api/index.d.ts +1 -1
- package/src/api/response.d.ts +3 -0
- package/src/client.d.ts +3 -3
- package/src/client.js +1 -1
- package/src/documents/{custom.d.ts → custom/customV1.d.ts} +4 -4
- package/src/documents/{custom.js → custom/customV1.js} +2 -2
- package/src/{fields/apiBuilder.d.ts → documents/custom/fields.d.ts} +8 -6
- package/src/{fields/apiBuilder.js → documents/custom/fields.js} +1 -1
- package/src/documents/document.d.ts +4 -4
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +2 -2
- package/src/documents/eu/licensePlate/licensePlateV1.js +1 -1
- package/src/documents/financialDocument/financialDocumentV1.d.ts +9 -9
- package/src/documents/financialDocument/financialDocumentV1.js +5 -5
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +4 -4
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +3 -3
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +4 -4
- package/src/documents/fr/carteVitale/carteVitaleV1.js +3 -3
- package/src/documents/fr/idCard/idCardV1.d.ts +9 -9
- package/src/documents/fr/idCard/idCardV1.js +8 -8
- package/src/documents/index.d.ts +1 -1
- package/src/documents/index.js +2 -2
- package/src/documents/invoice/invoiceLineItem.d.ts +2 -2
- package/src/documents/invoice/invoiceV3.d.ts +7 -7
- package/src/documents/invoice/invoiceV3.js +5 -5
- package/src/documents/invoice/invoiceV4.d.ts +7 -9
- package/src/documents/invoice/invoiceV4.js +6 -6
- package/src/documents/invoice/reconstruction.js +5 -4
- package/src/documents/passport/passportV1.d.ts +11 -11
- package/src/documents/passport/passportV1.js +15 -13
- package/src/documents/receipt/receiptV3.d.ts +4 -4
- package/src/documents/receipt/receiptV3.js +6 -7
- package/src/documents/receipt/receiptV4.d.ts +6 -6
- package/src/documents/receipt/receiptV4.js +5 -6
- package/src/documents/shipping_container/shippingContainerV1.d.ts +4 -4
- package/src/documents/shipping_container/shippingContainerV1.js +3 -3
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +5 -5
- package/src/documents/us/bankCheck/bankCheckV1.js +4 -4
- package/src/fields/amount.d.ts +1 -1
- package/src/fields/amount.js +2 -0
- package/src/fields/base.d.ts +27 -0
- package/src/fields/base.js +53 -0
- package/src/fields/companyRegistration.d.ts +3 -1
- package/src/fields/date.d.ts +4 -1
- package/src/fields/date.js +16 -8
- package/src/fields/field.d.ts +8 -38
- package/src/fields/field.js +6 -53
- package/src/fields/fullText.d.ts +1 -1
- package/src/fields/fullText.js +4 -4
- package/src/fields/index.d.ts +3 -3
- package/src/fields/index.js +5 -8
- package/src/fields/locale.d.ts +13 -9
- package/src/fields/locale.js +4 -3
- package/src/fields/orientation.d.ts +3 -1
- package/src/fields/orientation.js +2 -2
- package/src/fields/paymentDetails.d.ts +4 -1
- package/src/fields/paymentDetails.js +26 -23
- package/src/fields/position.d.ts +2 -2
- package/src/fields/tax.d.ts +2 -1
- package/src/fields/text.d.ts +13 -0
- package/src/fields/text.js +10 -0
- package/src/geometry.d.ts +1 -2
- package/src/index.d.ts +4 -3
- package/src/index.js +5 -1
- package/src/inputs/sources.d.ts +4 -4
- package/src/inputs/sources.js +9 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { TaxField, PaymentDetails, Locale, Amount,
|
|
2
|
+
import { TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration, BaseField } from "../../fields";
|
|
3
3
|
import { InvoiceLineItem } from "./invoiceLineItem";
|
|
4
4
|
export declare class InvoiceV4 extends Document {
|
|
5
5
|
#private;
|
|
@@ -8,33 +8,31 @@ export declare class InvoiceV4 extends Document {
|
|
|
8
8
|
/** The nature of the invoice. */
|
|
9
9
|
documentType: BaseField;
|
|
10
10
|
/** List of Reference numbers including PO number. */
|
|
11
|
-
referenceNumbers:
|
|
11
|
+
referenceNumbers: TextField[];
|
|
12
12
|
/** The total amount with tax included. */
|
|
13
13
|
totalAmount: Amount;
|
|
14
14
|
/** The creation date of the invoice. */
|
|
15
15
|
date: DateField;
|
|
16
16
|
/** The due date of the invoice. */
|
|
17
17
|
dueDate: DateField;
|
|
18
|
-
/** The created time of the invoice */
|
|
19
|
-
time: Field;
|
|
20
18
|
/** The total tax. */
|
|
21
19
|
totalTax: Amount;
|
|
22
20
|
/** The total amount without the tax value. */
|
|
23
21
|
totalNet: Amount;
|
|
24
22
|
/** The supplier name. */
|
|
25
|
-
supplierName:
|
|
23
|
+
supplierName: TextField;
|
|
26
24
|
/** The supplier address. */
|
|
27
|
-
supplierAddress:
|
|
25
|
+
supplierAddress: TextField;
|
|
28
26
|
/** The payment information. */
|
|
29
27
|
supplierPaymentDetails: PaymentDetails[];
|
|
30
28
|
/** The supplier company regitration information. */
|
|
31
29
|
supplierCompanyRegistrations: CompanyRegistration[];
|
|
32
30
|
/** The invoice number. */
|
|
33
|
-
invoiceNumber:
|
|
31
|
+
invoiceNumber: TextField;
|
|
34
32
|
/** The name of the customer. */
|
|
35
|
-
customerName:
|
|
33
|
+
customerName: TextField;
|
|
36
34
|
/** The address of the customer. */
|
|
37
|
-
customerAddress:
|
|
35
|
+
customerAddress: TextField;
|
|
38
36
|
/** The company registration information for the customer. */
|
|
39
37
|
customerCompanyRegistrations: CompanyRegistration[];
|
|
40
38
|
/** The list of the taxes. */
|
|
@@ -93,7 +93,7 @@ _InvoiceV4_instances = new WeakSet(), _InvoiceV4_initFromApiPrediction = functio
|
|
|
93
93
|
valueKey: "value",
|
|
94
94
|
});
|
|
95
95
|
this.referenceNumbers = apiPrediction.reference_numbers.map(function (prediction) {
|
|
96
|
-
return new fields_1.
|
|
96
|
+
return new fields_1.TextField({
|
|
97
97
|
prediction: prediction,
|
|
98
98
|
pageId: pageId,
|
|
99
99
|
});
|
|
@@ -135,23 +135,23 @@ _InvoiceV4_instances = new WeakSet(), _InvoiceV4_initFromApiPrediction = functio
|
|
|
135
135
|
prediction: apiPrediction.due_date,
|
|
136
136
|
pageId: pageId,
|
|
137
137
|
});
|
|
138
|
-
this.invoiceNumber = new fields_1.
|
|
138
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
139
139
|
prediction: apiPrediction.invoice_number,
|
|
140
140
|
pageId: pageId,
|
|
141
141
|
});
|
|
142
|
-
this.supplierName = new fields_1.
|
|
142
|
+
this.supplierName = new fields_1.TextField({
|
|
143
143
|
prediction: apiPrediction.supplier_name,
|
|
144
144
|
pageId: pageId,
|
|
145
145
|
});
|
|
146
|
-
this.supplierAddress = new fields_1.
|
|
146
|
+
this.supplierAddress = new fields_1.TextField({
|
|
147
147
|
prediction: apiPrediction.supplier_address,
|
|
148
148
|
pageId: pageId,
|
|
149
149
|
});
|
|
150
|
-
this.customerName = new fields_1.
|
|
150
|
+
this.customerName = new fields_1.TextField({
|
|
151
151
|
prediction: apiPrediction.customer_name,
|
|
152
152
|
pageId: pageId,
|
|
153
153
|
});
|
|
154
|
-
this.customerAddress = new fields_1.
|
|
154
|
+
this.customerAddress = new fields_1.TextField({
|
|
155
155
|
prediction: apiPrediction.customer_address,
|
|
156
156
|
pageId: pageId,
|
|
157
157
|
});
|
|
@@ -8,7 +8,7 @@ function reconstructTotalTax(document) {
|
|
|
8
8
|
value: document.taxes.reduce((acc, tax) => {
|
|
9
9
|
return tax.value !== undefined ? acc + tax.value : acc;
|
|
10
10
|
}, 0),
|
|
11
|
-
confidence: fields_1.
|
|
11
|
+
confidence: fields_1.TextField.arrayConfidence(document.taxes),
|
|
12
12
|
};
|
|
13
13
|
if (totalTax.value > 0)
|
|
14
14
|
document.totalTax = new fields_1.Amount({
|
|
@@ -45,8 +45,8 @@ function reconstructTotalExcl(document) {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const totalExcl = {
|
|
48
|
-
value: document.totalAmount.value - fields_1.
|
|
49
|
-
confidence: fields_1.
|
|
48
|
+
value: document.totalAmount.value - fields_1.TextField.arraySum(document.taxes),
|
|
49
|
+
confidence: fields_1.TextField.arrayConfidence(document.taxes) *
|
|
50
50
|
document.totalAmount.confidence,
|
|
51
51
|
};
|
|
52
52
|
document.totalNet = new fields_1.Amount({
|
|
@@ -65,7 +65,8 @@ function reconstructTotalIncl(document) {
|
|
|
65
65
|
document.taxes.reduce((acc, tax) => {
|
|
66
66
|
return tax.value ? acc + tax.value : acc;
|
|
67
67
|
}, 0.0),
|
|
68
|
-
confidence: fields_1.
|
|
68
|
+
confidence: fields_1.TextField.arrayConfidence(document.taxes) *
|
|
69
|
+
document.totalNet.confidence,
|
|
69
70
|
};
|
|
70
71
|
document.totalAmount = new fields_1.Amount({
|
|
71
72
|
prediction: totalIncl,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import {
|
|
2
|
+
import { DateField, TextField } from "../../fields";
|
|
3
3
|
export declare class PassportV1 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** The country of issue. */
|
|
6
|
-
country:
|
|
6
|
+
country: TextField;
|
|
7
7
|
/** The passport number. */
|
|
8
|
-
idNumber:
|
|
8
|
+
idNumber: TextField;
|
|
9
9
|
/** The date of birth of the passport holder. */
|
|
10
10
|
birthDate: DateField;
|
|
11
11
|
/** The expiration date of the passport. */
|
|
@@ -13,21 +13,21 @@ export declare class PassportV1 extends Document {
|
|
|
13
13
|
/** The issuance date.*/
|
|
14
14
|
issuanceDate: DateField;
|
|
15
15
|
/** The place of birth of the passport holder. */
|
|
16
|
-
birthPlace:
|
|
16
|
+
birthPlace: TextField;
|
|
17
17
|
/** The sex or gender of the passport holder. */
|
|
18
|
-
gender:
|
|
18
|
+
gender: TextField;
|
|
19
19
|
/** The surname of the person. */
|
|
20
|
-
surname:
|
|
20
|
+
surname: TextField;
|
|
21
21
|
/** The value of the first mrz line. */
|
|
22
|
-
mrz1:
|
|
22
|
+
mrz1: TextField;
|
|
23
23
|
/** The value of the second mrz line. */
|
|
24
|
-
mrz2:
|
|
24
|
+
mrz2: TextField;
|
|
25
25
|
/** List of first (given) names of the passport holder. */
|
|
26
|
-
givenNames:
|
|
26
|
+
givenNames: TextField[];
|
|
27
27
|
/** The full name of the passport holder. */
|
|
28
|
-
fullName:
|
|
28
|
+
fullName: TextField;
|
|
29
29
|
/** All the mrz values combined. */
|
|
30
|
-
mrz:
|
|
30
|
+
mrz: TextField;
|
|
31
31
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
32
32
|
static convertMRZDateToDatetime(dateString: string): Date;
|
|
33
33
|
toString(): string;
|
|
@@ -32,7 +32,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.PassportV1 = void 0;
|
|
33
33
|
const document_1 = require("../document");
|
|
34
34
|
const fields_1 = require("../../fields");
|
|
35
|
-
// @ts-ignore
|
|
36
35
|
const MRZ = __importStar(require("mrz"));
|
|
37
36
|
class PassportV1 extends document_1.Document {
|
|
38
37
|
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
|
|
@@ -45,11 +44,11 @@ class PassportV1 extends document_1.Document {
|
|
|
45
44
|
_PassportV1_instances.add(this);
|
|
46
45
|
/** List of first (given) names of the passport holder. */
|
|
47
46
|
this.givenNames = [];
|
|
48
|
-
this.country = new fields_1.
|
|
47
|
+
this.country = new fields_1.TextField({
|
|
49
48
|
prediction: prediction.country,
|
|
50
49
|
pageId: pageId,
|
|
51
50
|
});
|
|
52
|
-
this.idNumber = new fields_1.
|
|
51
|
+
this.idNumber = new fields_1.TextField({
|
|
53
52
|
prediction: prediction.id_number,
|
|
54
53
|
pageId: pageId,
|
|
55
54
|
});
|
|
@@ -65,27 +64,27 @@ class PassportV1 extends document_1.Document {
|
|
|
65
64
|
prediction: prediction.issuance_date,
|
|
66
65
|
pageId: pageId,
|
|
67
66
|
});
|
|
68
|
-
this.birthPlace = new fields_1.
|
|
67
|
+
this.birthPlace = new fields_1.TextField({
|
|
69
68
|
prediction: prediction.birth_place,
|
|
70
69
|
pageId: pageId,
|
|
71
70
|
});
|
|
72
|
-
this.gender = new fields_1.
|
|
71
|
+
this.gender = new fields_1.TextField({
|
|
73
72
|
prediction: prediction.gender,
|
|
74
73
|
pageId: pageId,
|
|
75
74
|
});
|
|
76
|
-
this.surname = new fields_1.
|
|
75
|
+
this.surname = new fields_1.TextField({
|
|
77
76
|
prediction: prediction.surname,
|
|
78
77
|
pageId: pageId,
|
|
79
78
|
});
|
|
80
|
-
this.mrz1 = new fields_1.
|
|
79
|
+
this.mrz1 = new fields_1.TextField({
|
|
81
80
|
prediction: prediction.mrz1,
|
|
82
81
|
pageId: pageId,
|
|
83
82
|
});
|
|
84
|
-
this.mrz2 = new fields_1.
|
|
83
|
+
this.mrz2 = new fields_1.TextField({
|
|
85
84
|
prediction: prediction.mrz2,
|
|
86
85
|
pageId: pageId,
|
|
87
86
|
});
|
|
88
|
-
prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.
|
|
87
|
+
prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.TextField({
|
|
89
88
|
prediction: prediction,
|
|
90
89
|
pageId: pageId,
|
|
91
90
|
})));
|
|
@@ -179,9 +178,12 @@ MRZ: ${this.mrz}
|
|
|
179
178
|
this.givenNames[0].value) {
|
|
180
179
|
const fullName = {
|
|
181
180
|
value: `${this.givenNames[0].value} ${this.surname.value}`,
|
|
182
|
-
confidence: fields_1.
|
|
181
|
+
confidence: fields_1.TextField.arrayConfidence([
|
|
182
|
+
this.surname,
|
|
183
|
+
this.givenNames[0],
|
|
184
|
+
]),
|
|
183
185
|
};
|
|
184
|
-
return new fields_1.
|
|
186
|
+
return new fields_1.TextField({
|
|
185
187
|
prediction: fullName,
|
|
186
188
|
pageId: pageNumber,
|
|
187
189
|
reconstructed: true,
|
|
@@ -192,9 +194,9 @@ MRZ: ${this.mrz}
|
|
|
192
194
|
if (this.mrz1.value && this.mrz2.value) {
|
|
193
195
|
const mrz = {
|
|
194
196
|
value: `${this.mrz1.value}${this.mrz2.value}`,
|
|
195
|
-
confidence: fields_1.
|
|
197
|
+
confidence: fields_1.TextField.arrayConfidence([this.mrz1, this.mrz2]),
|
|
196
198
|
};
|
|
197
|
-
return new fields_1.
|
|
199
|
+
return new fields_1.TextField({
|
|
198
200
|
prediction: mrz,
|
|
199
201
|
pageId: pageNumber,
|
|
200
202
|
reconstructed: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { TaxField,
|
|
2
|
+
import { TaxField, TextField, Amount, Locale, DateField } from "../../fields";
|
|
3
3
|
export declare class ReceiptV3 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Total amount with the tax amount of the purchase. */
|
|
@@ -9,11 +9,11 @@ export declare class ReceiptV3 extends Document {
|
|
|
9
9
|
/** The purchase date. */
|
|
10
10
|
date: DateField;
|
|
11
11
|
/** The type of purchase. */
|
|
12
|
-
category:
|
|
12
|
+
category: TextField;
|
|
13
13
|
/** Merchant's name as seen on the receipt. */
|
|
14
|
-
merchantName:
|
|
14
|
+
merchantName: TextField;
|
|
15
15
|
/** Time as seen on the receipt in HH:MM format. */
|
|
16
|
-
time:
|
|
16
|
+
time: TextField;
|
|
17
17
|
/** Total tax amount of the purchase. */
|
|
18
18
|
totalTax: Amount;
|
|
19
19
|
/** Total amount without tax of the purchase. */
|
|
@@ -23,7 +23,6 @@ class ReceiptV3 extends document_1.Document {
|
|
|
23
23
|
this.taxes = [];
|
|
24
24
|
this.locale = new fields_1.Locale({
|
|
25
25
|
prediction: prediction.locale,
|
|
26
|
-
pageId: pageId,
|
|
27
26
|
});
|
|
28
27
|
this.totalTax = new fields_1.Amount({
|
|
29
28
|
prediction: { value: undefined, confidence: 0 },
|
|
@@ -68,15 +67,15 @@ _ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = functio
|
|
|
68
67
|
prediction: apiPrediction.date,
|
|
69
68
|
pageId: pageId,
|
|
70
69
|
});
|
|
71
|
-
this.category = new fields_1.
|
|
70
|
+
this.category = new fields_1.TextField({
|
|
72
71
|
prediction: apiPrediction.category,
|
|
73
72
|
pageId: pageId,
|
|
74
73
|
});
|
|
75
|
-
this.merchantName = new fields_1.
|
|
74
|
+
this.merchantName = new fields_1.TextField({
|
|
76
75
|
prediction: apiPrediction.supplier,
|
|
77
76
|
pageId: pageId,
|
|
78
77
|
});
|
|
79
|
-
this.time = new fields_1.
|
|
78
|
+
this.time = new fields_1.TextField({
|
|
80
79
|
prediction: apiPrediction.time,
|
|
81
80
|
pageId: pageId,
|
|
82
81
|
});
|
|
@@ -124,8 +123,8 @@ _ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = functio
|
|
|
124
123
|
}, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes = function _ReceiptV3_reconstructTotalExclFromTCCAndTaxes() {
|
|
125
124
|
if (this.taxes.length && this.totalIncl.value !== undefined) {
|
|
126
125
|
const totalExcl = {
|
|
127
|
-
value: this.totalIncl.value - fields_1.
|
|
128
|
-
confidence: fields_1.
|
|
126
|
+
value: this.totalIncl.value - fields_1.TextField.arraySum(this.taxes),
|
|
127
|
+
confidence: fields_1.TextField.arrayConfidence(this.taxes) *
|
|
129
128
|
this.totalIncl.confidence,
|
|
130
129
|
};
|
|
131
130
|
this.totalExcl = new fields_1.Amount({
|
|
@@ -140,7 +139,7 @@ _ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = functio
|
|
|
140
139
|
value: this.taxes
|
|
141
140
|
.map((tax) => tax.value || 0)
|
|
142
141
|
.reduce((a, b) => a + b, 0),
|
|
143
|
-
confidence: fields_1.
|
|
142
|
+
confidence: fields_1.TextField.arrayConfidence(this.taxes),
|
|
144
143
|
};
|
|
145
144
|
if (totalTax.value > 0)
|
|
146
145
|
this.totalTax = new fields_1.Amount({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { Amount, DateField,
|
|
2
|
+
import { Amount, DateField, TextField, Locale, TaxField } from "../../fields";
|
|
3
3
|
export declare class ReceiptV4 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Where the purchase was made, the language, and the currency. */
|
|
@@ -7,15 +7,15 @@ export declare class ReceiptV4 extends Document {
|
|
|
7
7
|
/** The purchase date. */
|
|
8
8
|
date: DateField;
|
|
9
9
|
/** The type of purchase. */
|
|
10
|
-
category:
|
|
10
|
+
category: TextField;
|
|
11
11
|
/** The receipt sub category among predefined classes. */
|
|
12
|
-
subCategory:
|
|
12
|
+
subCategory: TextField;
|
|
13
13
|
/** The receipt document type provdes the information whether the document is an expense receipt or a credit card receipt. */
|
|
14
|
-
documentType:
|
|
14
|
+
documentType: TextField;
|
|
15
15
|
/** Merchant's name as seen on the receipt. */
|
|
16
|
-
supplier:
|
|
16
|
+
supplier: TextField;
|
|
17
17
|
/** Time as seen on the receipt in HH:MM format. */
|
|
18
|
-
time:
|
|
18
|
+
time: TextField;
|
|
19
19
|
/** List of taxes detected on the receipt. */
|
|
20
20
|
taxes: TaxField[];
|
|
21
21
|
/** Total amount of tip and gratuity. */
|
|
@@ -49,7 +49,6 @@ exports.ReceiptV4 = ReceiptV4;
|
|
|
49
49
|
_ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = function _ReceiptV4_initFromApiPrediction(apiPrediction, pageId) {
|
|
50
50
|
this.locale = new fields_1.Locale({
|
|
51
51
|
prediction: apiPrediction.locale,
|
|
52
|
-
pageId: pageId,
|
|
53
52
|
});
|
|
54
53
|
this.totalTax = new fields_1.Amount({
|
|
55
54
|
prediction: apiPrediction.total_tax,
|
|
@@ -75,23 +74,23 @@ _ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = functio
|
|
|
75
74
|
prediction: apiPrediction.date,
|
|
76
75
|
pageId: pageId,
|
|
77
76
|
});
|
|
78
|
-
this.category = new fields_1.
|
|
77
|
+
this.category = new fields_1.TextField({
|
|
79
78
|
prediction: apiPrediction.category,
|
|
80
79
|
pageId: pageId,
|
|
81
80
|
});
|
|
82
|
-
this.subCategory = new fields_1.
|
|
81
|
+
this.subCategory = new fields_1.TextField({
|
|
83
82
|
prediction: apiPrediction.subcategory,
|
|
84
83
|
pageId: pageId,
|
|
85
84
|
});
|
|
86
|
-
this.documentType = new fields_1.
|
|
85
|
+
this.documentType = new fields_1.TextField({
|
|
87
86
|
prediction: apiPrediction.document_type,
|
|
88
87
|
pageId: pageId,
|
|
89
88
|
});
|
|
90
|
-
this.supplier = new fields_1.
|
|
89
|
+
this.supplier = new fields_1.TextField({
|
|
91
90
|
prediction: apiPrediction.supplier,
|
|
92
91
|
pageId: pageId,
|
|
93
92
|
});
|
|
94
|
-
this.time = new fields_1.
|
|
93
|
+
this.time = new fields_1.TextField({
|
|
95
94
|
prediction: apiPrediction.time,
|
|
96
95
|
pageId: pageId,
|
|
97
96
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import {
|
|
2
|
+
import { TextField } from "../../fields";
|
|
3
3
|
export declare class ShippingContainerV1 extends Document {
|
|
4
4
|
/** ISO 6346 code for container owner prefix + equipment identifier. */
|
|
5
|
-
owner:
|
|
5
|
+
owner: TextField;
|
|
6
6
|
/** ISO 6346 code for container serial number (6+1 digits). */
|
|
7
|
-
serialNumber:
|
|
7
|
+
serialNumber: TextField;
|
|
8
8
|
/** ISO 6346 code for container length, height and type. */
|
|
9
|
-
sizeType:
|
|
9
|
+
sizeType: TextField;
|
|
10
10
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
11
11
|
toString(): string;
|
|
12
12
|
}
|
|
@@ -11,15 +11,15 @@ class ShippingContainerV1 extends document_1.Document {
|
|
|
11
11
|
orientation: orientation,
|
|
12
12
|
extras: extras,
|
|
13
13
|
});
|
|
14
|
-
this.owner = new fields_1.
|
|
14
|
+
this.owner = new fields_1.TextField({
|
|
15
15
|
prediction: prediction.owner,
|
|
16
16
|
pageId: pageId,
|
|
17
17
|
});
|
|
18
|
-
this.serialNumber = new fields_1.
|
|
18
|
+
this.serialNumber = new fields_1.TextField({
|
|
19
19
|
prediction: prediction.serial_number,
|
|
20
20
|
pageId: pageId,
|
|
21
21
|
});
|
|
22
|
-
this.sizeType = new fields_1.
|
|
22
|
+
this.sizeType = new fields_1.TextField({
|
|
23
23
|
prediction: prediction.size_type,
|
|
24
24
|
pageId: pageId,
|
|
25
25
|
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../../document";
|
|
2
|
-
import {
|
|
2
|
+
import { TextField, DateField, PositionField, Amount } from "../../../fields";
|
|
3
3
|
export declare class BankCheckV1 extends Document {
|
|
4
4
|
/** Payer's bank account number. */
|
|
5
|
-
accountNumber:
|
|
5
|
+
accountNumber: TextField;
|
|
6
6
|
/** Total including taxes. */
|
|
7
7
|
amount: Amount;
|
|
8
8
|
/** Payer's bank account number. */
|
|
9
|
-
checkNumber:
|
|
9
|
+
checkNumber: TextField;
|
|
10
10
|
/** Check's position in the image. */
|
|
11
11
|
checkPosition: PositionField;
|
|
12
12
|
/** Date the check was issued. */
|
|
13
13
|
issuanceDate: DateField;
|
|
14
14
|
/** List of payees (full name or company name). */
|
|
15
|
-
payees:
|
|
15
|
+
payees: TextField[];
|
|
16
16
|
/** Payer's bank account routing number. */
|
|
17
|
-
routingNumber:
|
|
17
|
+
routingNumber: TextField;
|
|
18
18
|
/** Signatures' positions in the image. */
|
|
19
19
|
signaturesPositions: PositionField;
|
|
20
20
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
@@ -13,11 +13,11 @@ class BankCheckV1 extends document_1.Document {
|
|
|
13
13
|
});
|
|
14
14
|
/** List of payees (full name or company name). */
|
|
15
15
|
this.payees = [];
|
|
16
|
-
this.accountNumber = new fields_1.
|
|
16
|
+
this.accountNumber = new fields_1.TextField({
|
|
17
17
|
prediction: prediction.account_number,
|
|
18
18
|
pageId: pageId,
|
|
19
19
|
});
|
|
20
|
-
this.checkNumber = new fields_1.
|
|
20
|
+
this.checkNumber = new fields_1.TextField({
|
|
21
21
|
prediction: prediction.check_number,
|
|
22
22
|
pageId: pageId,
|
|
23
23
|
});
|
|
@@ -34,11 +34,11 @@ class BankCheckV1 extends document_1.Document {
|
|
|
34
34
|
prediction: prediction.date,
|
|
35
35
|
pageId: pageId,
|
|
36
36
|
});
|
|
37
|
-
prediction.payees.map((prediction) => this.payees.push(new fields_1.
|
|
37
|
+
prediction.payees.map((prediction) => this.payees.push(new fields_1.TextField({
|
|
38
38
|
prediction: prediction,
|
|
39
39
|
pageId: pageId,
|
|
40
40
|
})));
|
|
41
|
-
this.routingNumber = new fields_1.
|
|
41
|
+
this.routingNumber = new fields_1.TextField({
|
|
42
42
|
prediction: prediction.routing_number,
|
|
43
43
|
pageId: pageId,
|
|
44
44
|
});
|
package/src/fields/amount.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Field, FieldConstructor } from "./field";
|
|
|
2
2
|
export declare function floatToString(value: number): string;
|
|
3
3
|
export declare class Amount extends Field {
|
|
4
4
|
/** The value. */
|
|
5
|
-
value
|
|
5
|
+
value?: number;
|
|
6
6
|
/**
|
|
7
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
8
8
|
* @param {String} valueKey - Key to use in the prediction dict
|
package/src/fields/amount.js
CHANGED
|
@@ -19,6 +19,8 @@ class Amount extends field_1.Field {
|
|
|
19
19
|
*/
|
|
20
20
|
constructor({ prediction, valueKey = "amount", reconstructed = false, pageId = undefined, }) {
|
|
21
21
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
22
|
+
/** The value. */
|
|
23
|
+
this.value = undefined;
|
|
22
24
|
this.value = +parseFloat(prediction[valueKey]).toFixed(3);
|
|
23
25
|
if (isNaN(this.value)) {
|
|
24
26
|
this.value = undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type StringDict = {
|
|
2
|
+
[index: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export interface BaseFieldConstructor {
|
|
5
|
+
prediction: StringDict;
|
|
6
|
+
valueKey?: string;
|
|
7
|
+
reconstructed?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class BaseField {
|
|
10
|
+
/** The value. */
|
|
11
|
+
value?: string | number;
|
|
12
|
+
/** `true` when the field was reconstructed or computed using other fields. */
|
|
13
|
+
reconstructed: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @param {Object} prediction - Prediction object from HTTP response
|
|
16
|
+
* @param {String} valueKey - Key to use in the prediction dict
|
|
17
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
18
|
+
*/
|
|
19
|
+
constructor({ prediction, valueKey, reconstructed, }: BaseFieldConstructor);
|
|
20
|
+
compare(other: BaseField): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @param {BaseField[]} array - Array of Fields
|
|
23
|
+
* @returns {Number} Sum of all the Fields values in the array
|
|
24
|
+
*/
|
|
25
|
+
static arraySum(array: BaseField[]): number;
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseField = void 0;
|
|
4
|
+
class BaseField {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Object} prediction - Prediction object from HTTP response
|
|
7
|
+
* @param {String} valueKey - Key to use in the prediction dict
|
|
8
|
+
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
9
|
+
*/
|
|
10
|
+
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
11
|
+
/** The value. */
|
|
12
|
+
this.value = undefined;
|
|
13
|
+
this.reconstructed = reconstructed;
|
|
14
|
+
if (prediction !== undefined &&
|
|
15
|
+
prediction !== null &&
|
|
16
|
+
valueKey in prediction &&
|
|
17
|
+
prediction[valueKey] !== null) {
|
|
18
|
+
this.value = prediction[valueKey];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
compare(other) {
|
|
22
|
+
if (this.value === null && other.value === null)
|
|
23
|
+
return true;
|
|
24
|
+
if (this.value === null || other.value === null)
|
|
25
|
+
return false;
|
|
26
|
+
if (typeof this.value === "string" && typeof other.value === "string") {
|
|
27
|
+
return this.value.toLowerCase() === other.value.toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
return this.value === other.value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param {BaseField[]} array - Array of Fields
|
|
33
|
+
* @returns {Number} Sum of all the Fields values in the array
|
|
34
|
+
*/
|
|
35
|
+
static arraySum(array) {
|
|
36
|
+
let total = 0.0;
|
|
37
|
+
for (const field of array) {
|
|
38
|
+
if (typeof field.value !== "number")
|
|
39
|
+
return 0.0;
|
|
40
|
+
total += field.value;
|
|
41
|
+
if (isNaN(total))
|
|
42
|
+
return 0.0;
|
|
43
|
+
}
|
|
44
|
+
return total;
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
if (this.value !== undefined) {
|
|
48
|
+
return `${this.value}`;
|
|
49
|
+
}
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.BaseField = BaseField;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Field, FieldConstructor } from "./field";
|
|
2
2
|
export declare class CompanyRegistration extends Field {
|
|
3
|
-
/**
|
|
3
|
+
/** Registration identifier. */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** Type of company registration. */
|
|
4
6
|
type: string;
|
|
5
7
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
6
8
|
}
|
package/src/fields/date.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Field, FieldConstructor } from "./field";
|
|
2
2
|
export declare class DateField extends Field {
|
|
3
|
+
/** Date string in ISO format. */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** Date as a standard JavaScript `Date` object. */
|
|
6
|
+
dateObject?: Date;
|
|
3
7
|
/**
|
|
4
8
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
5
9
|
* @param {String} valueKey - Key to use in the prediction dict
|
|
6
10
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
7
11
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
8
12
|
*/
|
|
9
|
-
dateObject: Date | undefined;
|
|
10
13
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
11
14
|
static compareDates(date1: Date, date2: Date): boolean;
|
|
12
15
|
}
|
package/src/fields/date.js
CHANGED
|
@@ -3,16 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DateField = void 0;
|
|
4
4
|
const field_1 = require("./field");
|
|
5
5
|
class DateField extends field_1.Field {
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} prediction - Prediction object from HTTP response
|
|
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)
|
|
10
|
+
* @param {Integer} pageId - Page ID for multi-page document
|
|
11
|
+
*/
|
|
6
12
|
constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
|
|
7
13
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.dateObject
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (typeof this.value === "string") {
|
|
15
|
+
this.dateObject = new Date(this.value);
|
|
16
|
+
if (isNaN(this.dateObject.valueOf())) {
|
|
17
|
+
this.dateObject = undefined;
|
|
18
|
+
this.confidence = 0.0;
|
|
19
|
+
this.value = undefined;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.dateObject.setUTCHours(0, 0, 0, 0);
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
}
|
|
18
26
|
static compareDates(date1, date2) {
|