mindee 2.1.1 → 3.0.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 +16 -0
- package/README.md +30 -9
- package/package.json +3 -2
- package/src/api/endpoint.d.ts +19 -17
- package/src/api/endpoint.js +27 -39
- package/src/api/index.d.ts +2 -2
- package/src/api/index.js +2 -11
- package/src/api/response.d.ts +8 -41
- package/src/api/response.js +18 -89
- package/src/cli.js +46 -12
- package/src/client.d.ts +47 -13
- package/src/client.js +73 -27
- package/src/documents/cropper/cropperV1.d.ts +7 -0
- package/src/documents/{cropper.js → cropper/cropperV1.js} +12 -8
- package/src/documents/custom.d.ts +2 -6
- package/src/documents/custom.js +12 -7
- package/src/documents/document.d.ts +8 -3
- package/src/documents/document.js +11 -5
- package/src/documents/documentConfig.d.ts +20 -34
- package/src/documents/documentConfig.js +33 -57
- package/src/documents/{financialDocument.d.ts → financialDocument/financialDocumentV1.d.ts} +4 -4
- package/src/documents/{financialDocument.js → financialDocument/financialDocumentV1.js} +28 -22
- package/src/documents/fr/idCard/idCardV1.d.ts +3 -0
- package/src/documents/fr/idCard/idCardV1.js +7 -0
- package/src/documents/index.d.ts +15 -13
- package/src/documents/index.js +21 -18
- package/src/documents/{invoice.d.ts → invoice/invoiceV3.d.ts} +4 -4
- package/src/documents/{invoice.js → invoice/invoiceV3.js} +30 -24
- package/src/documents/{passport.d.ts → passport/passportV1.d.ts} +4 -4
- package/src/documents/{passport.js → passport/passportV1.js} +19 -14
- package/src/documents/receipt/receiptV3.d.ts +17 -0
- package/src/documents/{receipt.js → receipt/receiptV3.js} +28 -22
- package/src/documents/receipt/receiptV4.d.ts +27 -0
- package/src/documents/receipt/receiptV4.js +96 -0
- package/src/documents/receipt/tax.d.ts +25 -0
- package/src/documents/receipt/tax.js +40 -0
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +3 -0
- package/src/documents/us/bankCheck/bankCheckV1.js +7 -0
- package/src/errors/MindeeError.d.ts +3 -0
- package/src/errors/MindeeError.js +10 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +5 -0
- package/src/fields/{customDocs.d.ts → apiBuilder.d.ts} +5 -1
- package/src/fields/{customDocs.js → apiBuilder.js} +0 -0
- package/src/fields/index.d.ts +1 -1
- package/src/fields/index.js +4 -4
- package/src/index.d.ts +2 -1
- package/src/index.js +11 -9
- package/src/inputs/base.d.ts +33 -0
- package/src/inputs/base.js +116 -0
- package/src/inputs/index.d.ts +3 -0
- package/src/inputs/index.js +18 -0
- package/src/inputs/pageOptions.d.ts +20 -0
- package/src/inputs/pageOptions.js +8 -0
- package/src/inputs/sources.d.ts +55 -0
- package/src/inputs/sources.js +121 -0
- package/src/pdf/index.d.ts +1 -0
- package/src/pdf/index.js +6 -0
- package/src/pdf/pdfOperation.d.ts +14 -0
- package/src/pdf/pdfOperation.js +69 -0
- package/src/constants.d.ts +0 -13
- package/src/constants.js +0 -60
- package/src/documents/cropper.d.ts +0 -7
- package/src/documents/receipt.d.ts +0 -17
- package/src/inputs.d.ts +0 -69
- package/src/inputs.js +0 -196
|
@@ -4,23 +4,29 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
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
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var _FinancialDocumentV1_instances, _FinancialDocumentV1_initFromApiPrediction, _FinancialDocumentV1_checklist, _FinancialDocumentV1_taxesMatchTotalIncl;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
const document_1 = require("
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const fields_1 = require("
|
|
14
|
-
class
|
|
15
|
-
constructor({ prediction, orientation = undefined, extras = undefined,
|
|
16
|
-
super({
|
|
17
|
-
|
|
9
|
+
exports.FinancialDocumentV1 = void 0;
|
|
10
|
+
const document_1 = require("../document");
|
|
11
|
+
const invoiceV3_1 = require("../invoice/invoiceV3");
|
|
12
|
+
const receiptV3_1 = require("../receipt/receiptV3");
|
|
13
|
+
const fields_1 = require("../../fields");
|
|
14
|
+
class FinancialDocumentV1 extends document_1.Document {
|
|
15
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
16
|
+
super({
|
|
17
|
+
inputSource: inputSource,
|
|
18
|
+
pageId: pageId,
|
|
19
|
+
orientation: orientation,
|
|
20
|
+
fullText: fullText,
|
|
21
|
+
extras: extras,
|
|
22
|
+
});
|
|
23
|
+
_FinancialDocumentV1_instances.add(this);
|
|
18
24
|
this.taxes = [];
|
|
19
25
|
this.companyRegistration = [];
|
|
20
26
|
this.paymentDetails = [];
|
|
21
27
|
this.customerCompanyRegistration = [];
|
|
22
|
-
__classPrivateFieldGet(this,
|
|
23
|
-
__classPrivateFieldGet(this,
|
|
28
|
+
__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_initFromApiPrediction).call(this, prediction, inputSource, pageId, orientation, extras);
|
|
29
|
+
__classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_checklist).call(this);
|
|
24
30
|
}
|
|
25
31
|
toString() {
|
|
26
32
|
const outStr = `-----Financial document-----
|
|
@@ -31,15 +37,15 @@ Supplier: ${this.supplier.value}
|
|
|
31
37
|
Total taxes: ${this.totalTax.value}
|
|
32
38
|
----------------------
|
|
33
39
|
`;
|
|
34
|
-
return
|
|
40
|
+
return FinancialDocumentV1.cleanOutString(outStr);
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
|
-
exports.
|
|
38
|
-
|
|
43
|
+
exports.FinancialDocumentV1 = FinancialDocumentV1;
|
|
44
|
+
_FinancialDocumentV1_instances = new WeakSet(), _FinancialDocumentV1_initFromApiPrediction = function _FinancialDocumentV1_initFromApiPrediction(prediction, inputFile, pageNumber, orientation, extras) {
|
|
39
45
|
if (Object.keys(prediction).includes("invoice_number")) {
|
|
40
|
-
const invoice = new
|
|
46
|
+
const invoice = new invoiceV3_1.InvoiceV3({
|
|
41
47
|
prediction: prediction,
|
|
42
|
-
inputFile,
|
|
48
|
+
inputSource: inputFile,
|
|
43
49
|
pageId: pageNumber,
|
|
44
50
|
orientation: orientation,
|
|
45
51
|
extras: extras,
|
|
@@ -65,9 +71,9 @@ _FinancialDocument_instances = new WeakSet(), _FinancialDocument_initFromApiPred
|
|
|
65
71
|
this.customerCompanyRegistration = invoice.customerCompanyRegistration;
|
|
66
72
|
}
|
|
67
73
|
else {
|
|
68
|
-
const receipt = new
|
|
74
|
+
const receipt = new receiptV3_1.ReceiptV3({
|
|
69
75
|
prediction: prediction,
|
|
70
|
-
inputFile,
|
|
76
|
+
inputSource: inputFile,
|
|
71
77
|
pageId: pageNumber,
|
|
72
78
|
orientation: orientation,
|
|
73
79
|
extras: extras,
|
|
@@ -95,11 +101,11 @@ _FinancialDocument_instances = new WeakSet(), _FinancialDocument_initFromApiPred
|
|
|
95
101
|
prediction: { value: undefined, confidence: 0.0 },
|
|
96
102
|
});
|
|
97
103
|
}
|
|
98
|
-
},
|
|
104
|
+
}, _FinancialDocumentV1_checklist = function _FinancialDocumentV1_checklist() {
|
|
99
105
|
this.checklist = {
|
|
100
|
-
taxesMatchTotalIncl: __classPrivateFieldGet(this,
|
|
106
|
+
taxesMatchTotalIncl: __classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_taxesMatchTotalIncl).call(this),
|
|
101
107
|
};
|
|
102
|
-
},
|
|
108
|
+
}, _FinancialDocumentV1_taxesMatchTotalIncl = function _FinancialDocumentV1_taxesMatchTotalIncl() {
|
|
103
109
|
// Check taxes and total include exist
|
|
104
110
|
if (this.taxes.length === 0 || this.totalIncl.value === undefined)
|
|
105
111
|
return false;
|
package/src/documents/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
10
|
-
export declare const DOC_TYPE_RECEIPT: string;
|
|
11
|
-
export declare const DOC_TYPE_PASSPORT: string;
|
|
12
|
-
export declare const DOC_TYPE_FINANCIAL: string;
|
|
1
|
+
import { InvoiceV3 } from "./invoice/invoiceV3";
|
|
2
|
+
import { ReceiptV3 } from "./receipt/receiptV3";
|
|
3
|
+
import { ReceiptV4 } from "./receipt/receiptV4";
|
|
4
|
+
import { PassportV1 } from "./passport/passportV1";
|
|
5
|
+
import { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1";
|
|
6
|
+
import { CustomV1 } from "./custom";
|
|
7
|
+
import { CropperV1 } from "./cropper/cropperV1";
|
|
8
|
+
export { Document, DocumentConstructorProps, DocumentSig } from "./document";
|
|
9
|
+
export { ReceiptV3, ReceiptV4, InvoiceV3, FinancialDocumentV1, PassportV1, CustomV1, CropperV1, };
|
|
13
10
|
export declare const DOC_TYPE_CUSTOM: string;
|
|
14
|
-
export declare const
|
|
11
|
+
export declare const DOC_TYPE_INVOICE_V3: string;
|
|
12
|
+
export declare const DOC_TYPE_RECEIPT_V3: string;
|
|
13
|
+
export declare const DOC_TYPE_RECEIPT_V4: string;
|
|
14
|
+
export declare const DOC_TYPE_PASSPORT_V1: string;
|
|
15
|
+
export declare const DOC_TYPE_FINANCIAL_V1: string;
|
|
16
|
+
export declare const DOC_TYPE_CROPPER_V1: string;
|
package/src/documents/index.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
const
|
|
7
|
-
Object.defineProperty(exports, "
|
|
8
|
-
const
|
|
9
|
-
Object.defineProperty(exports, "
|
|
10
|
-
const
|
|
11
|
-
Object.defineProperty(exports, "
|
|
3
|
+
exports.DOC_TYPE_CROPPER_V1 = exports.DOC_TYPE_FINANCIAL_V1 = exports.DOC_TYPE_PASSPORT_V1 = exports.DOC_TYPE_RECEIPT_V4 = exports.DOC_TYPE_RECEIPT_V3 = exports.DOC_TYPE_INVOICE_V3 = exports.DOC_TYPE_CUSTOM = exports.CropperV1 = exports.CustomV1 = exports.PassportV1 = exports.FinancialDocumentV1 = exports.InvoiceV3 = exports.ReceiptV4 = exports.ReceiptV3 = exports.Document = void 0;
|
|
4
|
+
const invoiceV3_1 = require("./invoice/invoiceV3");
|
|
5
|
+
Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
|
|
6
|
+
const receiptV3_1 = require("./receipt/receiptV3");
|
|
7
|
+
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return receiptV3_1.ReceiptV3; } });
|
|
8
|
+
const receiptV4_1 = require("./receipt/receiptV4");
|
|
9
|
+
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return receiptV4_1.ReceiptV4; } });
|
|
10
|
+
const passportV1_1 = require("./passport/passportV1");
|
|
11
|
+
Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } });
|
|
12
|
+
const financialDocumentV1_1 = require("./financialDocument/financialDocumentV1");
|
|
13
|
+
Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return financialDocumentV1_1.FinancialDocumentV1; } });
|
|
12
14
|
const custom_1 = require("./custom");
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
const
|
|
15
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return custom_1.CustomV1; } });
|
|
16
|
+
const cropperV1_1 = require("./cropper/cropperV1");
|
|
17
|
+
Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return cropperV1_1.CropperV1; } });
|
|
16
18
|
var document_1 = require("./document");
|
|
17
19
|
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
20
|
+
exports.DOC_TYPE_CUSTOM = custom_1.CustomV1.name;
|
|
21
|
+
exports.DOC_TYPE_INVOICE_V3 = invoiceV3_1.InvoiceV3.name;
|
|
22
|
+
exports.DOC_TYPE_RECEIPT_V3 = receiptV3_1.ReceiptV3.name;
|
|
23
|
+
exports.DOC_TYPE_RECEIPT_V4 = receiptV4_1.ReceiptV4.name;
|
|
24
|
+
exports.DOC_TYPE_PASSPORT_V1 = passportV1_1.PassportV1.name;
|
|
25
|
+
exports.DOC_TYPE_FINANCIAL_V1 = financialDocumentV1_1.FinancialDocumentV1.name;
|
|
26
|
+
exports.DOC_TYPE_CROPPER_V1 = cropperV1_1.CropperV1.name;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Document, DocumentConstructorProps } from "
|
|
2
|
-
import { BaseField, TaxField, PaymentDetails, Locale, Amount, Field, DateField, CompanyRegistration } from "
|
|
3
|
-
export declare class
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
+
import { BaseField, TaxField, PaymentDetails, Locale, Amount, Field, DateField, CompanyRegistration } from "../../fields";
|
|
3
|
+
export declare class InvoiceV3 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
locale: Locale;
|
|
6
6
|
documentType: BaseField;
|
|
@@ -19,7 +19,7 @@ export declare class Invoice extends Document {
|
|
|
19
19
|
taxes: TaxField[];
|
|
20
20
|
paymentDetails: PaymentDetails[];
|
|
21
21
|
customerCompanyRegistration: CompanyRegistration[];
|
|
22
|
-
constructor({ prediction, orientation, extras,
|
|
22
|
+
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
23
23
|
toString(): string;
|
|
24
24
|
private taxesMatchTotalIncl;
|
|
25
25
|
/**
|
|
@@ -4,22 +4,28 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
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
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var _InvoiceV3_instances, _InvoiceV3_initFromApiPrediction, _InvoiceV3_checklist, _InvoiceV3_reconstruct, _InvoiceV3_reconstructTotalTax, _InvoiceV3_reconstructTotalTaxFromTotals, _InvoiceV3_reconstructTotalExcl, _InvoiceV3_reconstructTotalIncl;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
const document_1 = require("
|
|
11
|
-
const fields_1 = require("
|
|
12
|
-
class
|
|
13
|
-
constructor({ prediction, orientation = undefined, extras = undefined,
|
|
14
|
-
super({
|
|
15
|
-
|
|
9
|
+
exports.InvoiceV3 = void 0;
|
|
10
|
+
const document_1 = require("../document");
|
|
11
|
+
const fields_1 = require("../../fields");
|
|
12
|
+
class InvoiceV3 extends document_1.Document {
|
|
13
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
14
|
+
super({
|
|
15
|
+
inputSource: inputSource,
|
|
16
|
+
pageId: pageId,
|
|
17
|
+
orientation: orientation,
|
|
18
|
+
fullText: fullText,
|
|
19
|
+
extras: extras,
|
|
20
|
+
});
|
|
21
|
+
_InvoiceV3_instances.add(this);
|
|
16
22
|
this.companyRegistration = [];
|
|
17
23
|
this.taxes = [];
|
|
18
24
|
this.paymentDetails = [];
|
|
19
25
|
this.customerCompanyRegistration = [];
|
|
20
|
-
__classPrivateFieldGet(this,
|
|
21
|
-
__classPrivateFieldGet(this,
|
|
22
|
-
__classPrivateFieldGet(this,
|
|
26
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_initFromApiPrediction).call(this, prediction, pageId);
|
|
27
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_checklist).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstruct).call(this);
|
|
23
29
|
}
|
|
24
30
|
toString() {
|
|
25
31
|
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
@@ -51,7 +57,7 @@ Total taxes: ${this.totalTax}
|
|
|
51
57
|
Locale: ${this.locale}
|
|
52
58
|
----------------------
|
|
53
59
|
`;
|
|
54
|
-
return
|
|
60
|
+
return InvoiceV3.cleanOutString(outStr);
|
|
55
61
|
}
|
|
56
62
|
taxesMatchTotalIncl() {
|
|
57
63
|
// Check taxes and total include exist
|
|
@@ -138,8 +144,8 @@ Locale: ${this.locale}
|
|
|
138
144
|
return false;
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
|
-
exports.
|
|
142
|
-
|
|
147
|
+
exports.InvoiceV3 = InvoiceV3;
|
|
148
|
+
_InvoiceV3_instances = new WeakSet(), _InvoiceV3_initFromApiPrediction = function _InvoiceV3_initFromApiPrediction(apiPrediction, pageId) {
|
|
143
149
|
this.locale = new fields_1.Locale({
|
|
144
150
|
prediction: apiPrediction.locale,
|
|
145
151
|
valueKey: "language",
|
|
@@ -212,18 +218,18 @@ _Invoice_instances = new WeakSet(), _Invoice_initFromApiPrediction = function _I
|
|
|
212
218
|
prediction: prediction,
|
|
213
219
|
pageId: pageId,
|
|
214
220
|
})));
|
|
215
|
-
},
|
|
221
|
+
}, _InvoiceV3_checklist = function _InvoiceV3_checklist() {
|
|
216
222
|
this.checklist = {
|
|
217
223
|
taxesMatchTotalIncl: this.taxesMatchTotalIncl(),
|
|
218
224
|
taxesMatchTotalExcl: this.taxesMatchTotalExcl(),
|
|
219
225
|
taxesAndTotalExclMatchTotalIncl: this.taxesAndTotalExclMatchTotalIncl(),
|
|
220
226
|
};
|
|
221
|
-
},
|
|
222
|
-
__classPrivateFieldGet(this,
|
|
223
|
-
__classPrivateFieldGet(this,
|
|
224
|
-
__classPrivateFieldGet(this,
|
|
225
|
-
__classPrivateFieldGet(this,
|
|
226
|
-
},
|
|
227
|
+
}, _InvoiceV3_reconstruct = function _InvoiceV3_reconstruct() {
|
|
228
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstructTotalTax).call(this);
|
|
229
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstructTotalExcl).call(this);
|
|
230
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstructTotalIncl).call(this);
|
|
231
|
+
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstructTotalTaxFromTotals).call(this);
|
|
232
|
+
}, _InvoiceV3_reconstructTotalTax = function _InvoiceV3_reconstructTotalTax() {
|
|
227
233
|
if (this.taxes.length > 0) {
|
|
228
234
|
const totalTax = {
|
|
229
235
|
value: this.taxes.reduce((acc, tax) => {
|
|
@@ -238,7 +244,7 @@ _Invoice_instances = new WeakSet(), _Invoice_initFromApiPrediction = function _I
|
|
|
238
244
|
reconstructed: true,
|
|
239
245
|
});
|
|
240
246
|
}
|
|
241
|
-
},
|
|
247
|
+
}, _InvoiceV3_reconstructTotalTaxFromTotals = function _InvoiceV3_reconstructTotalTaxFromTotals() {
|
|
242
248
|
if (this.totalTax.value !== undefined ||
|
|
243
249
|
this.totalExcl.value === undefined ||
|
|
244
250
|
this.totalIncl.value === undefined) {
|
|
@@ -255,7 +261,7 @@ _Invoice_instances = new WeakSet(), _Invoice_initFromApiPrediction = function _I
|
|
|
255
261
|
reconstructed: true,
|
|
256
262
|
});
|
|
257
263
|
}
|
|
258
|
-
},
|
|
264
|
+
}, _InvoiceV3_reconstructTotalExcl = function _InvoiceV3_reconstructTotalExcl() {
|
|
259
265
|
if (this.totalIncl.value === undefined ||
|
|
260
266
|
this.taxes.length === 0 ||
|
|
261
267
|
this.totalExcl.value !== undefined) {
|
|
@@ -271,7 +277,7 @@ _Invoice_instances = new WeakSet(), _Invoice_initFromApiPrediction = function _I
|
|
|
271
277
|
valueKey: "value",
|
|
272
278
|
reconstructed: true,
|
|
273
279
|
});
|
|
274
|
-
},
|
|
280
|
+
}, _InvoiceV3_reconstructTotalIncl = function _InvoiceV3_reconstructTotalIncl() {
|
|
275
281
|
if (!(this.totalExcl.value === undefined ||
|
|
276
282
|
this.taxes.length === 0 ||
|
|
277
283
|
this.totalIncl.value !== undefined)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Document, DocumentConstructorProps } from "
|
|
2
|
-
import { Field, DateField } from "
|
|
3
|
-
export declare class
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
+
import { Field, DateField } from "../../fields";
|
|
3
|
+
export declare class PassportV1 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
country: Field;
|
|
6
6
|
idNumber: Field;
|
|
@@ -15,7 +15,7 @@ export declare class Passport extends Document {
|
|
|
15
15
|
givenNames: Field[];
|
|
16
16
|
fullName: Field;
|
|
17
17
|
mrz: Field;
|
|
18
|
-
constructor({ prediction, orientation, extras,
|
|
18
|
+
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
19
19
|
static convertMRZDateToDatetime(dateString: string): Date;
|
|
20
20
|
toString(): string;
|
|
21
21
|
isExpired(): boolean;
|
|
@@ -27,17 +27,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
27
27
|
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");
|
|
28
28
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
29
|
};
|
|
30
|
-
var
|
|
30
|
+
var _PassportV1_instances, _PassportV1_checklist;
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
33
|
-
const document_1 = require("
|
|
34
|
-
const fields_1 = require("
|
|
32
|
+
exports.PassportV1 = void 0;
|
|
33
|
+
const document_1 = require("../document");
|
|
34
|
+
const fields_1 = require("../../fields");
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
const MRZ = __importStar(require("mrz"));
|
|
37
|
-
class
|
|
38
|
-
constructor({ prediction, orientation = undefined, extras = undefined,
|
|
39
|
-
super({
|
|
40
|
-
|
|
37
|
+
class PassportV1 extends document_1.Document {
|
|
38
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
|
|
39
|
+
super({
|
|
40
|
+
inputSource: inputSource,
|
|
41
|
+
pageId: pageId,
|
|
42
|
+
orientation: orientation,
|
|
43
|
+
extras: extras,
|
|
44
|
+
});
|
|
45
|
+
_PassportV1_instances.add(this);
|
|
41
46
|
this.givenNames = [];
|
|
42
47
|
this.country = new fields_1.Field({
|
|
43
48
|
prediction: prediction.country,
|
|
@@ -85,7 +90,7 @@ class Passport extends document_1.Document {
|
|
|
85
90
|
})));
|
|
86
91
|
this.fullName = this.constructFullName(pageId);
|
|
87
92
|
this.mrz = this.constructMRZ(pageId);
|
|
88
|
-
__classPrivateFieldGet(this,
|
|
93
|
+
__classPrivateFieldGet(this, _PassportV1_instances, "m", _PassportV1_checklist).call(this);
|
|
89
94
|
}
|
|
90
95
|
static convertMRZDateToDatetime(dateString) {
|
|
91
96
|
const year = parseInt(dateString.substring(0, 2));
|
|
@@ -110,7 +115,7 @@ MRZ 2: ${this.mrz2}
|
|
|
110
115
|
MRZ: ${this.mrz}
|
|
111
116
|
----------------------
|
|
112
117
|
`;
|
|
113
|
-
return
|
|
118
|
+
return PassportV1.cleanOutString(outStr);
|
|
114
119
|
}
|
|
115
120
|
isExpired() {
|
|
116
121
|
const dateTime = new Date();
|
|
@@ -129,7 +134,7 @@ MRZ: ${this.mrz}
|
|
|
129
134
|
if (this.birthDate.dateObject === undefined || !mrz.fields.birthDate) {
|
|
130
135
|
return false;
|
|
131
136
|
}
|
|
132
|
-
const mrzDate =
|
|
137
|
+
const mrzDate = PassportV1.convertMRZDateToDatetime(mrz.fields.birthDate);
|
|
133
138
|
const check = fields_1.DateField.compareDates(this.birthDate.dateObject, mrzDate);
|
|
134
139
|
if (check) {
|
|
135
140
|
this.birthDate.confidence = 1.0;
|
|
@@ -141,7 +146,7 @@ MRZ: ${this.mrz}
|
|
|
141
146
|
!mrz.fields.expirationDate) {
|
|
142
147
|
return false;
|
|
143
148
|
}
|
|
144
|
-
const mrzDate =
|
|
149
|
+
const mrzDate = PassportV1.convertMRZDateToDatetime(mrz.fields.expirationDate);
|
|
145
150
|
const check = fields_1.DateField.compareDates(this.expiryDate.dateObject, mrzDate);
|
|
146
151
|
if (check) {
|
|
147
152
|
this.expiryDate.confidence = 1.0;
|
|
@@ -196,8 +201,8 @@ MRZ: ${this.mrz}
|
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
203
|
}
|
|
199
|
-
exports.
|
|
200
|
-
|
|
204
|
+
exports.PassportV1 = PassportV1;
|
|
205
|
+
_PassportV1_instances = new WeakSet(), _PassportV1_checklist = function _PassportV1_checklist() {
|
|
201
206
|
if (this.mrz1.value && this.mrz2.value) {
|
|
202
207
|
const mrz = MRZ.parse([this.mrz1.value, this.mrz2.value]);
|
|
203
208
|
this.checklist = {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
+
import { TaxField, Field, Amount, Locale, DateField } from "../../fields";
|
|
3
|
+
export declare class ReceiptV3 extends Document {
|
|
4
|
+
#private;
|
|
5
|
+
locale: Locale;
|
|
6
|
+
totalIncl: Amount;
|
|
7
|
+
date: DateField;
|
|
8
|
+
/** Receipt category as seen on the receipt. */
|
|
9
|
+
category: Field;
|
|
10
|
+
merchantName: Field;
|
|
11
|
+
time: Field;
|
|
12
|
+
totalTax: Amount;
|
|
13
|
+
totalExcl: Amount;
|
|
14
|
+
taxes: TaxField[];
|
|
15
|
+
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
@@ -4,15 +4,21 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
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
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var _ReceiptV3_instances, _ReceiptV3_initFromApiPrediction, _ReceiptV3_checklist, _ReceiptV3_taxesMatchTotal, _ReceiptV3_reconstruct, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes, _ReceiptV3_reconstructTotalTax;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
const document_1 = require("
|
|
11
|
-
const fields_1 = require("
|
|
12
|
-
class
|
|
13
|
-
constructor({ prediction, orientation = undefined, extras = undefined,
|
|
14
|
-
super({
|
|
15
|
-
|
|
9
|
+
exports.ReceiptV3 = void 0;
|
|
10
|
+
const document_1 = require("../document");
|
|
11
|
+
const fields_1 = require("../../fields");
|
|
12
|
+
class ReceiptV3 extends document_1.Document {
|
|
13
|
+
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
14
|
+
super({
|
|
15
|
+
inputSource: inputSource,
|
|
16
|
+
pageId: pageId,
|
|
17
|
+
orientation: orientation,
|
|
18
|
+
extras: extras,
|
|
19
|
+
fullText: fullText,
|
|
20
|
+
});
|
|
21
|
+
_ReceiptV3_instances.add(this);
|
|
16
22
|
this.taxes = [];
|
|
17
23
|
this.locale = new fields_1.Locale({
|
|
18
24
|
prediction: prediction.locale,
|
|
@@ -28,9 +34,9 @@ class Receipt extends document_1.Document {
|
|
|
28
34
|
valueKey: "value",
|
|
29
35
|
pageId: pageId,
|
|
30
36
|
});
|
|
31
|
-
__classPrivateFieldGet(this,
|
|
32
|
-
__classPrivateFieldGet(this,
|
|
33
|
-
__classPrivateFieldGet(this,
|
|
37
|
+
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_initFromApiPrediction).call(this, prediction, pageId);
|
|
38
|
+
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_checklist).call(this);
|
|
39
|
+
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstruct).call(this);
|
|
34
40
|
}
|
|
35
41
|
toString() {
|
|
36
42
|
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
@@ -47,11 +53,11 @@ Total taxes: ${this.totalTax}
|
|
|
47
53
|
Locale: ${this.locale}
|
|
48
54
|
----------------------
|
|
49
55
|
`;
|
|
50
|
-
return
|
|
56
|
+
return ReceiptV3.cleanOutString(outStr);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
exports.
|
|
54
|
-
|
|
59
|
+
exports.ReceiptV3 = ReceiptV3;
|
|
60
|
+
_ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = function _ReceiptV3_initFromApiPrediction(apiPrediction, pageId) {
|
|
55
61
|
this.totalIncl = new fields_1.Amount({
|
|
56
62
|
prediction: apiPrediction.total_incl,
|
|
57
63
|
valueKey: "value",
|
|
@@ -80,9 +86,9 @@ _Receipt_instances = new WeakSet(), _Receipt_initFromApiPrediction = function _R
|
|
|
80
86
|
rateKey: "rate",
|
|
81
87
|
codeKey: "code",
|
|
82
88
|
})));
|
|
83
|
-
},
|
|
84
|
-
this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this,
|
|
85
|
-
},
|
|
89
|
+
}, _ReceiptV3_checklist = function _ReceiptV3_checklist() {
|
|
90
|
+
this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_taxesMatchTotal).call(this) };
|
|
91
|
+
}, _ReceiptV3_taxesMatchTotal = function _ReceiptV3_taxesMatchTotal() {
|
|
86
92
|
// Check taxes and total amount exist
|
|
87
93
|
if (this.taxes.length === 0 || this.totalIncl.value === undefined) {
|
|
88
94
|
return false;
|
|
@@ -111,10 +117,10 @@ _Receipt_instances = new WeakSet(), _Receipt_initFromApiPrediction = function _R
|
|
|
111
117
|
return true;
|
|
112
118
|
}
|
|
113
119
|
return false;
|
|
114
|
-
},
|
|
115
|
-
__classPrivateFieldGet(this,
|
|
116
|
-
__classPrivateFieldGet(this,
|
|
117
|
-
},
|
|
120
|
+
}, _ReceiptV3_reconstruct = function _ReceiptV3_reconstruct() {
|
|
121
|
+
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstructTotalExclFromTCCAndTaxes).call(this);
|
|
122
|
+
__classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstructTotalTax).call(this);
|
|
123
|
+
}, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes = function _ReceiptV3_reconstructTotalExclFromTCCAndTaxes() {
|
|
118
124
|
if (this.taxes.length && this.totalIncl.value !== undefined) {
|
|
119
125
|
const totalExcl = {
|
|
120
126
|
value: this.totalIncl.value - fields_1.Field.arraySum(this.taxes),
|
|
@@ -127,7 +133,7 @@ _Receipt_instances = new WeakSet(), _Receipt_initFromApiPrediction = function _R
|
|
|
127
133
|
reconstructed: true,
|
|
128
134
|
});
|
|
129
135
|
}
|
|
130
|
-
},
|
|
136
|
+
}, _ReceiptV3_reconstructTotalTax = function _ReceiptV3_reconstructTotalTax() {
|
|
131
137
|
if (this.taxes.length && this.totalTax.value === undefined) {
|
|
132
138
|
const totalTax = {
|
|
133
139
|
value: this.taxes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
+
import { Amount, DateField, Field, Locale, TaxField } from "../../fields";
|
|
3
|
+
export declare class ReceiptV4 extends Document {
|
|
4
|
+
#private;
|
|
5
|
+
/** Where the purchase was made, the language, and the currency. */
|
|
6
|
+
locale: Locale;
|
|
7
|
+
/** The purchase date. */
|
|
8
|
+
date: DateField;
|
|
9
|
+
/** The type of purchase. */
|
|
10
|
+
category: Field;
|
|
11
|
+
/** Merchant's name as seen on the receipt. */
|
|
12
|
+
supplier: Field;
|
|
13
|
+
/** Time as seen on the receipt in HH:MM format. */
|
|
14
|
+
time: Field;
|
|
15
|
+
/** List of taxes detected on the receipt. */
|
|
16
|
+
taxes: TaxField[];
|
|
17
|
+
/** Total amount of tip and gratuity. */
|
|
18
|
+
tip: Amount;
|
|
19
|
+
/** total spent including taxes, discounts, fees, tips, and gratuity. */
|
|
20
|
+
totalAmount: Amount;
|
|
21
|
+
/** Total amount of the purchase excluding taxes. */
|
|
22
|
+
totalNet: Amount;
|
|
23
|
+
/** Total tax amount of the purchase. */
|
|
24
|
+
totalTax: Amount;
|
|
25
|
+
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
26
|
+
toString(): string;
|
|
27
|
+
}
|