mindee 3.1.1 → 3.3.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 +15 -0
- package/README.md +4 -4
- package/package.json +1 -1
- package/src/api/endpoint.d.ts +2 -0
- package/src/api/endpoint.js +12 -3
- package/src/cli.js +70 -53
- package/src/client.d.ts +41 -5
- package/src/client.js +20 -4
- package/src/documents/cropper/cropperV1.d.ts +2 -2
- package/src/documents/cropper/cropperV1.js +1 -1
- package/src/documents/document.d.ts +2 -2
- package/src/documents/document.js +1 -1
- package/src/documents/eu/index.d.ts +1 -0
- package/src/documents/eu/index.js +5 -0
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +8 -0
- package/src/documents/eu/licensePlate/licensePlateV1.js +29 -0
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +12 -0
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +37 -0
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +14 -0
- package/src/documents/fr/carteVitale/carteVitaleV1.js +44 -0
- package/src/documents/fr/idCard/idCardV1.d.ts +11 -0
- package/src/documents/fr/idCard/idCardV1.js +1 -0
- package/src/documents/fr/index.d.ts +2 -0
- package/src/documents/fr/index.js +5 -1
- package/src/documents/index.d.ts +3 -0
- package/src/documents/index.js +6 -1
- package/src/documents/invoice/checks.d.ts +5 -0
- package/src/documents/invoice/checks.js +87 -0
- package/src/documents/invoice/invoiceLineItem.d.ts +29 -0
- package/src/documents/invoice/invoiceLineItem.js +66 -0
- package/src/documents/invoice/invoiceV3.d.ts +27 -8
- package/src/documents/invoice/invoiceV3.js +33 -159
- package/src/documents/invoice/invoiceV4.d.ts +44 -0
- package/src/documents/invoice/invoiceV4.js +168 -0
- package/src/documents/invoice/reconstruction.d.ts +6 -0
- package/src/documents/invoice/reconstruction.js +77 -0
- package/src/documents/passport/passportV1.d.ts +13 -0
- package/src/documents/passport/passportV1.js +1 -0
- package/src/documents/receipt/receiptV3.d.ts +9 -1
- package/src/documents/receipt/receiptV3.js +1 -0
- package/src/documents/shipping_container/shippingContainerV1.d.ts +12 -0
- package/src/documents/shipping_container/shippingContainerV1.js +37 -0
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +20 -1
- package/src/documents/us/bankCheck/bankCheckV1.js +57 -0
- package/src/fields/amount.d.ts +1 -0
- package/src/fields/apiBuilder.d.ts +1 -0
- package/src/fields/companyRegistration.d.ts +1 -1
- package/src/fields/field.d.ts +1 -0
- package/src/fields/field.js +1 -0
- package/src/fields/index.d.ts +1 -1
- package/src/fields/index.js +3 -3
- package/src/fields/locale.d.ts +3 -0
- package/src/fields/paymentDetails.d.ts +4 -0
- package/src/fields/{cropper.d.ts → position.d.ts} +8 -3
- package/src/fields/{cropper.js → position.js} +4 -6
- package/src/index.d.ts +1 -1
- package/src/index.js +4 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _InvoiceV4_instances, _InvoiceV4_initFromApiPrediction, _InvoiceV4_checklist, _InvoiceV4_reconstruct;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.InvoiceV4 = void 0;
|
|
10
|
+
const document_1 = require("../document");
|
|
11
|
+
const fields_1 = require("../../fields");
|
|
12
|
+
const invoiceLineItem_1 = require("./invoiceLineItem");
|
|
13
|
+
const checks_1 = require("./checks");
|
|
14
|
+
const reconstruction_1 = require("./reconstruction");
|
|
15
|
+
class InvoiceV4 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
|
+
_InvoiceV4_instances.add(this);
|
|
25
|
+
/** The payment information. */
|
|
26
|
+
this.supplierPaymentDetails = [];
|
|
27
|
+
/** The supplier company regitration information. */
|
|
28
|
+
this.supplierCompanyRegistrations = [];
|
|
29
|
+
/** The company registration information for the customer. */
|
|
30
|
+
this.customerCompanyRegistrations = [];
|
|
31
|
+
/** The list of the taxes. */
|
|
32
|
+
this.taxes = [];
|
|
33
|
+
/** Line items details. */
|
|
34
|
+
this.lineItems = [];
|
|
35
|
+
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_initFromApiPrediction).call(this, prediction, pageId);
|
|
36
|
+
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_checklist).call(this);
|
|
37
|
+
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_reconstruct).call(this);
|
|
38
|
+
}
|
|
39
|
+
toString() {
|
|
40
|
+
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
41
|
+
const paymentDetails = this.supplierPaymentDetails
|
|
42
|
+
.map((item) => item.toString())
|
|
43
|
+
.join("\n ");
|
|
44
|
+
const customerCompanyRegistration = this.customerCompanyRegistrations
|
|
45
|
+
.map((item) => item.toString())
|
|
46
|
+
.join("; ");
|
|
47
|
+
const companyRegistration = this.supplierCompanyRegistrations
|
|
48
|
+
.map((item) => item.toString())
|
|
49
|
+
.join("; ");
|
|
50
|
+
let lineItems = "\n";
|
|
51
|
+
if (this.lineItems.length > 0) {
|
|
52
|
+
lineItems =
|
|
53
|
+
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
54
|
+
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
55
|
+
}
|
|
56
|
+
const outStr = `----- Invoice V4 -----
|
|
57
|
+
Filename: ${this.filename}
|
|
58
|
+
Locale: ${this.locale}
|
|
59
|
+
Invoice number: ${this.invoiceNumber}
|
|
60
|
+
Invoice date: ${this.date}
|
|
61
|
+
Invoice due date: ${this.dueDate}
|
|
62
|
+
Supplier name: ${this.supplierName}
|
|
63
|
+
Supplier address: ${this.supplierAddress}
|
|
64
|
+
Supplier company registrations: ${companyRegistration}
|
|
65
|
+
Supplier payment details: ${paymentDetails}
|
|
66
|
+
Customer name: ${this.customerName}
|
|
67
|
+
Customer company registrations: ${customerCompanyRegistration}
|
|
68
|
+
Customer address: ${this.customerAddress}
|
|
69
|
+
Line Items: ${lineItems}
|
|
70
|
+
Taxes: ${taxes}
|
|
71
|
+
Total taxes: ${this.totalTax}
|
|
72
|
+
Total amount excluding taxes: ${this.totalNet}
|
|
73
|
+
Total amount including taxes: ${this.totalAmount}
|
|
74
|
+
----------------------
|
|
75
|
+
`;
|
|
76
|
+
return InvoiceV4.cleanOutString(outStr);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.InvoiceV4 = InvoiceV4;
|
|
80
|
+
_InvoiceV4_instances = new WeakSet(), _InvoiceV4_initFromApiPrediction = function _InvoiceV4_initFromApiPrediction(apiPrediction, pageId) {
|
|
81
|
+
this.locale = new fields_1.Locale({
|
|
82
|
+
prediction: apiPrediction.locale,
|
|
83
|
+
valueKey: "language",
|
|
84
|
+
});
|
|
85
|
+
this.documentType = new fields_1.BaseField({
|
|
86
|
+
prediction: apiPrediction.document_type,
|
|
87
|
+
valueKey: "value",
|
|
88
|
+
});
|
|
89
|
+
this.totalAmount = new fields_1.Amount({
|
|
90
|
+
prediction: apiPrediction.total_amount,
|
|
91
|
+
valueKey: "value",
|
|
92
|
+
pageId: pageId,
|
|
93
|
+
});
|
|
94
|
+
this.totalTax = new fields_1.Amount({
|
|
95
|
+
prediction: { value: undefined, confidence: 0.0 },
|
|
96
|
+
valueKey: "value",
|
|
97
|
+
pageId: pageId,
|
|
98
|
+
});
|
|
99
|
+
this.totalNet = new fields_1.Amount({
|
|
100
|
+
prediction: apiPrediction.total_net,
|
|
101
|
+
valueKey: "value",
|
|
102
|
+
pageId: pageId,
|
|
103
|
+
});
|
|
104
|
+
this.date = new fields_1.DateField({
|
|
105
|
+
prediction: apiPrediction.date,
|
|
106
|
+
pageId,
|
|
107
|
+
});
|
|
108
|
+
apiPrediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({
|
|
109
|
+
prediction: prediction,
|
|
110
|
+
pageId: pageId,
|
|
111
|
+
valueKey: "value",
|
|
112
|
+
rateKey: "rate",
|
|
113
|
+
codeKey: "code",
|
|
114
|
+
})));
|
|
115
|
+
this.supplierCompanyRegistrations =
|
|
116
|
+
apiPrediction.supplier_company_registrations.map(function (prediction) {
|
|
117
|
+
return new fields_1.CompanyRegistration({
|
|
118
|
+
prediction: prediction,
|
|
119
|
+
pageId: pageId,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
this.dueDate = new fields_1.DateField({
|
|
123
|
+
prediction: apiPrediction.due_date,
|
|
124
|
+
pageId: pageId,
|
|
125
|
+
});
|
|
126
|
+
this.invoiceNumber = new fields_1.Field({
|
|
127
|
+
prediction: apiPrediction.invoice_number,
|
|
128
|
+
pageId: pageId,
|
|
129
|
+
});
|
|
130
|
+
this.supplierName = new fields_1.Field({
|
|
131
|
+
prediction: apiPrediction.supplier_name,
|
|
132
|
+
pageId: pageId,
|
|
133
|
+
});
|
|
134
|
+
this.supplierAddress = new fields_1.Field({
|
|
135
|
+
prediction: apiPrediction.supplier_address,
|
|
136
|
+
pageId: pageId,
|
|
137
|
+
});
|
|
138
|
+
this.customerName = new fields_1.Field({
|
|
139
|
+
prediction: apiPrediction.customer_name,
|
|
140
|
+
pageId: pageId,
|
|
141
|
+
});
|
|
142
|
+
this.customerAddress = new fields_1.Field({
|
|
143
|
+
prediction: apiPrediction.customer_address,
|
|
144
|
+
pageId: pageId,
|
|
145
|
+
});
|
|
146
|
+
apiPrediction.customer_company_registrations.map((prediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
|
|
147
|
+
prediction: prediction,
|
|
148
|
+
pageId: pageId,
|
|
149
|
+
})));
|
|
150
|
+
apiPrediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
|
|
151
|
+
prediction: prediction,
|
|
152
|
+
pageId: pageId,
|
|
153
|
+
})));
|
|
154
|
+
apiPrediction.line_items.map((prediction) => this.lineItems.push(new invoiceLineItem_1.InvoiceLineItem({
|
|
155
|
+
prediction: prediction,
|
|
156
|
+
})));
|
|
157
|
+
}, _InvoiceV4_checklist = function _InvoiceV4_checklist() {
|
|
158
|
+
this.checklist = {
|
|
159
|
+
taxesMatchTotalIncl: (0, checks_1.taxesMatchTotalIncl)(this),
|
|
160
|
+
taxesMatchTotalExcl: (0, checks_1.taxesMatchTotalExcl)(this),
|
|
161
|
+
taxesAndTotalExclMatchTotalIncl: (0, checks_1.taxesAndTotalExclMatchTotalIncl)(this),
|
|
162
|
+
};
|
|
163
|
+
}, _InvoiceV4_reconstruct = function _InvoiceV4_reconstruct() {
|
|
164
|
+
(0, reconstruction_1.reconstructTotalTax)(this);
|
|
165
|
+
(0, reconstruction_1.reconstructTotalExcl)(this);
|
|
166
|
+
(0, reconstruction_1.reconstructTotalIncl)(this);
|
|
167
|
+
(0, reconstruction_1.reconstructTotalTaxFromTotals)(this);
|
|
168
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InvoiceV3 } from "./invoiceV3";
|
|
2
|
+
import { InvoiceV4 } from "./invoiceV4";
|
|
3
|
+
export declare function reconstructTotalTax(document: InvoiceV3 | InvoiceV4): void;
|
|
4
|
+
export declare function reconstructTotalTaxFromTotals(document: InvoiceV3 | InvoiceV4): void;
|
|
5
|
+
export declare function reconstructTotalExcl(document: InvoiceV3 | InvoiceV4): void;
|
|
6
|
+
export declare function reconstructTotalIncl(document: InvoiceV3 | InvoiceV4): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reconstructTotalIncl = exports.reconstructTotalExcl = exports.reconstructTotalTaxFromTotals = exports.reconstructTotalTax = void 0;
|
|
4
|
+
const fields_1 = require("../../fields");
|
|
5
|
+
function reconstructTotalTax(document) {
|
|
6
|
+
if (document.taxes.length > 0) {
|
|
7
|
+
const totalTax = {
|
|
8
|
+
value: document.taxes.reduce((acc, tax) => {
|
|
9
|
+
return tax.value !== undefined ? acc + tax.value : acc;
|
|
10
|
+
}, 0),
|
|
11
|
+
confidence: fields_1.Field.arrayConfidence(document.taxes),
|
|
12
|
+
};
|
|
13
|
+
if (totalTax.value > 0)
|
|
14
|
+
document.totalTax = new fields_1.Amount({
|
|
15
|
+
prediction: totalTax,
|
|
16
|
+
valueKey: "value",
|
|
17
|
+
reconstructed: true,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.reconstructTotalTax = reconstructTotalTax;
|
|
22
|
+
function reconstructTotalTaxFromTotals(document) {
|
|
23
|
+
if (document.totalTax.value !== undefined ||
|
|
24
|
+
document.totalNet.value === undefined ||
|
|
25
|
+
document.totalAmount.value === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const totalTax = {
|
|
29
|
+
value: document.totalAmount.value - document.totalNet.value,
|
|
30
|
+
confidence: document.totalAmount.confidence * document.totalNet.confidence,
|
|
31
|
+
};
|
|
32
|
+
if (totalTax.value >= 0) {
|
|
33
|
+
document.totalTax = new fields_1.Amount({
|
|
34
|
+
prediction: totalTax,
|
|
35
|
+
valueKey: "value",
|
|
36
|
+
reconstructed: true,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.reconstructTotalTaxFromTotals = reconstructTotalTaxFromTotals;
|
|
41
|
+
function reconstructTotalExcl(document) {
|
|
42
|
+
if (document.totalAmount.value === undefined ||
|
|
43
|
+
document.taxes.length === 0 ||
|
|
44
|
+
document.totalNet.value !== undefined) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const totalExcl = {
|
|
48
|
+
value: document.totalAmount.value - fields_1.Field.arraySum(document.taxes),
|
|
49
|
+
confidence: fields_1.Field.arrayConfidence(document.taxes) *
|
|
50
|
+
document.totalAmount.confidence,
|
|
51
|
+
};
|
|
52
|
+
document.totalNet = new fields_1.Amount({
|
|
53
|
+
prediction: totalExcl,
|
|
54
|
+
valueKey: "value",
|
|
55
|
+
reconstructed: true,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.reconstructTotalExcl = reconstructTotalExcl;
|
|
59
|
+
function reconstructTotalIncl(document) {
|
|
60
|
+
if (!(document.totalNet.value === undefined ||
|
|
61
|
+
document.taxes.length === 0 ||
|
|
62
|
+
document.totalAmount.value !== undefined)) {
|
|
63
|
+
const totalIncl = {
|
|
64
|
+
value: document.totalNet.value +
|
|
65
|
+
document.taxes.reduce((acc, tax) => {
|
|
66
|
+
return tax.value ? acc + tax.value : acc;
|
|
67
|
+
}, 0.0),
|
|
68
|
+
confidence: fields_1.Field.arrayConfidence(document.taxes) * document.totalNet.confidence,
|
|
69
|
+
};
|
|
70
|
+
document.totalAmount = new fields_1.Amount({
|
|
71
|
+
prediction: totalIncl,
|
|
72
|
+
valueKey: "value",
|
|
73
|
+
reconstructed: true,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.reconstructTotalIncl = reconstructTotalIncl;
|
|
@@ -2,18 +2,31 @@ import { Document, DocumentConstructorProps } from "../document";
|
|
|
2
2
|
import { Field, DateField } from "../../fields";
|
|
3
3
|
export declare class PassportV1 extends Document {
|
|
4
4
|
#private;
|
|
5
|
+
/** The country of issue. */
|
|
5
6
|
country: Field;
|
|
7
|
+
/** The passport number. */
|
|
6
8
|
idNumber: Field;
|
|
9
|
+
/** The date of birth of the passport holder. */
|
|
7
10
|
birthDate: DateField;
|
|
11
|
+
/** The expiration date of the passport. */
|
|
8
12
|
expiryDate: DateField;
|
|
13
|
+
/** The issuance date.*/
|
|
9
14
|
issuanceDate: DateField;
|
|
15
|
+
/** The place of birth of the passport holder. */
|
|
10
16
|
birthPlace: Field;
|
|
17
|
+
/** The sex or gender of the passport holder. */
|
|
11
18
|
gender: Field;
|
|
19
|
+
/** The surname of the person. */
|
|
12
20
|
surname: Field;
|
|
21
|
+
/** The value of the first mrz line. */
|
|
13
22
|
mrz1: Field;
|
|
23
|
+
/** The value of the second mrz line. */
|
|
14
24
|
mrz2: Field;
|
|
25
|
+
/** List of first (given) names of the passport holder. */
|
|
15
26
|
givenNames: Field[];
|
|
27
|
+
/** The full name of the passport holder. */
|
|
16
28
|
fullName: Field;
|
|
29
|
+
/** All the mrz values combined. */
|
|
17
30
|
mrz: Field;
|
|
18
31
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
19
32
|
static convertMRZDateToDatetime(dateString: string): Date;
|
|
@@ -43,6 +43,7 @@ class PassportV1 extends document_1.Document {
|
|
|
43
43
|
extras: extras,
|
|
44
44
|
});
|
|
45
45
|
_PassportV1_instances.add(this);
|
|
46
|
+
/** List of first (given) names of the passport holder. */
|
|
46
47
|
this.givenNames = [];
|
|
47
48
|
this.country = new fields_1.Field({
|
|
48
49
|
prediction: prediction.country,
|
|
@@ -2,15 +2,23 @@ import { Document, DocumentConstructorProps } from "../document";
|
|
|
2
2
|
import { TaxField, Field, Amount, Locale, DateField } from "../../fields";
|
|
3
3
|
export declare class ReceiptV3 extends Document {
|
|
4
4
|
#private;
|
|
5
|
+
/** Total amount with the tax amount of the purchase. */
|
|
5
6
|
locale: Locale;
|
|
7
|
+
/** Where the purchase was made, the language, and the currency. */
|
|
6
8
|
totalIncl: Amount;
|
|
9
|
+
/** The purchase date. */
|
|
7
10
|
date: DateField;
|
|
8
|
-
/**
|
|
11
|
+
/** The type of purchase. */
|
|
9
12
|
category: Field;
|
|
13
|
+
/** Merchant's name as seen on the receipt. */
|
|
10
14
|
merchantName: Field;
|
|
15
|
+
/** Time as seen on the receipt in HH:MM format. */
|
|
11
16
|
time: Field;
|
|
17
|
+
/** Total tax amount of the purchase. */
|
|
12
18
|
totalTax: Amount;
|
|
19
|
+
/** Total amount without tax of the purchase. */
|
|
13
20
|
totalExcl: Amount;
|
|
21
|
+
/** List of different taxe. */
|
|
14
22
|
taxes: TaxField[];
|
|
15
23
|
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
16
24
|
toString(): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
+
import { Field } from "../../fields";
|
|
3
|
+
export declare class ShippingContainerV1 extends Document {
|
|
4
|
+
/** ISO 6346 code for container owner prefix + equipment identifier. */
|
|
5
|
+
owner: Field;
|
|
6
|
+
/** ISO 6346 code for container serial number (6+1 digits). */
|
|
7
|
+
serialNumber: Field;
|
|
8
|
+
/** ISO 6346 code for container length, height and type. */
|
|
9
|
+
sizeType: Field;
|
|
10
|
+
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
11
|
+
toString(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShippingContainerV1 = void 0;
|
|
4
|
+
const document_1 = require("../document");
|
|
5
|
+
const fields_1 = require("../../fields");
|
|
6
|
+
class ShippingContainerV1 extends document_1.Document {
|
|
7
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
|
|
8
|
+
super({
|
|
9
|
+
inputSource: inputSource,
|
|
10
|
+
pageId: pageId,
|
|
11
|
+
orientation: orientation,
|
|
12
|
+
extras: extras,
|
|
13
|
+
});
|
|
14
|
+
this.owner = new fields_1.Field({
|
|
15
|
+
prediction: prediction.owner,
|
|
16
|
+
pageId: pageId,
|
|
17
|
+
});
|
|
18
|
+
this.serialNumber = new fields_1.Field({
|
|
19
|
+
prediction: prediction.serial_number,
|
|
20
|
+
pageId: pageId,
|
|
21
|
+
});
|
|
22
|
+
this.sizeType = new fields_1.Field({
|
|
23
|
+
prediction: prediction.size_type,
|
|
24
|
+
pageId: pageId,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
toString() {
|
|
28
|
+
const outStr = `----- Shipping Container V1 -----
|
|
29
|
+
Owner: ${this.owner}
|
|
30
|
+
Serial number: ${this.serialNumber}
|
|
31
|
+
Size and type: ${this.sizeType}
|
|
32
|
+
----------------------
|
|
33
|
+
`;
|
|
34
|
+
return ShippingContainerV1.cleanOutString(outStr);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ShippingContainerV1 = ShippingContainerV1;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import { Document } from "../../document";
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../../document";
|
|
2
|
+
import { Field, DateField, PositionField, Amount } from "../../../fields";
|
|
2
3
|
export declare class BankCheckV1 extends Document {
|
|
4
|
+
/** Payer's bank account number. */
|
|
5
|
+
accountNumber: Field;
|
|
6
|
+
/** Total including taxes. */
|
|
7
|
+
amount: Amount;
|
|
8
|
+
/** Payer's bank account number. */
|
|
9
|
+
checkNumber: Field;
|
|
10
|
+
/** Check's position in the image. */
|
|
11
|
+
checkPosition: PositionField;
|
|
12
|
+
/** Date the check was issued. */
|
|
13
|
+
issuanceDate: DateField;
|
|
14
|
+
/** List of payees (full name or company name). */
|
|
15
|
+
payees: Field[];
|
|
16
|
+
/** Payer's bank account routing number. */
|
|
17
|
+
routingNumber: Field;
|
|
18
|
+
/** Signatures' positions in the image. */
|
|
19
|
+
signaturesPositions: PositionField;
|
|
20
|
+
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
21
|
+
toString(): string;
|
|
3
22
|
}
|
|
@@ -2,6 +2,63 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BankCheckV1 = void 0;
|
|
4
4
|
const document_1 = require("../../document");
|
|
5
|
+
const fields_1 = require("../../../fields");
|
|
5
6
|
class BankCheckV1 extends document_1.Document {
|
|
7
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
|
|
8
|
+
super({
|
|
9
|
+
inputSource: inputSource,
|
|
10
|
+
pageId: pageId,
|
|
11
|
+
orientation: orientation,
|
|
12
|
+
extras: extras,
|
|
13
|
+
});
|
|
14
|
+
/** List of payees (full name or company name). */
|
|
15
|
+
this.payees = [];
|
|
16
|
+
this.accountNumber = new fields_1.Field({
|
|
17
|
+
prediction: prediction.account_number,
|
|
18
|
+
pageId: pageId,
|
|
19
|
+
});
|
|
20
|
+
this.checkNumber = new fields_1.Field({
|
|
21
|
+
prediction: prediction.check_number,
|
|
22
|
+
pageId: pageId,
|
|
23
|
+
});
|
|
24
|
+
this.amount = new fields_1.Amount({
|
|
25
|
+
prediction: prediction.amount,
|
|
26
|
+
valueKey: "value",
|
|
27
|
+
pageId: pageId,
|
|
28
|
+
});
|
|
29
|
+
this.checkPosition = new fields_1.PositionField({
|
|
30
|
+
prediction: prediction.check_position,
|
|
31
|
+
pageId: pageId,
|
|
32
|
+
});
|
|
33
|
+
this.issuanceDate = new fields_1.DateField({
|
|
34
|
+
prediction: prediction.date,
|
|
35
|
+
pageId: pageId,
|
|
36
|
+
});
|
|
37
|
+
prediction.payees.map((prediction) => this.payees.push(new fields_1.Field({
|
|
38
|
+
prediction: prediction,
|
|
39
|
+
pageId: pageId,
|
|
40
|
+
})));
|
|
41
|
+
this.routingNumber = new fields_1.Field({
|
|
42
|
+
prediction: prediction.routing_number,
|
|
43
|
+
pageId: pageId,
|
|
44
|
+
});
|
|
45
|
+
this.signaturesPositions = new fields_1.PositionField({
|
|
46
|
+
prediction: prediction.signatures_positions,
|
|
47
|
+
pageId: pageId,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
toString() {
|
|
51
|
+
const outStr = `----- US Bank Check V1 -----
|
|
52
|
+
Filename: ${this.filename}
|
|
53
|
+
Routing number: ${this.routingNumber}
|
|
54
|
+
Account number: ${this.accountNumber}
|
|
55
|
+
Check number: ${this.checkNumber}
|
|
56
|
+
Date: ${this.issuanceDate}
|
|
57
|
+
Amount: ${this.amount}
|
|
58
|
+
Payees: ${this.payees.map((name) => name.value).join(", ")}
|
|
59
|
+
----------------------
|
|
60
|
+
`;
|
|
61
|
+
return BankCheckV1.cleanOutString(outStr);
|
|
62
|
+
}
|
|
6
63
|
}
|
|
7
64
|
exports.BankCheckV1 = BankCheckV1;
|
package/src/fields/amount.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Field, FieldConstructor } from "./field";
|
|
2
2
|
export declare function floatToString(value: number): string;
|
|
3
3
|
export declare class Amount extends Field {
|
|
4
|
+
/** The value. */
|
|
4
5
|
value: number | undefined;
|
|
5
6
|
/**
|
|
6
7
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Field, FieldConstructor } from "./field";
|
|
2
2
|
export declare class CompanyRegistration extends Field {
|
|
3
|
-
/** Type of company registration number */
|
|
3
|
+
/** Type of company registration number. */
|
|
4
4
|
type: string;
|
|
5
5
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
6
6
|
}
|
package/src/fields/field.d.ts
CHANGED
package/src/fields/field.js
CHANGED
|
@@ -9,6 +9,7 @@ class BaseField {
|
|
|
9
9
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
10
10
|
*/
|
|
11
11
|
constructor({ prediction, valueKey = "value", reconstructed = false, }) {
|
|
12
|
+
/** The value. */
|
|
12
13
|
this.value = undefined;
|
|
13
14
|
this.reconstructed = reconstructed;
|
|
14
15
|
if (prediction !== undefined &&
|
package/src/fields/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export { BaseField, stringDict, Field } from "./field";
|
|
|
8
8
|
export { ListField, ListFieldValue, ClassificationField } from "./apiBuilder";
|
|
9
9
|
export { FullText } from "./fullText";
|
|
10
10
|
export { CompanyRegistration } from "./companyRegistration";
|
|
11
|
-
export {
|
|
11
|
+
export { PositionField } from "./position";
|
package/src/fields/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PositionField = 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");
|
|
@@ -24,5 +24,5 @@ var fullText_1 = require("./fullText");
|
|
|
24
24
|
Object.defineProperty(exports, "FullText", { enumerable: true, get: function () { return fullText_1.FullText; } });
|
|
25
25
|
var companyRegistration_1 = require("./companyRegistration");
|
|
26
26
|
Object.defineProperty(exports, "CompanyRegistration", { enumerable: true, get: function () { return companyRegistration_1.CompanyRegistration; } });
|
|
27
|
-
var
|
|
28
|
-
Object.defineProperty(exports, "
|
|
27
|
+
var position_1 = require("./position");
|
|
28
|
+
Object.defineProperty(exports, "PositionField", { enumerable: true, get: function () { return position_1.PositionField; } });
|
package/src/fields/locale.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Field } from "./field";
|
|
2
2
|
export declare class Locale extends Field {
|
|
3
|
+
/** The langage which has been detected */
|
|
3
4
|
language: string | undefined;
|
|
5
|
+
/** The country which has been detected (ISO Alpha-2)*/
|
|
4
6
|
country: string | undefined;
|
|
7
|
+
/** The currency which has been detected.*/
|
|
5
8
|
currency: string | undefined;
|
|
6
9
|
/**
|
|
7
10
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
@@ -11,9 +11,13 @@ interface PaymentDetailsConstructor {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class PaymentDetails extends Field {
|
|
13
13
|
#private;
|
|
14
|
+
/** The account number. */
|
|
14
15
|
accountNumber: number | undefined;
|
|
16
|
+
/** The account IBAN. */
|
|
15
17
|
iban: string | undefined;
|
|
18
|
+
/** The routing number. */
|
|
16
19
|
routingNumber: number | undefined;
|
|
20
|
+
/** The SWIFT value. */
|
|
17
21
|
swift: number | undefined;
|
|
18
22
|
/**
|
|
19
23
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stringDict } from "./field";
|
|
2
2
|
import { Polygon } from "../geometry";
|
|
3
|
-
export
|
|
3
|
+
export interface PositionFieldConstructor {
|
|
4
|
+
prediction: stringDict;
|
|
5
|
+
valueKey?: string;
|
|
6
|
+
pageId?: number | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare class PositionField {
|
|
4
9
|
/** Straight rectangle. */
|
|
5
10
|
boundingBox: Polygon;
|
|
6
11
|
/** Free polygon with up to 30 vertices. */
|
|
@@ -11,6 +16,6 @@ export declare class CropperField extends BaseField {
|
|
|
11
16
|
rectangle: Polygon;
|
|
12
17
|
/** The document page on which the information was found. */
|
|
13
18
|
pageId: number | undefined;
|
|
14
|
-
constructor({ prediction,
|
|
19
|
+
constructor({ prediction, pageId }: PositionFieldConstructor);
|
|
15
20
|
toString(): string;
|
|
16
21
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor({ prediction, valueKey = "polygon", pageId }) {
|
|
7
|
-
super({ prediction, valueKey });
|
|
3
|
+
exports.PositionField = void 0;
|
|
4
|
+
class PositionField {
|
|
5
|
+
constructor({ prediction, pageId }) {
|
|
8
6
|
this.pageId = pageId;
|
|
9
7
|
this.boundingBox = prediction.bounding_box;
|
|
10
8
|
this.polygon = prediction.polygon;
|
|
@@ -15,4 +13,4 @@ class CropperField extends field_1.BaseField {
|
|
|
15
13
|
return `Polygon with ${this.polygon.length} points.`;
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
|
-
exports.
|
|
16
|
+
exports.PositionField = PositionField;
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CustomV1, FinancialDocumentV1, InvoiceV3, PassportV1, ReceiptV3, ReceiptV4, CropperV1, fr, us, } from "./documents";
|
|
1
|
+
export { CustomV1, FinancialDocumentV1, InvoiceV3, InvoiceV4, PassportV1, ReceiptV3, ReceiptV4, CropperV1, ShippingContainerV1, fr, us, eu, } from "./documents";
|
|
2
2
|
export { Client } from "./client";
|
|
3
3
|
export { PageOptionsOperation } from "./inputs";
|
package/src/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageOptionsOperation = exports.Client = exports.us = exports.fr = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.CustomV1 = void 0;
|
|
3
|
+
exports.PageOptionsOperation = exports.Client = exports.eu = exports.us = exports.fr = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.CustomV1 = void 0;
|
|
4
4
|
var documents_1 = require("./documents");
|
|
5
5
|
Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return documents_1.CustomV1; } });
|
|
6
6
|
Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return documents_1.FinancialDocumentV1; } });
|
|
7
7
|
Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return documents_1.InvoiceV3; } });
|
|
8
|
+
Object.defineProperty(exports, "InvoiceV4", { enumerable: true, get: function () { return documents_1.InvoiceV4; } });
|
|
8
9
|
Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return documents_1.PassportV1; } });
|
|
9
10
|
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return documents_1.ReceiptV3; } });
|
|
10
11
|
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return documents_1.ReceiptV4; } });
|
|
11
12
|
Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return documents_1.CropperV1; } });
|
|
13
|
+
Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return documents_1.ShippingContainerV1; } });
|
|
12
14
|
Object.defineProperty(exports, "fr", { enumerable: true, get: function () { return documents_1.fr; } });
|
|
13
15
|
Object.defineProperty(exports, "us", { enumerable: true, get: function () { return documents_1.us; } });
|
|
16
|
+
Object.defineProperty(exports, "eu", { enumerable: true, get: function () { return documents_1.eu; } });
|
|
14
17
|
var client_1 = require("./client");
|
|
15
18
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
16
19
|
var inputs_1 = require("./inputs");
|