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.
Files changed (66) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +30 -9
  3. package/package.json +3 -2
  4. package/src/api/endpoint.d.ts +19 -17
  5. package/src/api/endpoint.js +27 -39
  6. package/src/api/index.d.ts +2 -2
  7. package/src/api/index.js +2 -11
  8. package/src/api/response.d.ts +8 -41
  9. package/src/api/response.js +18 -89
  10. package/src/cli.js +46 -12
  11. package/src/client.d.ts +47 -13
  12. package/src/client.js +73 -27
  13. package/src/documents/cropper/cropperV1.d.ts +7 -0
  14. package/src/documents/{cropper.js → cropper/cropperV1.js} +12 -8
  15. package/src/documents/custom.d.ts +2 -6
  16. package/src/documents/custom.js +12 -7
  17. package/src/documents/document.d.ts +8 -3
  18. package/src/documents/document.js +11 -5
  19. package/src/documents/documentConfig.d.ts +20 -34
  20. package/src/documents/documentConfig.js +33 -57
  21. package/src/documents/{financialDocument.d.ts → financialDocument/financialDocumentV1.d.ts} +4 -4
  22. package/src/documents/{financialDocument.js → financialDocument/financialDocumentV1.js} +28 -22
  23. package/src/documents/fr/idCard/idCardV1.d.ts +3 -0
  24. package/src/documents/fr/idCard/idCardV1.js +7 -0
  25. package/src/documents/index.d.ts +15 -13
  26. package/src/documents/index.js +21 -18
  27. package/src/documents/{invoice.d.ts → invoice/invoiceV3.d.ts} +4 -4
  28. package/src/documents/{invoice.js → invoice/invoiceV3.js} +30 -24
  29. package/src/documents/{passport.d.ts → passport/passportV1.d.ts} +4 -4
  30. package/src/documents/{passport.js → passport/passportV1.js} +19 -14
  31. package/src/documents/receipt/receiptV3.d.ts +17 -0
  32. package/src/documents/{receipt.js → receipt/receiptV3.js} +28 -22
  33. package/src/documents/receipt/receiptV4.d.ts +27 -0
  34. package/src/documents/receipt/receiptV4.js +96 -0
  35. package/src/documents/receipt/tax.d.ts +25 -0
  36. package/src/documents/receipt/tax.js +40 -0
  37. package/src/documents/us/bankCheck/bankCheckV1.d.ts +3 -0
  38. package/src/documents/us/bankCheck/bankCheckV1.js +7 -0
  39. package/src/errors/MindeeError.d.ts +3 -0
  40. package/src/errors/MindeeError.js +10 -0
  41. package/src/errors/index.d.ts +1 -0
  42. package/src/errors/index.js +5 -0
  43. package/src/fields/{customDocs.d.ts → apiBuilder.d.ts} +5 -1
  44. package/src/fields/{customDocs.js → apiBuilder.js} +0 -0
  45. package/src/fields/index.d.ts +1 -1
  46. package/src/fields/index.js +4 -4
  47. package/src/index.d.ts +2 -1
  48. package/src/index.js +11 -9
  49. package/src/inputs/base.d.ts +33 -0
  50. package/src/inputs/base.js +116 -0
  51. package/src/inputs/index.d.ts +3 -0
  52. package/src/inputs/index.js +18 -0
  53. package/src/inputs/pageOptions.d.ts +20 -0
  54. package/src/inputs/pageOptions.js +8 -0
  55. package/src/inputs/sources.d.ts +55 -0
  56. package/src/inputs/sources.js +121 -0
  57. package/src/pdf/index.d.ts +1 -0
  58. package/src/pdf/index.js +6 -0
  59. package/src/pdf/pdfOperation.d.ts +14 -0
  60. package/src/pdf/pdfOperation.js +69 -0
  61. package/src/constants.d.ts +0 -13
  62. package/src/constants.js +0 -60
  63. package/src/documents/cropper.d.ts +0 -7
  64. package/src/documents/receipt.d.ts +0 -17
  65. package/src/inputs.d.ts +0 -69
  66. 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 _FinancialDocument_instances, _FinancialDocument_initFromApiPrediction, _FinancialDocument_checklist, _FinancialDocument_taxesMatchTotalIncl;
7
+ var _FinancialDocumentV1_instances, _FinancialDocumentV1_initFromApiPrediction, _FinancialDocumentV1_checklist, _FinancialDocumentV1_taxesMatchTotalIncl;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.FinancialDocument = void 0;
10
- const document_1 = require("./document");
11
- const invoice_1 = require("./invoice");
12
- const receipt_1 = require("./receipt");
13
- const fields_1 = require("../fields");
14
- class FinancialDocument extends document_1.Document {
15
- constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
16
- super({ inputFile, pageId, fullText, orientation, extras });
17
- _FinancialDocument_instances.add(this);
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, _FinancialDocument_instances, "m", _FinancialDocument_initFromApiPrediction).call(this, prediction, inputFile, pageId, orientation, extras);
23
- __classPrivateFieldGet(this, _FinancialDocument_instances, "m", _FinancialDocument_checklist).call(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 FinancialDocument.cleanOutString(outStr);
40
+ return FinancialDocumentV1.cleanOutString(outStr);
35
41
  }
36
42
  }
37
- exports.FinancialDocument = FinancialDocument;
38
- _FinancialDocument_instances = new WeakSet(), _FinancialDocument_initFromApiPrediction = function _FinancialDocument_initFromApiPrediction(prediction, inputFile, pageNumber, orientation, extras) {
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 invoice_1.Invoice({
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 receipt_1.Receipt({
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
- }, _FinancialDocument_checklist = function _FinancialDocument_checklist() {
104
+ }, _FinancialDocumentV1_checklist = function _FinancialDocumentV1_checklist() {
99
105
  this.checklist = {
100
- taxesMatchTotalIncl: __classPrivateFieldGet(this, _FinancialDocument_instances, "m", _FinancialDocument_taxesMatchTotalIncl).call(this),
106
+ taxesMatchTotalIncl: __classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_taxesMatchTotalIncl).call(this),
101
107
  };
102
- }, _FinancialDocument_taxesMatchTotalIncl = function _FinancialDocument_taxesMatchTotalIncl() {
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;
@@ -0,0 +1,3 @@
1
+ import { Document } from "../../document";
2
+ export declare class IdCardV1 extends Document {
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdCardV1 = void 0;
4
+ const document_1 = require("../../document");
5
+ class IdCardV1 extends document_1.Document {
6
+ }
7
+ exports.IdCardV1 = IdCardV1;
@@ -1,14 +1,16 @@
1
- import { Invoice } from "./invoice";
2
- import { Receipt } from "./receipt";
3
- import { Passport } from "./passport";
4
- import { FinancialDocument } from "./financialDocument";
5
- import { CustomDocument } from "./custom";
6
- import { Cropper } from "./cropper";
7
- export { Document, DocumentConstructorProps } from "./document";
8
- export { Receipt, Invoice, FinancialDocument, Passport, CustomDocument, Cropper, };
9
- export declare const DOC_TYPE_INVOICE: string;
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 DOC_TYPE_CROPPER: string;
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;
@@ -1,23 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DOC_TYPE_CROPPER = exports.DOC_TYPE_CUSTOM = exports.DOC_TYPE_FINANCIAL = exports.DOC_TYPE_PASSPORT = exports.DOC_TYPE_RECEIPT = exports.DOC_TYPE_INVOICE = exports.Cropper = exports.CustomDocument = exports.Passport = exports.FinancialDocument = exports.Invoice = exports.Receipt = exports.Document = void 0;
4
- const invoice_1 = require("./invoice");
5
- Object.defineProperty(exports, "Invoice", { enumerable: true, get: function () { return invoice_1.Invoice; } });
6
- const receipt_1 = require("./receipt");
7
- Object.defineProperty(exports, "Receipt", { enumerable: true, get: function () { return receipt_1.Receipt; } });
8
- const passport_1 = require("./passport");
9
- Object.defineProperty(exports, "Passport", { enumerable: true, get: function () { return passport_1.Passport; } });
10
- const financialDocument_1 = require("./financialDocument");
11
- Object.defineProperty(exports, "FinancialDocument", { enumerable: true, get: function () { return financialDocument_1.FinancialDocument; } });
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, "CustomDocument", { enumerable: true, get: function () { return custom_1.CustomDocument; } });
14
- const cropper_1 = require("./cropper");
15
- Object.defineProperty(exports, "Cropper", { enumerable: true, get: function () { return cropper_1.Cropper; } });
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.DOC_TYPE_INVOICE = invoice_1.Invoice.name;
19
- exports.DOC_TYPE_RECEIPT = receipt_1.Receipt.name;
20
- exports.DOC_TYPE_PASSPORT = passport_1.Passport.name;
21
- exports.DOC_TYPE_FINANCIAL = financialDocument_1.FinancialDocument.name;
22
- exports.DOC_TYPE_CUSTOM = custom_1.CustomDocument.name;
23
- exports.DOC_TYPE_CROPPER = cropper_1.Cropper.name;
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 "./document";
2
- import { BaseField, TaxField, PaymentDetails, Locale, Amount, Field, DateField, CompanyRegistration } from "../fields";
3
- export declare class Invoice extends Document {
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, inputFile, fullText, pageId, }: DocumentConstructorProps);
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 _Invoice_instances, _Invoice_initFromApiPrediction, _Invoice_checklist, _Invoice_reconstruct, _Invoice_reconstructTotalTax, _Invoice_reconstructTotalTaxFromTotals, _Invoice_reconstructTotalExcl, _Invoice_reconstructTotalIncl;
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.Invoice = void 0;
10
- const document_1 = require("./document");
11
- const fields_1 = require("../fields");
12
- class Invoice extends document_1.Document {
13
- constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
14
- super({ inputFile, pageId, fullText, orientation, extras });
15
- _Invoice_instances.add(this);
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, _Invoice_instances, "m", _Invoice_initFromApiPrediction).call(this, prediction, pageId);
21
- __classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_checklist).call(this);
22
- __classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_reconstruct).call(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 Invoice.cleanOutString(outStr);
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.Invoice = Invoice;
142
- _Invoice_instances = new WeakSet(), _Invoice_initFromApiPrediction = function _Invoice_initFromApiPrediction(apiPrediction, pageId) {
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
- }, _Invoice_checklist = function _Invoice_checklist() {
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
- }, _Invoice_reconstruct = function _Invoice_reconstruct() {
222
- __classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_reconstructTotalTax).call(this);
223
- __classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_reconstructTotalExcl).call(this);
224
- __classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_reconstructTotalIncl).call(this);
225
- __classPrivateFieldGet(this, _Invoice_instances, "m", _Invoice_reconstructTotalTaxFromTotals).call(this);
226
- }, _Invoice_reconstructTotalTax = function _Invoice_reconstructTotalTax() {
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
- }, _Invoice_reconstructTotalTaxFromTotals = function _Invoice_reconstructTotalTaxFromTotals() {
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
- }, _Invoice_reconstructTotalExcl = function _Invoice_reconstructTotalExcl() {
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
- }, _Invoice_reconstructTotalIncl = function _Invoice_reconstructTotalIncl() {
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 "./document";
2
- import { Field, DateField } from "../fields";
3
- export declare class Passport extends Document {
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, inputFile, pageId, }: DocumentConstructorProps);
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 _Passport_instances, _Passport_checklist;
30
+ var _PassportV1_instances, _PassportV1_checklist;
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.Passport = void 0;
33
- const document_1 = require("./document");
34
- const fields_1 = require("../fields");
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 Passport extends document_1.Document {
38
- constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, pageId = undefined, }) {
39
- super({ inputFile, pageId, orientation, extras });
40
- _Passport_instances.add(this);
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, _Passport_instances, "m", _Passport_checklist).call(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 Passport.cleanOutString(outStr);
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 = Passport.convertMRZDateToDatetime(mrz.fields.birthDate);
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 = Passport.convertMRZDateToDatetime(mrz.fields.expirationDate);
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.Passport = Passport;
200
- _Passport_instances = new WeakSet(), _Passport_checklist = function _Passport_checklist() {
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 _Receipt_instances, _Receipt_initFromApiPrediction, _Receipt_checklist, _Receipt_taxesMatchTotal, _Receipt_reconstruct, _Receipt_reconstructTotalExclFromTCCAndTaxes, _Receipt_reconstructTotalTax;
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.Receipt = void 0;
10
- const document_1 = require("./document");
11
- const fields_1 = require("../fields");
12
- class Receipt extends document_1.Document {
13
- constructor({ prediction, orientation = undefined, extras = undefined, inputFile = undefined, fullText = undefined, pageId = undefined, }) {
14
- super({ inputFile, pageId, fullText, orientation, extras });
15
- _Receipt_instances.add(this);
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, _Receipt_instances, "m", _Receipt_initFromApiPrediction).call(this, prediction, pageId);
32
- __classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_checklist).call(this);
33
- __classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_reconstruct).call(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 Receipt.cleanOutString(outStr);
56
+ return ReceiptV3.cleanOutString(outStr);
51
57
  }
52
58
  }
53
- exports.Receipt = Receipt;
54
- _Receipt_instances = new WeakSet(), _Receipt_initFromApiPrediction = function _Receipt_initFromApiPrediction(apiPrediction, pageId) {
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
- }, _Receipt_checklist = function _Receipt_checklist() {
84
- this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_taxesMatchTotal).call(this) };
85
- }, _Receipt_taxesMatchTotal = function _Receipt_taxesMatchTotal() {
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
- }, _Receipt_reconstruct = function _Receipt_reconstruct() {
115
- __classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_reconstructTotalExclFromTCCAndTaxes).call(this);
116
- __classPrivateFieldGet(this, _Receipt_instances, "m", _Receipt_reconstructTotalTax).call(this);
117
- }, _Receipt_reconstructTotalExclFromTCCAndTaxes = function _Receipt_reconstructTotalExclFromTCCAndTaxes() {
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
- }, _Receipt_reconstructTotalTax = function _Receipt_reconstructTotalTax() {
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
+ }