mindee 3.10.2 → 4.0.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 (265) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +103 -41
  3. package/package.json +6 -6
  4. package/src/cli.js +96 -70
  5. package/src/client.d.ts +34 -65
  6. package/src/client.js +108 -172
  7. package/src/geometry/boundingBox.d.ts +5 -0
  8. package/src/geometry/boundingBox.js +2 -0
  9. package/src/geometry/boundingBoxUtils.d.ts +22 -0
  10. package/src/geometry/boundingBoxUtils.js +66 -0
  11. package/src/geometry/index.d.ts +6 -0
  12. package/src/geometry/index.js +21 -0
  13. package/src/geometry/minMax.d.ts +4 -0
  14. package/src/geometry/minMax.js +2 -0
  15. package/src/geometry/point.d.ts +2 -0
  16. package/src/geometry/point.js +2 -0
  17. package/src/geometry/polygon.d.ts +4 -0
  18. package/src/geometry/polygon.js +7 -0
  19. package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
  20. package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
  21. package/src/http/endpoint.d.ts +44 -0
  22. package/src/http/endpoint.js +188 -0
  23. package/src/http/error.d.ts +2 -0
  24. package/src/http/error.js +9 -0
  25. package/src/http/index.d.ts +3 -0
  26. package/src/http/index.js +11 -0
  27. package/src/http/mindeeApi.d.ts +20 -0
  28. package/src/http/mindeeApi.js +73 -0
  29. package/src/index.d.ts +4 -4
  30. package/src/index.js +33 -26
  31. package/src/{inputs → input}/base.d.ts +4 -3
  32. package/src/{inputs → input}/base.js +9 -7
  33. package/src/{inputs → input}/index.d.ts +1 -1
  34. package/src/{inputs → input}/index.js +1 -2
  35. package/src/{inputs → input}/sources.d.ts +10 -11
  36. package/src/{inputs → input}/sources.js +9 -9
  37. package/src/parsing/common/apiRequest.d.ts +10 -0
  38. package/src/parsing/common/apiRequest.js +13 -0
  39. package/src/parsing/common/apiResponse.d.ts +6 -0
  40. package/src/parsing/common/apiResponse.js +10 -0
  41. package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
  42. package/src/parsing/common/asyncPredictResponse.js +39 -0
  43. package/src/parsing/common/document.d.ts +13 -0
  44. package/src/parsing/common/document.js +34 -0
  45. package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
  46. package/src/parsing/common/extras/cropperExtra.js +26 -0
  47. package/src/parsing/common/extras/extras.d.ts +11 -0
  48. package/src/parsing/common/extras/extras.js +18 -0
  49. package/src/parsing/common/index.d.ts +9 -0
  50. package/src/parsing/common/index.js +20 -0
  51. package/src/parsing/common/inference.d.ts +26 -0
  52. package/src/parsing/common/inference.js +56 -0
  53. package/src/parsing/common/mvisionV1.d.ts +8 -0
  54. package/src/parsing/common/mvisionV1.js +17 -0
  55. package/src/parsing/common/ocr.d.ts +8 -0
  56. package/src/parsing/common/ocr.js +13 -0
  57. package/src/parsing/common/ocrPage.d.ts +16 -0
  58. package/src/parsing/common/ocrPage.js +66 -0
  59. package/src/{fields → parsing/common}/orientation.d.ts +2 -2
  60. package/src/{fields → parsing/common}/orientation.js +4 -4
  61. package/src/parsing/common/page.d.ts +12 -0
  62. package/src/parsing/common/page.js +40 -0
  63. package/src/parsing/common/predictResponse.d.ts +6 -0
  64. package/src/parsing/common/predictResponse.js +12 -0
  65. package/src/parsing/common/prediction.d.ts +2 -0
  66. package/src/parsing/common/prediction.js +6 -0
  67. package/src/parsing/common/product.d.ts +4 -0
  68. package/src/parsing/common/product.js +2 -0
  69. package/src/parsing/common/stringDict.d.ts +3 -0
  70. package/src/parsing/common/stringDict.js +2 -0
  71. package/src/parsing/common/summaryHelper.d.ts +8 -0
  72. package/src/parsing/common/summaryHelper.js +22 -0
  73. package/src/parsing/custom/classificationField.d.ts +16 -0
  74. package/src/parsing/custom/classificationField.js +14 -0
  75. package/src/parsing/custom/index.d.ts +3 -0
  76. package/src/parsing/custom/index.js +12 -0
  77. package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
  78. package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
  79. package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
  80. package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
  81. package/src/parsing/index.d.ts +3 -0
  82. package/src/parsing/index.js +29 -0
  83. package/src/{fields → parsing/standard}/amount.d.ts +2 -2
  84. package/src/{fields → parsing/standard}/amount.js +5 -5
  85. package/src/{fields → parsing/standard}/base.d.ts +5 -5
  86. package/src/{fields → parsing/standard}/base.js +3 -2
  87. package/src/{fields → parsing/standard}/classification.d.ts +1 -1
  88. package/src/{fields → parsing/standard}/classification.js +3 -3
  89. package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
  90. package/src/parsing/standard/companyRegistration.js +14 -0
  91. package/src/{fields → parsing/standard}/date.d.ts +1 -1
  92. package/src/{fields → parsing/standard}/date.js +2 -2
  93. package/src/{fields → parsing/standard}/field.d.ts +3 -4
  94. package/src/{fields → parsing/standard}/field.js +6 -7
  95. package/src/parsing/standard/index.d.ts +12 -0
  96. package/src/parsing/standard/index.js +27 -0
  97. package/src/{fields → parsing/standard}/locale.d.ts +4 -4
  98. package/src/parsing/standard/locale.js +42 -0
  99. package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
  100. package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
  101. package/src/{fields → parsing/standard}/position.d.ts +2 -2
  102. package/src/{fields → parsing/standard}/position.js +5 -5
  103. package/src/{fields → parsing/standard}/tax.d.ts +3 -3
  104. package/src/{fields → parsing/standard}/tax.js +3 -3
  105. package/src/{fields → parsing/standard}/text.d.ts +2 -2
  106. package/src/{fields → parsing/standard}/text.js +4 -4
  107. package/src/parsing/standard/word.d.ts +10 -0
  108. package/src/parsing/standard/word.js +2 -0
  109. package/src/pdf/pdfOperation.d.ts +1 -1
  110. package/src/pdf/pdfOperation.js +3 -3
  111. package/src/product/cropper/cropperV1.d.ts +9 -0
  112. package/src/product/cropper/cropperV1.js +16 -0
  113. package/src/product/cropper/cropperV1Document.d.ts +8 -0
  114. package/src/product/cropper/cropperV1Document.js +26 -0
  115. package/src/product/custom/customV1.d.ts +10 -0
  116. package/src/product/custom/customV1.js +17 -0
  117. package/src/product/custom/customV1Document.d.ts +9 -0
  118. package/src/product/custom/customV1Document.js +43 -0
  119. package/src/product/custom/customV1Page.d.ts +7 -0
  120. package/src/product/custom/customV1Page.js +24 -0
  121. package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
  122. package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
  123. package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
  124. package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
  125. package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
  126. package/src/product/financialDocument/financialDocumentV1.js +16 -0
  127. package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
  128. package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
  129. package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
  130. package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
  131. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
  132. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
  133. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
  134. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
  135. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
  136. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
  137. package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
  138. package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
  139. package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
  140. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
  141. package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
  142. package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
  143. package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
  144. package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
  145. package/src/product/fr/idCard/idCardV1.d.ts +10 -0
  146. package/src/product/fr/idCard/idCardV1.js +17 -0
  147. package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
  148. package/src/product/fr/idCard/idCardV1Document.js +70 -0
  149. package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
  150. package/src/product/fr/idCard/idCardV1Page.js +23 -0
  151. package/src/{documents → product}/index.d.ts +2 -7
  152. package/src/{documents → product}/index.js +3 -14
  153. package/src/product/invoice/invoiceV4.d.ts +9 -0
  154. package/src/product/invoice/invoiceV4.js +16 -0
  155. package/src/product/invoice/invoiceV4Document.d.ts +44 -0
  156. package/src/product/invoice/invoiceV4Document.js +146 -0
  157. package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
  158. package/src/product/invoice/invoiceV4LineItem.js +101 -0
  159. package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
  160. package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
  161. package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
  162. package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
  163. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
  164. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
  165. package/src/product/passport/passportV1.d.ts +9 -0
  166. package/src/product/passport/passportV1.js +16 -0
  167. package/src/product/passport/passportV1Document.d.ts +31 -0
  168. package/src/product/passport/passportV1Document.js +75 -0
  169. package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
  170. package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
  171. package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
  172. package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
  173. package/src/product/receipt/receiptV4.d.ts +9 -0
  174. package/src/product/receipt/receiptV4.js +15 -0
  175. package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
  176. package/src/product/receipt/receiptV4Document.js +67 -0
  177. package/src/product/receipt/receiptV5.d.ts +9 -0
  178. package/src/product/receipt/receiptV5.js +16 -0
  179. package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
  180. package/src/product/receipt/receiptV5Document.js +108 -0
  181. package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
  182. package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
  183. package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
  184. package/src/product/us/bankCheck/bankCheckV1.js +17 -0
  185. package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
  186. package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
  187. package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
  188. package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
  189. package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
  190. package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
  191. package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
  192. package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
  193. package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
  194. package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
  195. package/src/product/us/index.d.ts +2 -0
  196. package/src/product/us/index.js +7 -0
  197. package/src/api/documentResponse.d.ts +0 -25
  198. package/src/api/documentResponse.js +0 -50
  199. package/src/api/endpoint.d.ts +0 -63
  200. package/src/api/endpoint.js +0 -216
  201. package/src/api/index.d.ts +0 -3
  202. package/src/api/index.js +0 -13
  203. package/src/api/predictResponse.d.ts +0 -33
  204. package/src/api/predictResponse.js +0 -52
  205. package/src/documents/cropper/cropperV1.d.ts +0 -7
  206. package/src/documents/cropper/cropperV1.js +0 -35
  207. package/src/documents/custom/customV1.d.ts +0 -10
  208. package/src/documents/custom/customV1.js +0 -53
  209. package/src/documents/document.d.ts +0 -47
  210. package/src/documents/document.js +0 -76
  211. package/src/documents/documentConfig.d.ts +0 -42
  212. package/src/documents/documentConfig.js +0 -118
  213. package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
  214. package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
  215. package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
  216. package/src/documents/financialDocument/financialDocumentV0.js +0 -140
  217. package/src/documents/financialDocument/financialDocumentV1.js +0 -197
  218. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
  219. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
  220. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
  221. package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
  222. package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
  223. package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
  224. package/src/documents/fr/idCard/idCardV1.js +0 -79
  225. package/src/documents/invoice/checks.d.ts +0 -5
  226. package/src/documents/invoice/checks.js +0 -87
  227. package/src/documents/invoice/invoiceLineItem.js +0 -66
  228. package/src/documents/invoice/invoiceV3.d.ts +0 -49
  229. package/src/documents/invoice/invoiceV3.js +0 -156
  230. package/src/documents/invoice/invoiceV4.d.ts +0 -45
  231. package/src/documents/invoice/invoiceV4.js +0 -166
  232. package/src/documents/invoice/reconstruction.d.ts +0 -6
  233. package/src/documents/invoice/reconstruction.js +0 -78
  234. package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
  235. package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
  236. package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
  237. package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
  238. package/src/documents/passport/passportV1.d.ts +0 -43
  239. package/src/documents/passport/passportV1.js +0 -220
  240. package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
  241. package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
  242. package/src/documents/receipt/receiptV3.d.ts +0 -25
  243. package/src/documents/receipt/receiptV3.js +0 -136
  244. package/src/documents/receipt/receiptV4.js +0 -78
  245. package/src/documents/receipt/receiptV5.js +0 -137
  246. package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
  247. package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
  248. package/src/documents/us/index.d.ts +0 -1
  249. package/src/documents/us/index.js +0 -5
  250. package/src/fields/companyRegistration.js +0 -14
  251. package/src/fields/fullText.d.ts +0 -27
  252. package/src/fields/fullText.js +0 -92
  253. package/src/fields/index.d.ts +0 -12
  254. package/src/fields/index.js +0 -28
  255. package/src/fields/locale.js +0 -45
  256. package/src/math/index.d.ts +0 -1
  257. package/src/math/index.js +0 -5
  258. package/src/math/precision.d.ts +0 -1
  259. package/src/math/precision.js +0 -13
  260. /package/src/{inputs → input}/pageOptions.d.ts +0 -0
  261. /package/src/{inputs → input}/pageOptions.js +0 -0
  262. /package/src/{documents → product}/eu/index.d.ts +0 -0
  263. /package/src/{documents → product}/eu/index.js +0 -0
  264. /package/src/{documents → product}/fr/index.d.ts +0 -0
  265. /package/src/{documents → product}/fr/index.js +0 -0
@@ -1,11 +1,10 @@
1
- import { Document, DocumentConstructorProps } from "../document";
2
- import { Amount, ClassificationField, CompanyRegistration, DateField, Locale, TaxField, TextField } from "../../fields";
1
+ import { Prediction, StringDict } from "../../parsing/common";
3
2
  import { ReceiptV5LineItem } from "./receiptV5LineItem";
3
+ import { AmountField, ClassificationField, CompanyRegistrationField, DateField, LocaleField, StringField, Taxes } from "../../parsing/standard";
4
4
  /**
5
- * Document data for Expense Receipt, API version 5.
5
+ * Document data for Receipt, API version 5.
6
6
  */
7
- export declare class ReceiptV5 extends Document {
8
- #private;
7
+ export declare class ReceiptV5Document implements Prediction {
9
8
  /** The purchase category among predefined classes. */
10
9
  category: ClassificationField;
11
10
  /** The date the purchase was made. */
@@ -15,29 +14,29 @@ export declare class ReceiptV5 extends Document {
15
14
  /** List of line item details. */
16
15
  lineItems: ReceiptV5LineItem[];
17
16
  /** The locale detected on the document. */
18
- locale: Locale;
17
+ locale: LocaleField;
19
18
  /** The purchase subcategory among predefined classes for transport and food. */
20
19
  subcategory: ClassificationField;
21
20
  /** The address of the supplier or merchant. */
22
- supplierAddress: TextField;
21
+ supplierAddress: StringField;
23
22
  /** List of company registrations associated to the supplier. */
24
- supplierCompanyRegistrations: CompanyRegistration[];
23
+ supplierCompanyRegistrations: CompanyRegistrationField[];
25
24
  /** The name of the supplier or merchant. */
26
- supplierName: TextField;
25
+ supplierName: StringField;
27
26
  /** The phone number of the supplier or merchant. */
28
- supplierPhoneNumber: TextField;
27
+ supplierPhoneNumber: StringField;
29
28
  /** List of tax lines information. */
30
- taxes: TaxField[];
29
+ taxes: Taxes;
31
30
  /** The time the purchase was made. */
32
- time: TextField;
31
+ time: StringField;
33
32
  /** The total amount of tip and gratuity. */
34
- tip: Amount;
33
+ tip: AmountField;
35
34
  /** The total amount paid: includes taxes, discounts, fees, tips, and gratuity. */
36
- totalAmount: Amount;
35
+ totalAmount: AmountField;
37
36
  /** The net amount paid: does not include taxes, fees, and discounts. */
38
- totalNet: Amount;
37
+ totalNet: AmountField;
39
38
  /** The total amount of taxes. */
40
- totalTax: Amount;
41
- constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
39
+ totalTax: AmountField;
40
+ constructor(rawPrediction: StringDict, pageId?: number);
42
41
  toString(): string;
43
42
  }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReceiptV5Document = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const receiptV5LineItem_1 = require("./receiptV5LineItem");
6
+ const standard_1 = require("../../parsing/standard");
7
+ /**
8
+ * Document data for Receipt, API version 5.
9
+ */
10
+ class ReceiptV5Document {
11
+ constructor(rawPrediction, pageId) {
12
+ /** List of line item details. */
13
+ this.lineItems = [];
14
+ /** List of company registrations associated to the supplier. */
15
+ this.supplierCompanyRegistrations = [];
16
+ this.category = new standard_1.ClassificationField({
17
+ prediction: rawPrediction["category"],
18
+ });
19
+ this.date = new standard_1.DateField({
20
+ prediction: rawPrediction["date"],
21
+ pageId: pageId,
22
+ });
23
+ this.documentType = new standard_1.ClassificationField({
24
+ prediction: rawPrediction["document_type"],
25
+ });
26
+ rawPrediction["line_items"] &&
27
+ rawPrediction["line_items"].map((itemPrediction) => this.lineItems.push(new receiptV5LineItem_1.ReceiptV5LineItem({
28
+ prediction: itemPrediction,
29
+ pageId: pageId,
30
+ })));
31
+ this.locale = new standard_1.LocaleField({
32
+ prediction: rawPrediction["locale"],
33
+ });
34
+ this.subcategory = new standard_1.ClassificationField({
35
+ prediction: rawPrediction["subcategory"],
36
+ });
37
+ this.supplierAddress = new standard_1.StringField({
38
+ prediction: rawPrediction["supplier_address"],
39
+ pageId: pageId,
40
+ });
41
+ rawPrediction["supplier_company_registrations"] &&
42
+ rawPrediction["supplier_company_registrations"].map((itemPrediction) => this.supplierCompanyRegistrations.push(new standard_1.CompanyRegistrationField({
43
+ prediction: itemPrediction,
44
+ pageId: pageId,
45
+ })));
46
+ this.supplierName = new standard_1.StringField({
47
+ prediction: rawPrediction["supplier_name"],
48
+ pageId: pageId,
49
+ });
50
+ this.supplierPhoneNumber = new standard_1.StringField({
51
+ prediction: rawPrediction["supplier_phone_number"],
52
+ pageId: pageId,
53
+ });
54
+ this.taxes = new standard_1.Taxes().init(rawPrediction["taxes"], pageId);
55
+ this.time = new standard_1.StringField({
56
+ prediction: rawPrediction["time"],
57
+ pageId: pageId,
58
+ });
59
+ this.tip = new standard_1.AmountField({
60
+ prediction: rawPrediction["tip"],
61
+ pageId: pageId,
62
+ });
63
+ this.totalAmount = new standard_1.AmountField({
64
+ prediction: rawPrediction["total_amount"],
65
+ pageId: pageId,
66
+ });
67
+ this.totalNet = new standard_1.AmountField({
68
+ prediction: rawPrediction["total_net"],
69
+ pageId: pageId,
70
+ });
71
+ this.totalTax = new standard_1.AmountField({
72
+ prediction: rawPrediction["total_tax"],
73
+ pageId: pageId,
74
+ });
75
+ }
76
+ toString() {
77
+ const supplierCompanyRegistrations = this.supplierCompanyRegistrations.join("\n ");
78
+ let lineItemsSummary = "";
79
+ if (this.lineItems && this.lineItems.length > 0) {
80
+ const lineItemsColSizes = [38, 10, 14, 12];
81
+ lineItemsSummary += "\n" + (0, common_1.lineSeparator)(lineItemsColSizes, "-") + "\n ";
82
+ lineItemsSummary += "| Description ";
83
+ lineItemsSummary += "| Quantity ";
84
+ lineItemsSummary += "| Total Amount ";
85
+ lineItemsSummary += "| Unit Price ";
86
+ lineItemsSummary += "|\n" + (0, common_1.lineSeparator)(lineItemsColSizes, "=");
87
+ lineItemsSummary += this.lineItems.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(lineItemsColSizes, "-")).join("");
88
+ }
89
+ const outStr = `:Expense Locale: ${this.locale}
90
+ :Purchase Category: ${this.category}
91
+ :Purchase Subcategory: ${this.subcategory}
92
+ :Document Type: ${this.documentType}
93
+ :Purchase Date: ${this.date}
94
+ :Purchase Time: ${this.time}
95
+ :Total Amount: ${this.totalAmount}
96
+ :Total Net: ${this.totalNet}
97
+ :Total Tax: ${this.totalTax}
98
+ :Tip and Gratuity: ${this.tip}
99
+ :Taxes: ${this.taxes}
100
+ :Supplier Name: ${this.supplierName}
101
+ :Supplier Company Registrations: ${supplierCompanyRegistrations}
102
+ :Supplier Address: ${this.supplierAddress}
103
+ :Supplier Phone Number: ${this.supplierPhoneNumber}
104
+ :Line Items: ${lineItemsSummary}`.trimEnd();
105
+ return (0, common_1.cleanOutString)(outStr);
106
+ }
107
+ }
108
+ exports.ReceiptV5Document = ReceiptV5Document;
@@ -1,4 +1,4 @@
1
- import { StringDict } from "../../fields";
1
+ import { StringDict } from "../../parsing/common";
2
2
  import { Polygon } from "../../geometry";
3
3
  /**
4
4
  * List of line item details.
@@ -6,13 +6,13 @@ import { Polygon } from "../../geometry";
6
6
  export declare class ReceiptV5LineItem {
7
7
  #private;
8
8
  /** The item description. */
9
- description: string | null;
9
+ description: string | undefined;
10
10
  /** The item quantity. */
11
- quantity: number | null;
11
+ quantity: number | undefined;
12
12
  /** The item total amount. */
13
- totalAmount: number | null;
13
+ totalAmount: number | undefined;
14
14
  /** The item unit price. */
15
- unitPrice: number | null;
15
+ unitPrice: number | undefined;
16
16
  /** Confidence score */
17
17
  confidence: number;
18
18
  /** The document page on which the information was found. */
@@ -7,12 +7,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var _ReceiptV5LineItem_instances, _ReceiptV5LineItem_printableValues;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ReceiptV5LineItem = void 0;
10
- const amount_1 = require("../../fields/amount");
10
+ const standard_1 = require("../../parsing/standard");
11
11
  /**
12
12
  * List of line item details.
13
13
  */
14
14
  class ReceiptV5LineItem {
15
- constructor({ prediction }) {
15
+ constructor({ prediction = {} }) {
16
16
  _ReceiptV5LineItem_instances.add(this);
17
17
  /** Confidence score */
18
18
  this.confidence = 0.0;
@@ -22,17 +22,14 @@ class ReceiptV5LineItem {
22
22
  */
23
23
  this.polygon = [];
24
24
  this.description = prediction["description"];
25
- this.quantity = +parseFloat(prediction["quantity"]).toFixed(3);
26
- if (isNaN(this.quantity)) {
27
- this.quantity = null;
25
+ if (prediction["quantity"] && !isNaN(prediction["quantity"])) {
26
+ this.quantity = +parseFloat(prediction["quantity"]).toFixed(3);
28
27
  }
29
- this.totalAmount = +parseFloat(prediction["total_amount"]).toFixed(3);
30
- if (isNaN(this.totalAmount)) {
31
- this.totalAmount = null;
28
+ if (prediction["total_amount"] && !isNaN(prediction["total_amount"])) {
29
+ this.totalAmount = +parseFloat(prediction["total_amount"]).toFixed(3);
32
30
  }
33
- this.unitPrice = +parseFloat(prediction["unit_price"]).toFixed(3);
34
- if (isNaN(this.unitPrice)) {
35
- this.unitPrice = null;
31
+ if (prediction["unit_price"] && !isNaN(prediction["unit_price"])) {
32
+ this.unitPrice = +parseFloat(prediction["unit_price"]).toFixed(3);
36
33
  }
37
34
  this.pageId = prediction["page_id"];
38
35
  this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
@@ -47,12 +44,12 @@ class ReceiptV5LineItem {
47
44
  const printable = __classPrivateFieldGet(this, _ReceiptV5LineItem_instances, "m", _ReceiptV5LineItem_printableValues).call(this);
48
45
  return ("Description: " +
49
46
  printable.description +
50
- "Quantity: " +
47
+ ", Quantity: " +
51
48
  printable.quantity +
52
- "Total Amount: " +
49
+ ", Total Amount: " +
53
50
  printable.totalAmount +
54
- "Unit Price: " +
55
- printable.unitPrice).trim();
51
+ ", Unit Price: " +
52
+ printable.unitPrice);
56
53
  }
57
54
  /**
58
55
  * Output in a format suitable for inclusion in an rST table.
@@ -73,9 +70,13 @@ class ReceiptV5LineItem {
73
70
  exports.ReceiptV5LineItem = ReceiptV5LineItem;
74
71
  _ReceiptV5LineItem_instances = new WeakSet(), _ReceiptV5LineItem_printableValues = function _ReceiptV5LineItem_printableValues() {
75
72
  return {
76
- description: this.description ?? "",
77
- quantity: this.quantity !== null ? (0, amount_1.floatToString)(this.quantity) : "",
78
- totalAmount: this.totalAmount !== null ? (0, amount_1.floatToString)(this.totalAmount) : "",
79
- unitPrice: this.unitPrice !== null ? (0, amount_1.floatToString)(this.unitPrice) : "",
73
+ description: this.description ?
74
+ this.description.length <= 36 ?
75
+ this.description :
76
+ this.description.slice(0, 33) + "..." :
77
+ "",
78
+ quantity: this.quantity !== undefined ? (0, standard_1.floatToString)(this.quantity) : "",
79
+ totalAmount: this.totalAmount !== undefined ? (0, standard_1.floatToString)(this.totalAmount) : "",
80
+ unitPrice: this.unitPrice !== undefined ? (0, standard_1.floatToString)(this.unitPrice) : "",
80
81
  };
81
82
  };
@@ -0,0 +1,10 @@
1
+ import { Inference, StringDict, Page } from "../../../parsing/common";
2
+ import { BankCheckV1Document } from "./bankCheckV1Document";
3
+ import { BankCheckV1Page } from "./bankCheckV1Page";
4
+ export declare class BankCheckV1 extends Inference {
5
+ endpointName: string;
6
+ endpointVersion: string;
7
+ prediction: BankCheckV1Document;
8
+ pages: Page<BankCheckV1Page>[];
9
+ constructor(rawPrediction: StringDict);
10
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BankCheckV1 = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const bankCheckV1Document_1 = require("./bankCheckV1Document");
6
+ const bankCheckV1Page_1 = require("./bankCheckV1Page");
7
+ class BankCheckV1 extends common_1.Inference {
8
+ constructor(rawPrediction) {
9
+ super(rawPrediction);
10
+ this.endpointName = "bank_check";
11
+ this.endpointVersion = "1";
12
+ this.pages = [];
13
+ this.prediction = new bankCheckV1Document_1.BankCheckV1Document(rawPrediction["prediction"]);
14
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(bankCheckV1Page_1.BankCheckV1Page, page, page["id"], page["orientation"]));
15
+ }
16
+ }
17
+ exports.BankCheckV1 = BankCheckV1;
@@ -0,0 +1,21 @@
1
+ import { Prediction, StringDict } from "../../../parsing/common";
2
+ import { AmountField, DateField, StringField } from "../../../parsing/standard";
3
+ /**
4
+ * Document data for Bank Check, API version 1.
5
+ */
6
+ export declare class BankCheckV1Document implements Prediction {
7
+ /** The check payer's account number. */
8
+ accountNumber: StringField;
9
+ /** The amount of the check. */
10
+ amount: AmountField;
11
+ /** The issuer's check number. */
12
+ checkNumber: StringField;
13
+ /** The date the check was issued. */
14
+ date: DateField;
15
+ /** List of the check's payees (recipients). */
16
+ payees: StringField[];
17
+ /** The check issuer's routing number. */
18
+ routingNumber: StringField;
19
+ constructor(rawPrediction: StringDict, pageId?: number);
20
+ toString(): string;
21
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BankCheckV1Document = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const standard_1 = require("../../../parsing/standard");
6
+ /**
7
+ * Document data for Bank Check, API version 1.
8
+ */
9
+ class BankCheckV1Document {
10
+ constructor(rawPrediction, pageId) {
11
+ /** List of the check's payees (recipients). */
12
+ this.payees = [];
13
+ this.accountNumber = new standard_1.StringField({
14
+ prediction: rawPrediction["account_number"],
15
+ pageId: pageId,
16
+ });
17
+ this.amount = new standard_1.AmountField({
18
+ prediction: rawPrediction["amount"],
19
+ pageId: pageId,
20
+ });
21
+ this.checkNumber = new standard_1.StringField({
22
+ prediction: rawPrediction["check_number"],
23
+ pageId: pageId,
24
+ });
25
+ this.date = new standard_1.DateField({
26
+ prediction: rawPrediction["date"],
27
+ pageId: pageId,
28
+ });
29
+ rawPrediction["payees"] &&
30
+ rawPrediction["payees"].map((itemPrediction) => this.payees.push(new standard_1.StringField({
31
+ prediction: itemPrediction,
32
+ pageId: pageId,
33
+ })));
34
+ this.routingNumber = new standard_1.StringField({
35
+ prediction: rawPrediction["routing_number"],
36
+ pageId: pageId,
37
+ });
38
+ }
39
+ toString() {
40
+ const payees = this.payees.join("\n ");
41
+ const outStr = `:Check Issue Date: ${this.date}
42
+ :Amount: ${this.amount}
43
+ :Payees: ${payees}
44
+ :Routing Number: ${this.routingNumber}
45
+ :Account Number: ${this.accountNumber}
46
+ :Check Number: ${this.checkNumber}`.trimEnd();
47
+ return (0, common_1.cleanOutString)(outStr);
48
+ }
49
+ }
50
+ exports.BankCheckV1Document = BankCheckV1Document;
@@ -0,0 +1,14 @@
1
+ import { StringDict } from "../../../parsing/common";
2
+ import { PositionField } from "../../../parsing/standard";
3
+ import { BankCheckV1Document } from "./bankCheckV1Document";
4
+ /**
5
+ * Page data for Bank Check, API version 1.
6
+ */
7
+ export declare class BankCheckV1Page extends BankCheckV1Document {
8
+ /** The position of the check on the document. */
9
+ checkPosition: PositionField;
10
+ /** List of signature positions */
11
+ signaturesPositions: PositionField[];
12
+ constructor(rawPrediction: StringDict, pageId?: number);
13
+ toString(): string;
14
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BankCheckV1Page = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const standard_1 = require("../../../parsing/standard");
6
+ const bankCheckV1Document_1 = require("./bankCheckV1Document");
7
+ /**
8
+ * Page data for Bank Check, API version 1.
9
+ */
10
+ class BankCheckV1Page extends bankCheckV1Document_1.BankCheckV1Document {
11
+ constructor(rawPrediction, pageId) {
12
+ super(rawPrediction, pageId);
13
+ /** List of signature positions */
14
+ this.signaturesPositions = [];
15
+ this.checkPosition = new standard_1.PositionField({
16
+ prediction: rawPrediction["check_position"],
17
+ pageId: pageId,
18
+ });
19
+ rawPrediction["signatures_positions"].map((itemPrediction) => this.signaturesPositions.push(new standard_1.PositionField({
20
+ prediction: itemPrediction,
21
+ pageId: pageId,
22
+ })));
23
+ }
24
+ toString() {
25
+ const signaturesPositions = this.signaturesPositions.join("\n ");
26
+ let outStr = `:Check Position: ${this.checkPosition}
27
+ :Signature Positions: ${signaturesPositions}`.trimEnd();
28
+ outStr += "\n" + super.toString();
29
+ return (0, common_1.cleanOutString)(outStr);
30
+ }
31
+ }
32
+ exports.BankCheckV1Page = BankCheckV1Page;
@@ -0,0 +1,10 @@
1
+ import { Inference, StringDict, Page } from "../../../parsing/common";
2
+ import { DriverLicenseV1Document } from "./driverLicenseV1Document";
3
+ import { DriverLicenseV1Page } from "./driverLicenseV1Page";
4
+ export declare class DriverLicenseV1 extends Inference {
5
+ endpointName: string;
6
+ endpointVersion: string;
7
+ prediction: DriverLicenseV1Document;
8
+ pages: Page<DriverLicenseV1Page>[];
9
+ constructor(rawPrediction: StringDict);
10
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DriverLicenseV1 = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const driverLicenseV1Document_1 = require("./driverLicenseV1Document");
6
+ const driverLicenseV1Page_1 = require("./driverLicenseV1Page");
7
+ class DriverLicenseV1 extends common_1.Inference {
8
+ constructor(rawPrediction) {
9
+ super(rawPrediction);
10
+ this.endpointName = "us_driver_license";
11
+ this.endpointVersion = "1";
12
+ this.pages = [];
13
+ this.prediction = new driverLicenseV1Document_1.DriverLicenseV1Document(rawPrediction["prediction"]);
14
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(driverLicenseV1Page_1.DriverLicenseV1Page, page, page["id"], page["orientation"]));
15
+ }
16
+ }
17
+ exports.DriverLicenseV1 = DriverLicenseV1;
@@ -0,0 +1,43 @@
1
+ import { Prediction, StringDict } from "../../../parsing/common";
2
+ import { DateField, StringField } from "../../../parsing/standard";
3
+ /**
4
+ * Document data for Driver License, API version 1.
5
+ */
6
+ export declare class DriverLicenseV1Document implements Prediction {
7
+ /** US driver license holders address */
8
+ address: StringField;
9
+ /** US driver license holders date of birth */
10
+ dateOfBirth: DateField;
11
+ /** Document Discriminator Number of the US Driver License */
12
+ ddNumber: StringField;
13
+ /** US driver license holders class */
14
+ dlClass: StringField;
15
+ /** ID number of the US Driver License. */
16
+ driverLicenseId: StringField;
17
+ /** US driver license holders endorsements */
18
+ endorsements: StringField;
19
+ /** Date on which the documents expires. */
20
+ expiryDate: DateField;
21
+ /** US driver license holders eye colour */
22
+ eyeColor: StringField;
23
+ /** US driver license holders first name(s) */
24
+ firstName: StringField;
25
+ /** US driver license holders hair colour */
26
+ hairColor: StringField;
27
+ /** US driver license holders hight */
28
+ height: StringField;
29
+ /** Date on which the documents was issued. */
30
+ issuedDate: DateField;
31
+ /** US driver license holders last name */
32
+ lastName: StringField;
33
+ /** US driver license holders restrictions */
34
+ restrictions: StringField;
35
+ /** US driver license holders gender */
36
+ sex: StringField;
37
+ /** US State */
38
+ state: StringField;
39
+ /** US driver license holders weight */
40
+ weight: StringField;
41
+ constructor(rawPrediction: StringDict, pageId?: number);
42
+ toString(): string;
43
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DriverLicenseV1Document = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const standard_1 = require("../../../parsing/standard");
6
+ /**
7
+ * Document data for Driver License, API version 1.
8
+ */
9
+ class DriverLicenseV1Document {
10
+ constructor(rawPrediction, pageId) {
11
+ this.address = new standard_1.StringField({
12
+ prediction: rawPrediction["address"],
13
+ pageId: pageId,
14
+ });
15
+ this.dateOfBirth = new standard_1.DateField({
16
+ prediction: rawPrediction["date_of_birth"],
17
+ pageId: pageId,
18
+ });
19
+ this.ddNumber = new standard_1.StringField({
20
+ prediction: rawPrediction["dd_number"],
21
+ pageId: pageId,
22
+ });
23
+ this.dlClass = new standard_1.StringField({
24
+ prediction: rawPrediction["dl_class"],
25
+ pageId: pageId,
26
+ });
27
+ this.driverLicenseId = new standard_1.StringField({
28
+ prediction: rawPrediction["driver_license_id"],
29
+ pageId: pageId,
30
+ });
31
+ this.endorsements = new standard_1.StringField({
32
+ prediction: rawPrediction["endorsements"],
33
+ pageId: pageId,
34
+ });
35
+ this.expiryDate = new standard_1.DateField({
36
+ prediction: rawPrediction["expiry_date"],
37
+ pageId: pageId,
38
+ });
39
+ this.eyeColor = new standard_1.StringField({
40
+ prediction: rawPrediction["eye_color"],
41
+ pageId: pageId,
42
+ });
43
+ this.firstName = new standard_1.StringField({
44
+ prediction: rawPrediction["first_name"],
45
+ pageId: pageId,
46
+ });
47
+ this.hairColor = new standard_1.StringField({
48
+ prediction: rawPrediction["hair_color"],
49
+ pageId: pageId,
50
+ });
51
+ this.height = new standard_1.StringField({
52
+ prediction: rawPrediction["height"],
53
+ pageId: pageId,
54
+ });
55
+ this.issuedDate = new standard_1.DateField({
56
+ prediction: rawPrediction["issued_date"],
57
+ pageId: pageId,
58
+ });
59
+ this.lastName = new standard_1.StringField({
60
+ prediction: rawPrediction["last_name"],
61
+ pageId: pageId,
62
+ });
63
+ this.restrictions = new standard_1.StringField({
64
+ prediction: rawPrediction["restrictions"],
65
+ pageId: pageId,
66
+ });
67
+ this.sex = new standard_1.StringField({
68
+ prediction: rawPrediction["sex"],
69
+ pageId: pageId,
70
+ });
71
+ this.state = new standard_1.StringField({
72
+ prediction: rawPrediction["state"],
73
+ pageId: pageId,
74
+ });
75
+ this.weight = new standard_1.StringField({
76
+ prediction: rawPrediction["weight"],
77
+ pageId: pageId,
78
+ });
79
+ }
80
+ toString() {
81
+ const outStr = `:State: ${this.state}
82
+ :Driver License ID: ${this.driverLicenseId}
83
+ :Expiry Date: ${this.expiryDate}
84
+ :Date Of Issue: ${this.issuedDate}
85
+ :Last Name: ${this.lastName}
86
+ :First Name: ${this.firstName}
87
+ :Address: ${this.address}
88
+ :Date Of Birth: ${this.dateOfBirth}
89
+ :Restrictions: ${this.restrictions}
90
+ :Endorsements: ${this.endorsements}
91
+ :Driver License Class: ${this.dlClass}
92
+ :Sex: ${this.sex}
93
+ :Height: ${this.height}
94
+ :Weight: ${this.weight}
95
+ :Hair Color: ${this.hairColor}
96
+ :Eye Color: ${this.eyeColor}
97
+ :Document Discriminator: ${this.ddNumber}`.trimEnd();
98
+ return (0, common_1.cleanOutString)(outStr);
99
+ }
100
+ }
101
+ exports.DriverLicenseV1Document = DriverLicenseV1Document;
@@ -0,0 +1,14 @@
1
+ import { StringDict } from "../../../parsing/common";
2
+ import { PositionField } from "../../../parsing/standard";
3
+ import { DriverLicenseV1Document } from "./driverLicenseV1Document";
4
+ /**
5
+ * Page data for Driver License, API version 1.
6
+ */
7
+ export declare class DriverLicenseV1Page extends DriverLicenseV1Document {
8
+ /** Has a photo of the US driver license holder */
9
+ photo: PositionField;
10
+ /** Has a signature of the US driver license holder */
11
+ signature: PositionField;
12
+ constructor(rawPrediction: StringDict, pageId?: number);
13
+ toString(): string;
14
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DriverLicenseV1Page = void 0;
4
+ const common_1 = require("../../../parsing/common");
5
+ const standard_1 = require("../../../parsing/standard");
6
+ const driverLicenseV1Document_1 = require("./driverLicenseV1Document");
7
+ /**
8
+ * Page data for Driver License, API version 1.
9
+ */
10
+ class DriverLicenseV1Page extends driverLicenseV1Document_1.DriverLicenseV1Document {
11
+ constructor(rawPrediction, pageId) {
12
+ super(rawPrediction, pageId);
13
+ this.photo = new standard_1.PositionField({
14
+ prediction: rawPrediction["photo"],
15
+ pageId: pageId,
16
+ });
17
+ this.signature = new standard_1.PositionField({
18
+ prediction: rawPrediction["signature"],
19
+ pageId: pageId,
20
+ });
21
+ }
22
+ toString() {
23
+ let outStr = `:Photo: ${this.photo}
24
+ :Signature: ${this.signature}`.trimEnd();
25
+ outStr += "\n" + super.toString();
26
+ return (0, common_1.cleanOutString)(outStr);
27
+ }
28
+ }
29
+ exports.DriverLicenseV1Page = DriverLicenseV1Page;
@@ -0,0 +1,2 @@
1
+ export { BankCheckV1 } from "./bankCheck/bankCheckV1";
2
+ export { DriverLicenseV1 } from "./driverLicense/driverLicenseV1";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DriverLicenseV1 = exports.BankCheckV1 = void 0;
4
+ var bankCheckV1_1 = require("./bankCheck/bankCheckV1");
5
+ Object.defineProperty(exports, "BankCheckV1", { enumerable: true, get: function () { return bankCheckV1_1.BankCheckV1; } });
6
+ var driverLicenseV1_1 = require("./driverLicense/driverLicenseV1");
7
+ Object.defineProperty(exports, "DriverLicenseV1", { enumerable: true, get: function () { return driverLicenseV1_1.DriverLicenseV1; } });