mindee 3.4.0 → 3.5.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 +17 -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/cli.js +19 -11
- package/src/client.d.ts +3 -3
- package/src/client.js +4 -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 +3 -3
- package/src/documents/eu/licensePlate/licensePlateV1.js +2 -2
- 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 +8 -7
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +4 -3
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +6 -6
- package/src/documents/fr/carteVitale/carteVitaleV1.js +5 -5
- package/src/documents/fr/idCard/idCardV1.d.ts +10 -10
- package/src/documents/fr/idCard/idCardV1.js +8 -8
- package/src/documents/index.d.ts +2 -1
- package/src/documents/index.js +6 -3
- 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/invoiceSplitter/invoiceSplitterV1.d.ts +14 -0
- package/src/documents/invoiceSplitter/invoiceSplitterV1.js +46 -0
- package/src/documents/passport/passportV1.d.ts +16 -16
- 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 +10 -10
- package/src/documents/receipt/receiptV4.js +6 -8
- 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 +8 -8
- 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 +7 -2
- package/src/fields/tax.js +10 -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
- package/src/documents/receipt/tax.d.ts +0 -25
- package/src/documents/receipt/tax.js +0 -40
package/src/documents/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { InvoiceV3 } from "./invoice/invoiceV3";
|
|
2
2
|
export { InvoiceV4 } from "./invoice/invoiceV4";
|
|
3
|
+
export { InvoiceSplitterV1, PageGroup, } from "./invoiceSplitter/invoiceSplitterV1";
|
|
3
4
|
export { ReceiptV3 } from "./receipt/receiptV3";
|
|
4
5
|
export { ReceiptV4 } from "./receipt/receiptV4";
|
|
5
6
|
export { PassportV1 } from "./passport/passportV1";
|
|
6
7
|
export { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1";
|
|
7
|
-
export { CustomV1 } from "./custom";
|
|
8
|
+
export { CustomV1 } from "./custom/customV1";
|
|
8
9
|
export { CropperV1 } from "./cropper/cropperV1";
|
|
9
10
|
export { ShippingContainerV1 } from "./shipping_container/shippingContainerV1";
|
|
10
11
|
export { Document, DocumentConstructorProps, DocumentSig } from "./document";
|
package/src/documents/index.js
CHANGED
|
@@ -23,11 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.CropperV1 = exports.CustomV1 = exports.FinancialDocumentV1 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
|
|
26
|
+
exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.CropperV1 = exports.CustomV1 = exports.FinancialDocumentV1 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
|
|
27
27
|
var invoiceV3_1 = require("./invoice/invoiceV3");
|
|
28
28
|
Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
|
|
29
29
|
var invoiceV4_1 = require("./invoice/invoiceV4");
|
|
30
30
|
Object.defineProperty(exports, "InvoiceV4", { enumerable: true, get: function () { return invoiceV4_1.InvoiceV4; } });
|
|
31
|
+
var invoiceSplitterV1_1 = require("./invoiceSplitter/invoiceSplitterV1");
|
|
32
|
+
Object.defineProperty(exports, "InvoiceSplitterV1", { enumerable: true, get: function () { return invoiceSplitterV1_1.InvoiceSplitterV1; } });
|
|
33
|
+
Object.defineProperty(exports, "PageGroup", { enumerable: true, get: function () { return invoiceSplitterV1_1.PageGroup; } });
|
|
31
34
|
var receiptV3_1 = require("./receipt/receiptV3");
|
|
32
35
|
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return receiptV3_1.ReceiptV3; } });
|
|
33
36
|
var receiptV4_1 = require("./receipt/receiptV4");
|
|
@@ -36,8 +39,8 @@ var passportV1_1 = require("./passport/passportV1");
|
|
|
36
39
|
Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } });
|
|
37
40
|
var financialDocumentV1_1 = require("./financialDocument/financialDocumentV1");
|
|
38
41
|
Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return financialDocumentV1_1.FinancialDocumentV1; } });
|
|
39
|
-
var
|
|
40
|
-
Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return
|
|
42
|
+
var customV1_1 = require("./custom/customV1");
|
|
43
|
+
Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return customV1_1.CustomV1; } });
|
|
41
44
|
var cropperV1_1 = require("./cropper/cropperV1");
|
|
42
45
|
Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return cropperV1_1.CropperV1; } });
|
|
43
46
|
var shippingContainerV1_1 = require("./shipping_container/shippingContainerV1");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StringDict } from "../../fields";
|
|
2
2
|
import { Polygon } from "../../geometry";
|
|
3
3
|
export declare class InvoiceLineItem {
|
|
4
4
|
/** The product code referring to the item. */
|
|
@@ -24,6 +24,6 @@ export declare class InvoiceLineItem {
|
|
|
24
24
|
* the field in the document.
|
|
25
25
|
*/
|
|
26
26
|
polygon: Polygon;
|
|
27
|
-
constructor({ prediction }:
|
|
27
|
+
constructor({ prediction }: StringDict);
|
|
28
28
|
toString(): string;
|
|
29
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { BaseField, TaxField, PaymentDetails, Locale, Amount,
|
|
2
|
+
import { BaseField, TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields";
|
|
3
3
|
export declare class InvoiceV3 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Total amount with the tax amount of the purchase. */
|
|
@@ -13,23 +13,23 @@ export declare class InvoiceV3 extends Document {
|
|
|
13
13
|
/** The due date of the invoice. */
|
|
14
14
|
dueDate: DateField;
|
|
15
15
|
/** The created time of the invoice */
|
|
16
|
-
time:
|
|
16
|
+
time: TextField;
|
|
17
17
|
/** The total tax. */
|
|
18
18
|
totalTax: Amount;
|
|
19
19
|
/** The total amount without the tax value. Same as totalExcl. */
|
|
20
20
|
totalNet: Amount;
|
|
21
21
|
/** The supplier name. */
|
|
22
|
-
supplier:
|
|
22
|
+
supplier: TextField;
|
|
23
23
|
/** The supplier address. */
|
|
24
|
-
supplierAddress:
|
|
24
|
+
supplierAddress: TextField;
|
|
25
25
|
/** The invoice number. */
|
|
26
|
-
invoiceNumber:
|
|
26
|
+
invoiceNumber: TextField;
|
|
27
27
|
/** The company regitration information. */
|
|
28
28
|
companyRegistration: CompanyRegistration[];
|
|
29
29
|
/** The name of the customer. */
|
|
30
|
-
customerName:
|
|
30
|
+
customerName: TextField;
|
|
31
31
|
/** The address of the customer. */
|
|
32
|
-
customerAddress:
|
|
32
|
+
customerAddress: TextField;
|
|
33
33
|
/** The list of the taxes. */
|
|
34
34
|
taxes: TaxField[];
|
|
35
35
|
/** The payment information. */
|
|
@@ -129,23 +129,23 @@ _InvoiceV3_instances = new WeakSet(), _InvoiceV3_initFromApiPrediction = functio
|
|
|
129
129
|
prediction: apiPrediction.due_date,
|
|
130
130
|
pageId: pageId,
|
|
131
131
|
});
|
|
132
|
-
this.invoiceNumber = new fields_1.
|
|
132
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
133
133
|
prediction: apiPrediction.invoice_number,
|
|
134
134
|
pageId: pageId,
|
|
135
135
|
});
|
|
136
|
-
this.supplier = new fields_1.
|
|
136
|
+
this.supplier = new fields_1.TextField({
|
|
137
137
|
prediction: apiPrediction.supplier,
|
|
138
138
|
pageId: pageId,
|
|
139
139
|
});
|
|
140
|
-
this.supplierAddress = new fields_1.
|
|
140
|
+
this.supplierAddress = new fields_1.TextField({
|
|
141
141
|
prediction: apiPrediction.supplier_address,
|
|
142
142
|
pageId: pageId,
|
|
143
143
|
});
|
|
144
|
-
this.customerName = new fields_1.
|
|
144
|
+
this.customerName = new fields_1.TextField({
|
|
145
145
|
prediction: apiPrediction.customer,
|
|
146
146
|
pageId: pageId,
|
|
147
147
|
});
|
|
148
|
-
this.customerAddress = new fields_1.
|
|
148
|
+
this.customerAddress = new fields_1.TextField({
|
|
149
149
|
prediction: apiPrediction.customer_address,
|
|
150
150
|
pageId: pageId,
|
|
151
151
|
});
|
|
@@ -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,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
+
export declare class PageGroup {
|
|
3
|
+
pageIndexes: number[];
|
|
4
|
+
constructor(prediction: {
|
|
5
|
+
[index: string]: number[];
|
|
6
|
+
});
|
|
7
|
+
toString(): string;
|
|
8
|
+
}
|
|
9
|
+
export declare class InvoiceSplitterV1 extends Document {
|
|
10
|
+
/** List of page indexes that belong to the same invoice in the PDF. */
|
|
11
|
+
invoicePageGroups: PageGroup[];
|
|
12
|
+
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvoiceSplitterV1 = exports.PageGroup = void 0;
|
|
4
|
+
const document_1 = require("../document");
|
|
5
|
+
class PageGroup {
|
|
6
|
+
constructor(prediction) {
|
|
7
|
+
this.pageIndexes = [];
|
|
8
|
+
this.pageIndexes = prediction.page_indexes;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return `page indexes: ${this.pageIndexes.join(", ")}`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.PageGroup = PageGroup;
|
|
15
|
+
class InvoiceSplitterV1 extends document_1.Document {
|
|
16
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
17
|
+
super({
|
|
18
|
+
inputSource: inputSource,
|
|
19
|
+
pageId: pageId,
|
|
20
|
+
orientation: orientation,
|
|
21
|
+
fullText: fullText,
|
|
22
|
+
extras: extras,
|
|
23
|
+
});
|
|
24
|
+
/** List of page indexes that belong to the same invoice in the PDF. */
|
|
25
|
+
this.invoicePageGroups = [];
|
|
26
|
+
if (prediction.invoice_page_groups !== undefined) {
|
|
27
|
+
prediction.invoice_page_groups.map((prediction) => this.invoicePageGroups.push(new PageGroup(prediction)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
toString() {
|
|
31
|
+
let invoicePageGroups = "\n";
|
|
32
|
+
if (this.invoicePageGroups.length > 0) {
|
|
33
|
+
invoicePageGroups = "\n ";
|
|
34
|
+
invoicePageGroups += this.invoicePageGroups
|
|
35
|
+
.map((item) => item.toString())
|
|
36
|
+
.join("\n ");
|
|
37
|
+
}
|
|
38
|
+
const outStr = `----- Invoice Splitter V1 -----
|
|
39
|
+
Filename: ${this.filename}
|
|
40
|
+
Invoice Page Groups: ${invoicePageGroups}
|
|
41
|
+
----------------------
|
|
42
|
+
`;
|
|
43
|
+
return InvoiceSplitterV1.cleanOutString(outStr);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.InvoiceSplitterV1 = InvoiceSplitterV1;
|
|
@@ -1,33 +1,33 @@
|
|
|
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. */
|
|
12
12
|
expiryDate: DateField;
|
|
13
|
-
/** The issuance date
|
|
13
|
+
/** The issuance date of the passport. */
|
|
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:
|
|
19
|
-
/** The surname of the
|
|
20
|
-
surname:
|
|
21
|
-
/** The value of the first
|
|
22
|
-
mrz1:
|
|
23
|
-
/** The value of the second
|
|
24
|
-
mrz2:
|
|
18
|
+
gender: TextField;
|
|
19
|
+
/** The surname (last name) of the passport holder. */
|
|
20
|
+
surname: TextField;
|
|
21
|
+
/** The value of the first MRZ line. */
|
|
22
|
+
mrz1: TextField;
|
|
23
|
+
/** The value of the second MRZ line. */
|
|
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:
|
|
29
|
-
/** All the
|
|
30
|
-
mrz:
|
|
28
|
+
fullName: TextField;
|
|
29
|
+
/** All the MRZ values combined. */
|
|
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,21 +1,21 @@
|
|
|
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. */
|
|
6
6
|
locale: Locale;
|
|
7
7
|
/** The purchase date. */
|
|
8
8
|
date: DateField;
|
|
9
|
-
/** The
|
|
10
|
-
category:
|
|
11
|
-
/** The receipt sub
|
|
12
|
-
subCategory:
|
|
13
|
-
/**
|
|
14
|
-
documentType:
|
|
15
|
-
/**
|
|
16
|
-
supplier:
|
|
9
|
+
/** The receipt category among predefined classes. */
|
|
10
|
+
category: TextField;
|
|
11
|
+
/** The receipt sub-category among predefined classes. */
|
|
12
|
+
subCategory: TextField;
|
|
13
|
+
/** Whether the document is an expense receipt or a credit card receipt. */
|
|
14
|
+
documentType: TextField;
|
|
15
|
+
/** The name of the supplier or merchant, as seen on the receipt. */
|
|
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. */
|
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.ReceiptV4 = void 0;
|
|
10
10
|
const document_1 = require("../document");
|
|
11
11
|
const fields_1 = require("../../fields");
|
|
12
|
-
const tax_1 = require("./tax");
|
|
13
12
|
class ReceiptV4 extends document_1.Document {
|
|
14
13
|
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
15
14
|
super({
|
|
@@ -49,7 +48,6 @@ exports.ReceiptV4 = ReceiptV4;
|
|
|
49
48
|
_ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = function _ReceiptV4_initFromApiPrediction(apiPrediction, pageId) {
|
|
50
49
|
this.locale = new fields_1.Locale({
|
|
51
50
|
prediction: apiPrediction.locale,
|
|
52
|
-
pageId: pageId,
|
|
53
51
|
});
|
|
54
52
|
this.totalTax = new fields_1.Amount({
|
|
55
53
|
prediction: apiPrediction.total_tax,
|
|
@@ -75,27 +73,27 @@ _ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = functio
|
|
|
75
73
|
prediction: apiPrediction.date,
|
|
76
74
|
pageId: pageId,
|
|
77
75
|
});
|
|
78
|
-
this.category = new fields_1.
|
|
76
|
+
this.category = new fields_1.TextField({
|
|
79
77
|
prediction: apiPrediction.category,
|
|
80
78
|
pageId: pageId,
|
|
81
79
|
});
|
|
82
|
-
this.subCategory = new fields_1.
|
|
80
|
+
this.subCategory = new fields_1.TextField({
|
|
83
81
|
prediction: apiPrediction.subcategory,
|
|
84
82
|
pageId: pageId,
|
|
85
83
|
});
|
|
86
|
-
this.documentType = new fields_1.
|
|
84
|
+
this.documentType = new fields_1.TextField({
|
|
87
85
|
prediction: apiPrediction.document_type,
|
|
88
86
|
pageId: pageId,
|
|
89
87
|
});
|
|
90
|
-
this.supplier = new fields_1.
|
|
88
|
+
this.supplier = new fields_1.TextField({
|
|
91
89
|
prediction: apiPrediction.supplier,
|
|
92
90
|
pageId: pageId,
|
|
93
91
|
});
|
|
94
|
-
this.time = new fields_1.
|
|
92
|
+
this.time = new fields_1.TextField({
|
|
95
93
|
prediction: apiPrediction.time,
|
|
96
94
|
pageId: pageId,
|
|
97
95
|
});
|
|
98
|
-
apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new
|
|
96
|
+
apiPrediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({
|
|
99
97
|
prediction: taxPrediction,
|
|
100
98
|
pageId: pageId,
|
|
101
99
|
valueKey: "value",
|
|
@@ -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
|
});
|