mindee 3.9.0 → 3.10.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/src/cli.js +0 -10
  4. package/src/client.js +3 -3
  5. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +18 -0
  6. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +48 -0
  7. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +34 -0
  8. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +67 -0
  9. package/src/documents/fr/index.d.ts +1 -0
  10. package/src/documents/fr/index.js +3 -1
  11. package/src/documents/index.d.ts +0 -1
  12. package/src/documents/index.js +1 -3
  13. package/src/documents/receipt/receiptV5.d.ts +25 -25
  14. package/src/documents/receipt/receiptV5.js +39 -42
  15. package/src/documents/receipt/receiptV5LineItem.d.ts +1 -1
  16. package/src/documents/receipt/receiptV5LineItem.js +1 -1
  17. package/src/fields/amount.d.ts +3 -0
  18. package/src/fields/amount.js +3 -0
  19. package/src/fields/base.d.ts +3 -0
  20. package/src/fields/base.js +3 -0
  21. package/src/fields/classification.d.ts +3 -0
  22. package/src/fields/classification.js +3 -0
  23. package/src/fields/companyRegistration.d.ts +3 -0
  24. package/src/fields/companyRegistration.js +3 -0
  25. package/src/fields/date.d.ts +3 -0
  26. package/src/fields/date.js +3 -0
  27. package/src/fields/field.d.ts +3 -0
  28. package/src/fields/field.js +3 -0
  29. package/src/fields/fullText.d.ts +3 -0
  30. package/src/fields/fullText.js +3 -0
  31. package/src/fields/locale.d.ts +3 -0
  32. package/src/fields/locale.js +3 -0
  33. package/src/fields/orientation.d.ts +3 -0
  34. package/src/fields/orientation.js +3 -0
  35. package/src/fields/paymentDetails.d.ts +3 -0
  36. package/src/fields/paymentDetails.js +3 -0
  37. package/src/fields/position.d.ts +3 -0
  38. package/src/fields/position.js +3 -0
  39. package/src/fields/text.d.ts +3 -0
  40. package/src/fields/text.js +3 -0
  41. package/src/index.d.ts +1 -1
  42. package/src/index.js +1 -2
  43. package/src/documents/shippingContainer/shippingContainerV1.d.ts +0 -12
  44. package/src/documents/shippingContainer/shippingContainerV1.js +0 -38
package/CHANGELOG.md CHANGED
@@ -1,10 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v3.10.0 - 2023-07-04
4
+ ### Changes
5
+ * :sparkles: add support for FR Bank Account Details V2
6
+ * :recycle: update printing syntax & unit test for Receipt v5
7
+
8
+
3
9
  ## v3.9.0 - 2023-06-06
4
10
  ### Changes
5
11
  * :sparkles: support for financial document v1.1
6
12
  * :recycle: change http status code handling for async requests
7
13
 
14
+
8
15
  ### Fixes
9
16
  * :bug: fix typing in PaymentDetails
10
17
  * :bug: locale value should always be set
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/cli.js CHANGED
@@ -148,16 +148,6 @@ const CLI_COMMAND_CONFIG = new Map([
148
148
  sync: true,
149
149
  },
150
150
  ],
151
- [
152
- "shipping-container",
153
- {
154
- displayName: "Shipping Container",
155
- docClass: _1.ShippingContainerV1,
156
- fullText: false,
157
- async: false,
158
- sync: true,
159
- },
160
- ],
161
151
  [
162
152
  "mvision",
163
153
  {
package/src/client.js CHANGED
@@ -154,15 +154,15 @@ class Client {
154
154
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV1, [
155
155
  new api_1.StandardEndpoint("bank_account_details", "1", this.apiKey),
156
156
  ]));
157
+ this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV2.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV2, [
158
+ new api_1.StandardEndpoint("bank_account_details", "2", this.apiKey),
159
+ ]));
157
160
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.CarteVitaleV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.CarteVitaleV1, [
158
161
  new api_1.StandardEndpoint("carte_vitale", "1", this.apiKey),
159
162
  ]));
160
163
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.eu.LicensePlateV1.name], new documentConfig_1.DocumentConfig(documents_1.eu.LicensePlateV1, [
161
164
  new api_1.StandardEndpoint("license_plates", "1", this.apiKey),
162
165
  ]));
163
- this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ShippingContainerV1.name], new documentConfig_1.DocumentConfig(documents_1.ShippingContainerV1, [
164
- new api_1.StandardEndpoint("shipping_containers", "1", this.apiKey),
165
- ]));
166
166
  this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.MindeeVisionV1.name], new documentConfig_1.DocumentConfig(documents_1.MindeeVisionV1, [
167
167
  new api_1.StandardEndpoint("mindee_vision", "1", this.apiKey),
168
168
  ]));
@@ -0,0 +1,18 @@
1
+ import { Document, DocumentConstructorProps } from "../../document";
2
+ import { TextField } from "../../../fields";
3
+ import { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban";
4
+ /**
5
+ * Document data for Bank Account Details, API version 2.
6
+ */
7
+ export declare class BankAccountDetailsV2 extends Document {
8
+ /** Full extraction of the account holders names. */
9
+ accountHoldersNames: TextField;
10
+ /** Full extraction of BBAN, including: branch code, bank code, account and key. */
11
+ bban: BankAccountDetailsV2Bban;
12
+ /** Full extraction of the IBAN number. */
13
+ iban: TextField;
14
+ /** Full extraction of the SWIFT code. */
15
+ swiftCode: TextField;
16
+ constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
17
+ toString(): string;
18
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BankAccountDetailsV2 = void 0;
4
+ const document_1 = require("../../document");
5
+ const fields_1 = require("../../../fields");
6
+ const bankAccountDetailsV2Bban_1 = require("./bankAccountDetailsV2Bban");
7
+ /**
8
+ * Document data for Bank Account Details, API version 2.
9
+ */
10
+ class BankAccountDetailsV2 extends document_1.Document {
11
+ constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
12
+ super({
13
+ inputSource: inputSource,
14
+ pageId: pageId,
15
+ orientation: orientation,
16
+ extras: extras,
17
+ fullText: fullText,
18
+ });
19
+ this.accountHoldersNames = new fields_1.TextField({
20
+ prediction: prediction["account_holders_names"],
21
+ pageId: pageId,
22
+ });
23
+ this.bban = new bankAccountDetailsV2Bban_1.BankAccountDetailsV2Bban({
24
+ prediction: prediction["bban"],
25
+ pageId: pageId,
26
+ });
27
+ this.iban = new fields_1.TextField({
28
+ prediction: prediction["iban"],
29
+ pageId: pageId,
30
+ });
31
+ this.swiftCode = new fields_1.TextField({
32
+ prediction: prediction["swift_code"],
33
+ pageId: pageId,
34
+ });
35
+ }
36
+ toString() {
37
+ const outStr = `FR Bank Account Details V2 Prediction
38
+ =====================================
39
+ :Filename: ${this.filename}
40
+ :Account Holder's Names: ${this.accountHoldersNames}
41
+ :Basic Bank Account Number: ${this.bban.toFieldList()}
42
+ :IBAN: ${this.iban}
43
+ :SWIFT Code: ${this.swiftCode}
44
+ `;
45
+ return BankAccountDetailsV2.cleanOutString(outStr);
46
+ }
47
+ }
48
+ exports.BankAccountDetailsV2 = BankAccountDetailsV2;
@@ -0,0 +1,34 @@
1
+ import { StringDict } from "../../../fields";
2
+ import { Polygon } from "../../../geometry";
3
+ /**
4
+ * Full extraction of BBAN, including: branch code, bank code, account and key.
5
+ */
6
+ export declare class BankAccountDetailsV2Bban {
7
+ #private;
8
+ /** The BBAN bank code outputted as a string. */
9
+ bbanBankCode: string | null;
10
+ /** The BBAN branch code outputted as a string. */
11
+ bbanBranchCode: string | null;
12
+ /** The BBAN key outputted as a string. */
13
+ bbanKey: string | null;
14
+ /** The BBAN Account number outputted as a string. */
15
+ bbanNumber: string | null;
16
+ /** Confidence score */
17
+ confidence: number;
18
+ /** The document page on which the information was found. */
19
+ pageId: number;
20
+ /**
21
+ * Contains the relative vertices coordinates (points) of a polygon containing
22
+ * the field in the document.
23
+ */
24
+ polygon: Polygon;
25
+ constructor({ prediction }: StringDict);
26
+ /**
27
+ * Default string representation.
28
+ */
29
+ toString(): string;
30
+ /**
31
+ * Output in a format suitable for inclusion in a field list.
32
+ */
33
+ toFieldList(): string;
34
+ }
@@ -0,0 +1,67 @@
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 _BankAccountDetailsV2Bban_instances, _BankAccountDetailsV2Bban_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BankAccountDetailsV2Bban = void 0;
10
+ /**
11
+ * Full extraction of BBAN, including: branch code, bank code, account and key.
12
+ */
13
+ class BankAccountDetailsV2Bban {
14
+ constructor({ prediction }) {
15
+ _BankAccountDetailsV2Bban_instances.add(this);
16
+ /** Confidence score */
17
+ this.confidence = 0.0;
18
+ /**
19
+ * Contains the relative vertices coordinates (points) of a polygon containing
20
+ * the field in the document.
21
+ */
22
+ this.polygon = [];
23
+ this.bbanBankCode = prediction["bban_bank_code"];
24
+ this.bbanBranchCode = prediction["bban_branch_code"];
25
+ this.bbanKey = prediction["bban_key"];
26
+ this.bbanNumber = prediction["bban_number"];
27
+ this.pageId = prediction["page_id"];
28
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
29
+ if (prediction["polygon"]) {
30
+ this.polygon = prediction.polygon;
31
+ }
32
+ }
33
+ /**
34
+ * Default string representation.
35
+ */
36
+ toString() {
37
+ const printable = __classPrivateFieldGet(this, _BankAccountDetailsV2Bban_instances, "m", _BankAccountDetailsV2Bban_printableValues).call(this);
38
+ return ("Bank Code: " +
39
+ printable.bbanBankCode +
40
+ ", Branch Code: " +
41
+ printable.bbanBranchCode +
42
+ ", Key: " +
43
+ printable.bbanKey +
44
+ ", Account Number: " +
45
+ printable.bbanNumber);
46
+ }
47
+ /**
48
+ * Output in a format suitable for inclusion in a field list.
49
+ */
50
+ toFieldList() {
51
+ const printable = __classPrivateFieldGet(this, _BankAccountDetailsV2Bban_instances, "m", _BankAccountDetailsV2Bban_printableValues).call(this);
52
+ return `
53
+ :Bank Code: ${printable.bbanBankCode}
54
+ :Branch Code: ${printable.bbanBranchCode}
55
+ :Key: ${printable.bbanKey}
56
+ :Account Number: ${printable.bbanNumber}`.trimEnd();
57
+ }
58
+ }
59
+ exports.BankAccountDetailsV2Bban = BankAccountDetailsV2Bban;
60
+ _BankAccountDetailsV2Bban_instances = new WeakSet(), _BankAccountDetailsV2Bban_printableValues = function _BankAccountDetailsV2Bban_printableValues() {
61
+ return {
62
+ bbanBankCode: this.bbanBankCode ?? "",
63
+ bbanBranchCode: this.bbanBranchCode ?? "",
64
+ bbanKey: this.bbanKey ?? "",
65
+ bbanNumber: this.bbanNumber ?? "",
66
+ };
67
+ };
@@ -1,3 +1,4 @@
1
1
  export { IdCardV1 } from "./idCard/idCardV1";
2
2
  export { BankAccountDetailsV1 } from "./bankAccountDetails/bankAccountDetailsV1";
3
+ export { BankAccountDetailsV2 } from "./bankAccountDetails/bankAccountDetailsV2";
3
4
  export { CarteVitaleV1 } from "./carteVitale/carteVitaleV1";
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CarteVitaleV1 = exports.BankAccountDetailsV1 = exports.IdCardV1 = void 0;
3
+ exports.CarteVitaleV1 = exports.BankAccountDetailsV2 = exports.BankAccountDetailsV1 = exports.IdCardV1 = void 0;
4
4
  var idCardV1_1 = require("./idCard/idCardV1");
5
5
  Object.defineProperty(exports, "IdCardV1", { enumerable: true, get: function () { return idCardV1_1.IdCardV1; } });
6
6
  var bankAccountDetailsV1_1 = require("./bankAccountDetails/bankAccountDetailsV1");
7
7
  Object.defineProperty(exports, "BankAccountDetailsV1", { enumerable: true, get: function () { return bankAccountDetailsV1_1.BankAccountDetailsV1; } });
8
+ var bankAccountDetailsV2_1 = require("./bankAccountDetails/bankAccountDetailsV2");
9
+ Object.defineProperty(exports, "BankAccountDetailsV2", { enumerable: true, get: function () { return bankAccountDetailsV2_1.BankAccountDetailsV2; } });
8
10
  var carteVitaleV1_1 = require("./carteVitale/carteVitaleV1");
9
11
  Object.defineProperty(exports, "CarteVitaleV1", { enumerable: true, get: function () { return carteVitaleV1_1.CarteVitaleV1; } });
@@ -12,7 +12,6 @@ export { getLineItems } from "./custom/lineitems";
12
12
  export { CropperV1 } from "./cropper/cropperV1";
13
13
  export { MindeeVisionV1 } from "./mindeeVision/mindeeVisionV1";
14
14
  export { ProofOfAddressV1 } from "./proofOfAddress/proofOfAddressV1";
15
- export { ShippingContainerV1 } from "./shippingContainer/shippingContainerV1";
16
15
  export { Document, DocumentConstructorProps, DocumentSig } from "./document";
17
16
  export * as fr from "./fr";
18
17
  export * as us from "./us";
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
26
+ exports.eu = exports.us = exports.fr = exports.Document = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
27
27
  var invoiceV3_1 = require("./invoice/invoiceV3");
28
28
  Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
29
29
  var invoiceV4_1 = require("./invoice/invoiceV4");
@@ -53,8 +53,6 @@ var mindeeVisionV1_1 = require("./mindeeVision/mindeeVisionV1");
53
53
  Object.defineProperty(exports, "MindeeVisionV1", { enumerable: true, get: function () { return mindeeVisionV1_1.MindeeVisionV1; } });
54
54
  var proofOfAddressV1_1 = require("./proofOfAddress/proofOfAddressV1");
55
55
  Object.defineProperty(exports, "ProofOfAddressV1", { enumerable: true, get: function () { return proofOfAddressV1_1.ProofOfAddressV1; } });
56
- var shippingContainerV1_1 = require("./shippingContainer/shippingContainerV1");
57
- Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return shippingContainerV1_1.ShippingContainerV1; } });
58
56
  var document_1 = require("./document");
59
57
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
60
58
  exports.fr = __importStar(require("./fr"));
@@ -2,42 +2,42 @@ import { Document, DocumentConstructorProps } from "../document";
2
2
  import { Amount, ClassificationField, CompanyRegistration, DateField, Locale, TaxField, TextField } from "../../fields";
3
3
  import { ReceiptV5LineItem } from "./receiptV5LineItem";
4
4
  /**
5
- * Document data for Receipt, API version 5.
5
+ * Document data for Expense Receipt, API version 5.
6
6
  */
7
7
  export declare class ReceiptV5 extends Document {
8
8
  #private;
9
- /** The locale identifier in BCP 47 (RFC 5646) format: ISO language code, '-', ISO country code. */
10
- locale: Locale;
11
- /** The receipt category among predefined classes. */
9
+ /** The purchase category among predefined classes. */
12
10
  category: ClassificationField;
13
- /** The receipt sub category among predefined classes for transport and food. */
14
- subcategory: ClassificationField;
15
- /** The receipt document type provides the information whether the document is an expense receipt or a credit card receipt. */
16
- documentType: ClassificationField;
17
11
  /** The date the purchase was made. */
18
12
  date: DateField;
19
- /** Time of purchase with 24 hours formatting (HH:MM). */
13
+ /** One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. */
14
+ documentType: ClassificationField;
15
+ /** List of line item details. */
16
+ lineItems: ReceiptV5LineItem[];
17
+ /** The locale detected on the document. */
18
+ locale: Locale;
19
+ /** The purchase subcategory among predefined classes for transport and food. */
20
+ subcategory: ClassificationField;
21
+ /** The address of the supplier or merchant. */
22
+ supplierAddress: TextField;
23
+ /** List of company registrations associated to the supplier. */
24
+ supplierCompanyRegistrations: CompanyRegistration[];
25
+ /** The name of the supplier or merchant. */
26
+ supplierName: TextField;
27
+ /** The phone number of the supplier or merchant. */
28
+ supplierPhoneNumber: TextField;
29
+ /** List of tax lines information. */
30
+ taxes: TaxField[];
31
+ /** The time the purchase was made. */
20
32
  time: TextField;
21
- /** The total amount paid including taxes, discounts, fees, tips, and gratuity. */
33
+ /** The total amount of tip and gratuity. */
34
+ tip: Amount;
35
+ /** The total amount paid: includes taxes, discounts, fees, tips, and gratuity. */
22
36
  totalAmount: Amount;
23
- /** The total amount excluding taxes. */
37
+ /** The net amount paid: does not include taxes, fees, and discounts. */
24
38
  totalNet: Amount;
25
39
  /** The total amount of taxes. */
26
40
  totalTax: Amount;
27
- /** The total amount of tip and gratuity. */
28
- tip: Amount;
29
- /** List of tax lines information including: Amount, tax rate, tax base amount and tax code. */
30
- taxes: TaxField[];
31
- /** The name of the supplier or merchant. */
32
- supplierName: TextField;
33
- /** List of supplier company registrations or identifiers. */
34
- supplierCompanyRegistrations: CompanyRegistration[];
35
- /** The address of the supplier or merchant returned as a single string. */
36
- supplierAddress: TextField;
37
- /** The Phone number of the supplier or merchant returned as a single string. */
38
- supplierPhoneNumber: TextField;
39
- /** Full extraction of lines, including: description, quantity, unit price and total. */
40
- lineItems: ReceiptV5LineItem[];
41
41
  constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
42
42
  toString(): string;
43
43
  }
@@ -11,7 +11,7 @@ const document_1 = require("../document");
11
11
  const fields_1 = require("../../fields");
12
12
  const receiptV5LineItem_1 = require("./receiptV5LineItem");
13
13
  /**
14
- * Document data for Receipt, API version 5.
14
+ * Document data for Expense Receipt, API version 5.
15
15
  */
16
16
  class ReceiptV5 extends document_1.Document {
17
17
  constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
@@ -23,88 +23,85 @@ class ReceiptV5 extends document_1.Document {
23
23
  fullText: fullText,
24
24
  });
25
25
  _ReceiptV5_instances.add(this);
26
- /** List of supplier company registrations or identifiers. */
27
- this.supplierCompanyRegistrations = [];
28
- /** Full extraction of lines, including: description, quantity, unit price and total. */
26
+ /** List of line item details. */
29
27
  this.lineItems = [];
30
- this.locale = new fields_1.Locale({
31
- prediction: prediction["locale"],
32
- });
28
+ /** List of company registrations associated to the supplier. */
29
+ this.supplierCompanyRegistrations = [];
33
30
  this.category = new fields_1.ClassificationField({
34
31
  prediction: prediction["category"],
35
32
  });
36
- this.subcategory = new fields_1.ClassificationField({
37
- prediction: prediction["subcategory"],
33
+ this.date = new fields_1.DateField({
34
+ prediction: prediction["date"],
35
+ pageId: pageId,
38
36
  });
39
37
  this.documentType = new fields_1.ClassificationField({
40
38
  prediction: prediction["document_type"],
41
39
  });
42
- this.date = new fields_1.DateField({
43
- prediction: prediction["date"],
40
+ prediction["line_items"].map((itemPrediction) => this.lineItems.push(new receiptV5LineItem_1.ReceiptV5LineItem({
41
+ prediction: itemPrediction,
44
42
  pageId: pageId,
43
+ })));
44
+ this.locale = new fields_1.Locale({
45
+ prediction: prediction["locale"],
45
46
  });
46
- this.time = new fields_1.TextField({
47
- prediction: prediction["time"],
47
+ this.subcategory = new fields_1.ClassificationField({
48
+ prediction: prediction["subcategory"],
49
+ });
50
+ this.supplierAddress = new fields_1.TextField({
51
+ prediction: prediction["supplier_address"],
48
52
  pageId: pageId,
49
53
  });
50
- this.totalAmount = new fields_1.Amount({
51
- prediction: prediction["total_amount"],
54
+ prediction["supplier_company_registrations"].map((itemPrediction) => this.supplierCompanyRegistrations.push(new fields_1.CompanyRegistration({
55
+ prediction: itemPrediction,
56
+ pageId: pageId,
57
+ })));
58
+ this.supplierName = new fields_1.TextField({
59
+ prediction: prediction["supplier_name"],
52
60
  pageId: pageId,
53
61
  });
54
- this.totalNet = new fields_1.Amount({
55
- prediction: prediction["total_net"],
62
+ this.supplierPhoneNumber = new fields_1.TextField({
63
+ prediction: prediction["supplier_phone_number"],
56
64
  pageId: pageId,
57
65
  });
58
- this.totalTax = new fields_1.Amount({
59
- prediction: prediction["total_tax"],
66
+ this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
67
+ this.time = new fields_1.TextField({
68
+ prediction: prediction["time"],
60
69
  pageId: pageId,
61
70
  });
62
71
  this.tip = new fields_1.Amount({
63
72
  prediction: prediction["tip"],
64
73
  pageId: pageId,
65
74
  });
66
- this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
67
- this.supplierName = new fields_1.TextField({
68
- prediction: prediction["supplier_name"],
75
+ this.totalAmount = new fields_1.Amount({
76
+ prediction: prediction["total_amount"],
69
77
  pageId: pageId,
70
78
  });
71
- prediction["supplier_company_registrations"].map((itemPrediction) => this.supplierCompanyRegistrations.push(new fields_1.CompanyRegistration({
72
- prediction: itemPrediction,
73
- pageId: pageId,
74
- })));
75
- this.supplierAddress = new fields_1.TextField({
76
- prediction: prediction["supplier_address"],
79
+ this.totalNet = new fields_1.Amount({
80
+ prediction: prediction["total_net"],
77
81
  pageId: pageId,
78
82
  });
79
- this.supplierPhoneNumber = new fields_1.TextField({
80
- prediction: prediction["supplier_phone_number"],
83
+ this.totalTax = new fields_1.Amount({
84
+ prediction: prediction["total_tax"],
81
85
  pageId: pageId,
82
86
  });
83
- prediction["line_items"].map((itemPrediction) => this.lineItems.push(new receiptV5LineItem_1.ReceiptV5LineItem({
84
- prediction: itemPrediction,
85
- pageId: pageId,
86
- })));
87
87
  }
88
88
  toString() {
89
- const supplierCompanyRegistrations = this.supplierCompanyRegistrations
90
- .map((item) => item.toString())
91
- .join("; ");
92
89
  const outStr = `Receipt V5 Prediction
93
90
  =====================
94
91
  :Filename: ${this.filename}
95
92
  :Expense Locale: ${this.locale}
96
- :Expense Category: ${this.category}
97
- :Expense Sub Category: ${this.subcategory}
93
+ :Purchase Category: ${this.category}
94
+ :Purchase Subcategory: ${this.subcategory}
98
95
  :Document Type: ${this.documentType}
99
96
  :Purchase Date: ${this.date}
100
97
  :Purchase Time: ${this.time}
101
98
  :Total Amount: ${this.totalAmount}
102
- :Total Excluding Taxes: ${this.totalNet}
99
+ :Total Net: ${this.totalNet}
103
100
  :Total Tax: ${this.totalTax}
104
101
  :Tip and Gratuity: ${this.tip}
105
102
  :Taxes: ${this.taxes}
106
103
  :Supplier Name: ${this.supplierName}
107
- :Supplier Company Registrations: ${supplierCompanyRegistrations}
104
+ :Supplier Company Registrations: ${this.supplierCompanyRegistrations.join(`${" ".repeat(32)}`)}
108
105
  :Supplier Address: ${this.supplierAddress}
109
106
  :Supplier Phone Number: ${this.supplierPhoneNumber}
110
107
  :Line Items: ${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsToString).call(this)}
@@ -121,7 +118,7 @@ _ReceiptV5_instances = new WeakSet(), _ReceiptV5_lineItemsSeparator = function _
121
118
  outStr += `+${char.repeat(12)}`;
122
119
  return outStr + "+";
123
120
  }, _ReceiptV5_lineItemsToString = function _ReceiptV5_lineItemsToString() {
124
- if (this.lineItems.length === 0) {
121
+ if (!this.lineItems || this.lineItems.length === 0) {
125
122
  return "";
126
123
  }
127
124
  const lines = this.lineItems
@@ -1,7 +1,7 @@
1
1
  import { StringDict } from "../../fields";
2
2
  import { Polygon } from "../../geometry";
3
3
  /**
4
- * Full extraction of lines, including: description, quantity, unit price and total.
4
+ * List of line item details.
5
5
  */
6
6
  export declare class ReceiptV5LineItem {
7
7
  #private;
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ReceiptV5LineItem = void 0;
10
10
  const amount_1 = require("../../fields/amount");
11
11
  /**
12
- * Full extraction of lines, including: description, quantity, unit price and total.
12
+ * List of line item details.
13
13
  */
14
14
  class ReceiptV5LineItem {
15
15
  constructor({ prediction }) {
@@ -1,5 +1,8 @@
1
1
  import { Field, FieldConstructor } from "./field";
2
2
  export declare function floatToString(value: number): string;
3
+ /**
4
+ * A field containing an amount value.
5
+ */
3
6
  export declare class Amount extends Field {
4
7
  /** The value. */
5
8
  value?: number;
@@ -10,6 +10,9 @@ function floatToString(value) {
10
10
  });
11
11
  }
12
12
  exports.floatToString = floatToString;
13
+ /**
14
+ * A field containing an amount value.
15
+ */
13
16
  class Amount extends field_1.Field {
14
17
  /**
15
18
  * @param {Object} prediction - Prediction object from HTTP response
@@ -6,6 +6,9 @@ export interface BaseFieldConstructor {
6
6
  valueKey?: string;
7
7
  reconstructed?: boolean;
8
8
  }
9
+ /**
10
+ * Base class for most fields.
11
+ */
9
12
  export declare class BaseField {
10
13
  /** The value. */
11
14
  value?: string | number;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseField = void 0;
4
+ /**
5
+ * Base class for most fields.
6
+ */
4
7
  class BaseField {
5
8
  /**
6
9
  * @param {Object} prediction - Prediction object from HTTP response
@@ -1,4 +1,7 @@
1
1
  import { BaseField, BaseFieldConstructor } from "./base";
2
+ /**
3
+ * Represents a classifier value.
4
+ */
2
5
  export declare class ClassificationField extends BaseField {
3
6
  /** The confidence score of the prediction. */
4
7
  confidence: number;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassificationField = void 0;
4
4
  const base_1 = require("./base");
5
+ /**
6
+ * Represents a classifier value.
7
+ */
5
8
  class ClassificationField extends base_1.BaseField {
6
9
  constructor({ prediction, valueKey = "value", reconstructed = false, }) {
7
10
  super({ prediction, valueKey, reconstructed });
@@ -1,4 +1,7 @@
1
1
  import { Field, FieldConstructor } from "./field";
2
+ /**
3
+ * A company registration item.
4
+ */
2
5
  export declare class CompanyRegistration extends Field {
3
6
  /** Registration identifier. */
4
7
  value?: string;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompanyRegistration = void 0;
4
4
  const field_1 = require("./field");
5
+ /**
6
+ * A company registration item.
7
+ */
5
8
  class CompanyRegistration extends field_1.Field {
6
9
  constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
7
10
  super({ prediction, valueKey, reconstructed, pageId });
@@ -1,4 +1,7 @@
1
1
  import { Field, FieldConstructor } from "./field";
2
+ /**
3
+ * A field containing a date value.
4
+ */
2
5
  export declare class DateField extends Field {
3
6
  /** Date string in ISO format. */
4
7
  value?: string;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateField = void 0;
4
4
  const field_1 = require("./field");
5
+ /**
6
+ * A field containing a date value.
7
+ */
5
8
  class DateField extends field_1.Field {
6
9
  /**
7
10
  * @param {Object} prediction - Prediction object from HTTP response
@@ -6,6 +6,9 @@ export interface FieldConstructor {
6
6
  reconstructed?: boolean;
7
7
  pageId?: number | undefined;
8
8
  }
9
+ /**
10
+ * A basic field with position and page information.
11
+ */
9
12
  export declare class Field extends BaseField {
10
13
  /**
11
14
  * Contains exactly 4 relative vertices coordinates (points) of a right
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Field = void 0;
4
4
  const base_1 = require("./base");
5
5
  const geometry_1 = require("../geometry");
6
+ /**
7
+ * A basic field with position and page information.
8
+ */
6
9
  class Field extends base_1.BaseField {
7
10
  /**
8
11
  * @param {Object} prediction - Prediction object from HTTP response
@@ -9,6 +9,9 @@ export type Word = {
9
9
  confidence: number;
10
10
  };
11
11
  type Line = Word[];
12
+ /**
13
+ * OCR extraction from the entire document.
14
+ */
12
15
  export declare class FullText {
13
16
  words: Word[];
14
17
  /**
@@ -62,6 +62,9 @@ function orderLines(fullText) {
62
62
  orderedLines.reverse();
63
63
  return orderedLines;
64
64
  }
65
+ /**
66
+ * OCR extraction from the entire document.
67
+ */
65
68
  class FullText {
66
69
  constructor() {
67
70
  this.words = [];
@@ -1,4 +1,7 @@
1
1
  import { BaseField, BaseFieldConstructor } from "./base";
2
+ /**
3
+ * The locale detected on the document.
4
+ */
2
5
  export declare class Locale extends BaseField {
3
6
  /** Locale in ISO format. */
4
7
  value?: string;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Locale = void 0;
4
4
  const base_1 = require("./base");
5
+ /**
6
+ * The locale detected on the document.
7
+ */
5
8
  class Locale extends base_1.BaseField {
6
9
  /**
7
10
  * @param {Object} prediction - Prediction object from HTTP response
@@ -2,6 +2,9 @@ import { BaseField, BaseFieldConstructor } from "./base";
2
2
  interface OrientationFieldConstructor extends BaseFieldConstructor {
3
3
  pageId: number;
4
4
  }
5
+ /**
6
+ * The clockwise rotation to apply (in degrees) to make the image upright.
7
+ */
5
8
  export declare class OrientationField extends BaseField {
6
9
  /** Degrees of the rotation. */
7
10
  value: number;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrientationField = void 0;
4
4
  const base_1 = require("./base");
5
+ /**
6
+ * The clockwise rotation to apply (in degrees) to make the image upright.
7
+ */
5
8
  class OrientationField extends base_1.BaseField {
6
9
  /**
7
10
  * @param {Object} prediction - Prediction object from HTTP response
@@ -10,6 +10,9 @@ interface PaymentDetailsConstructor {
10
10
  reconstructed?: boolean;
11
11
  pageId?: number;
12
12
  }
13
+ /**
14
+ * Information on a single payment.
15
+ */
13
16
  export declare class PaymentDetails extends Field {
14
17
  #private;
15
18
  /** Synonym for the `iban` property */
@@ -8,6 +8,9 @@ var _a, _PaymentDetails_isKeySet;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.PaymentDetails = void 0;
10
10
  const field_1 = require("./field");
11
+ /**
12
+ * Information on a single payment.
13
+ */
11
14
  class PaymentDetails extends field_1.Field {
12
15
  /**
13
16
  * @param {Object} prediction - Prediction object from HTTP response
@@ -5,6 +5,9 @@ export interface PositionFieldConstructor {
5
5
  valueKey?: string;
6
6
  pageId?: number | undefined;
7
7
  }
8
+ /**
9
+ * A field indicating a position or area on the document.
10
+ */
8
11
  export declare class PositionField {
9
12
  /** Straight rectangle. */
10
13
  boundingBox: Polygon;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PositionField = void 0;
4
+ /**
5
+ * A field indicating a position or area on the document.
6
+ */
4
7
  class PositionField {
5
8
  constructor({ prediction, pageId }) {
6
9
  this.pageId = pageId;
@@ -6,6 +6,9 @@ export interface FieldConstructor {
6
6
  reconstructed?: boolean;
7
7
  pageId?: number | undefined;
8
8
  }
9
+ /**
10
+ * A field containing a text value.
11
+ */
9
12
  export declare class TextField extends Field {
10
13
  /** The value. */
11
14
  value?: string;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TextField = void 0;
4
4
  const field_1 = require("./field");
5
+ /**
6
+ * A field containing a text value.
7
+ */
5
8
  class TextField extends field_1.Field {
6
9
  constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
7
10
  super({ prediction, valueKey, reconstructed, pageId });
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, InvoiceSplitterV1, PassportV1, ReceiptV3, ReceiptV4, ReceiptV5, CropperV1, ShippingContainerV1, MindeeVisionV1, ProofOfAddressV1, fr, us, eu, } from "./documents";
1
+ export { CustomV1, Document, FinancialDocumentV0, FinancialDocumentV1, InvoiceV3, InvoiceV4, InvoiceSplitterV1, PassportV1, ReceiptV3, ReceiptV4, ReceiptV5, CropperV1, MindeeVisionV1, ProofOfAddressV1, fr, us, eu, } from "./documents";
2
2
  export { Client, ClientOptions, CustomConfigParams, DocumentClient, PredictOptions, } from "./client";
3
3
  export { ResponseSig, Response, AsyncPredictResponse } from "./api";
4
4
  export { InputSource, PageOptionsOperation } from "./inputs";
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PageOptionsOperation = exports.InputSource = exports.AsyncPredictResponse = exports.Response = exports.DocumentClient = exports.Client = exports.eu = exports.us = exports.fr = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.ShippingContainerV1 = exports.CropperV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = exports.CustomV1 = void 0;
3
+ exports.PageOptionsOperation = exports.InputSource = exports.AsyncPredictResponse = exports.Response = exports.DocumentClient = exports.Client = exports.eu = exports.us = exports.fr = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.ReceiptV5 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.Document = 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, "Document", { enumerable: true, get: function () { return documents_1.Document; } });
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function ()
14
14
  Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return documents_1.ReceiptV4; } });
15
15
  Object.defineProperty(exports, "ReceiptV5", { enumerable: true, get: function () { return documents_1.ReceiptV5; } });
16
16
  Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return documents_1.CropperV1; } });
17
- Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return documents_1.ShippingContainerV1; } });
18
17
  Object.defineProperty(exports, "MindeeVisionV1", { enumerable: true, get: function () { return documents_1.MindeeVisionV1; } });
19
18
  Object.defineProperty(exports, "ProofOfAddressV1", { enumerable: true, get: function () { return documents_1.ProofOfAddressV1; } });
20
19
  Object.defineProperty(exports, "fr", { enumerable: true, get: function () { return documents_1.fr; } });
@@ -1,12 +0,0 @@
1
- import { Document, DocumentConstructorProps } from "../document";
2
- import { TextField } from "../../fields";
3
- export declare class ShippingContainerV1 extends Document {
4
- /** ISO 6346 code for container owner prefix + equipment identifier. */
5
- owner: TextField;
6
- /** ISO 6346 code for container serial number (6+1 digits). */
7
- serialNumber: TextField;
8
- /** ISO 6346 code for container length, height and type. */
9
- sizeType: TextField;
10
- constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
11
- toString(): string;
12
- }
@@ -1,38 +0,0 @@
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.TextField({
15
- prediction: prediction.owner,
16
- pageId: pageId,
17
- });
18
- this.serialNumber = new fields_1.TextField({
19
- prediction: prediction.serial_number,
20
- pageId: pageId,
21
- });
22
- this.sizeType = new fields_1.TextField({
23
- prediction: prediction.size_type,
24
- pageId: pageId,
25
- });
26
- }
27
- toString() {
28
- const outStr = `----- Shipping Container V1 -----
29
- Filename: ${this.filename}
30
- Owner: ${this.owner}
31
- Serial Number: ${this.serialNumber}
32
- Size and Type: ${this.sizeType}
33
- ----------------------
34
- `;
35
- return ShippingContainerV1.cleanOutString(outStr);
36
- }
37
- }
38
- exports.ShippingContainerV1 = ShippingContainerV1;