mindee 3.10.2 → 4.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 (265) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +103 -41
  3. package/package.json +4 -5
  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,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProofOfAddressV1 = void 0;
4
- const document_1 = require("../document");
5
- const fields_1 = require("../../fields");
6
- class ProofOfAddressV1 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
- /** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */
15
- this.dates = [];
16
- /** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
17
- this.issuerCompanyRegistration = [];
18
- /** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
19
- this.recipientCompanyRegistration = [];
20
- this.locale = new fields_1.Locale({
21
- prediction: prediction.locale,
22
- });
23
- this.date = new fields_1.DateField({
24
- prediction: prediction.date,
25
- pageId: pageId,
26
- });
27
- prediction.dates.map((prediction) => this.dates.push(new fields_1.DateField({
28
- prediction: prediction,
29
- pageId: pageId,
30
- })));
31
- this.issuerAddress = new fields_1.TextField({
32
- prediction: prediction.issuer_address,
33
- pageId: pageId,
34
- });
35
- prediction.issuer_company_registration.map((prediction) => this.issuerCompanyRegistration.push(new fields_1.CompanyRegistration({
36
- prediction: prediction,
37
- pageId: pageId,
38
- })));
39
- this.issuerName = new fields_1.TextField({
40
- prediction: prediction.issuer_name,
41
- pageId: pageId,
42
- });
43
- prediction.recipient_company_registration.map((prediction) => this.recipientCompanyRegistration.push(new fields_1.CompanyRegistration({
44
- prediction: prediction,
45
- pageId: pageId,
46
- })));
47
- this.recipientAddress = new fields_1.TextField({
48
- prediction: prediction.recipient_address,
49
- pageId: pageId,
50
- });
51
- this.recipientName = new fields_1.TextField({
52
- prediction: prediction.recipient_name,
53
- pageId: pageId,
54
- });
55
- }
56
- toString() {
57
- const outStr = `----- Proof of Address V1 -----
58
- Filename: ${this.filename}
59
- Locale: ${this.locale}
60
- Issuer Name: ${this.issuerName}
61
- Issuer Company Registrations: ${this.issuerCompanyRegistration
62
- .map((icr) => icr.value)
63
- .join(", ")}
64
- Issuer Address: ${this.issuerAddress}
65
- Recipient Name: ${this.recipientName}
66
- Recipient Company Registrations: ${this.recipientCompanyRegistration
67
- .map((rcr) => rcr.value)
68
- .join(", ")}
69
- Recipient Address: ${this.recipientAddress}
70
- Dates: ${this.dates.map((rcr) => rcr.value).join("\n ")}
71
- Date of Issue: ${this.date}
72
- ----------------------
73
- `;
74
- return ProofOfAddressV1.cleanOutString(outStr);
75
- }
76
- }
77
- exports.ProofOfAddressV1 = ProofOfAddressV1;
@@ -1,25 +0,0 @@
1
- import { Document, DocumentConstructorProps } from "../document";
2
- import { ClassificationField, TaxField, TextField, Amount, Locale, DateField } from "../../fields";
3
- export declare class ReceiptV3 extends Document {
4
- #private;
5
- /** Total amount with the tax amount of the purchase. */
6
- locale: Locale;
7
- /** Where the purchase was made, the language, and the currency. */
8
- totalIncl: Amount;
9
- /** The purchase date. */
10
- date: DateField;
11
- /** The type of purchase. */
12
- category: ClassificationField;
13
- /** Merchant's name as seen on the receipt. */
14
- merchantName: TextField;
15
- /** Time as seen on the receipt in HH:MM format. */
16
- time: TextField;
17
- /** Total tax amount of the purchase. */
18
- totalTax: Amount;
19
- /** Total amount without tax of the purchase. */
20
- totalExcl: Amount;
21
- /** List of different taxes. */
22
- taxes: TaxField[];
23
- constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
24
- toString(): string;
25
- }
@@ -1,136 +0,0 @@
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 _ReceiptV3_instances, _ReceiptV3_checklist, _ReceiptV3_taxesMatchTotal, _ReceiptV3_reconstruct, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes, _ReceiptV3_reconstructTotalTax;
8
- Object.defineProperty(exports, "__esModule", { value: true });
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);
22
- this.locale = new fields_1.Locale({
23
- prediction: prediction.locale,
24
- });
25
- this.totalTax = new fields_1.Amount({
26
- prediction: { value: undefined, confidence: 0 },
27
- pageId: pageId,
28
- });
29
- this.totalExcl = new fields_1.Amount({
30
- prediction: { value: undefined, confidence: 0 },
31
- pageId: pageId,
32
- });
33
- this.totalIncl = new fields_1.Amount({
34
- prediction: prediction.total_incl,
35
- pageId: pageId,
36
- });
37
- this.date = new fields_1.DateField({
38
- prediction: prediction.date,
39
- pageId: pageId,
40
- });
41
- this.category = new fields_1.ClassificationField({
42
- prediction: prediction.category,
43
- });
44
- this.merchantName = new fields_1.TextField({
45
- prediction: prediction.supplier,
46
- pageId: pageId,
47
- });
48
- this.time = new fields_1.TextField({
49
- prediction: prediction.time,
50
- pageId: pageId,
51
- });
52
- this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
53
- __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_checklist).call(this);
54
- __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstruct).call(this);
55
- }
56
- toString() {
57
- const outStr = `Receipt V3 Prediction
58
- =====================
59
- :Filename: ${this.filename}
60
- :Total amount: ${this.totalIncl}
61
- :Total net: ${this.totalExcl}
62
- :Date: ${this.date}
63
- :Category: ${this.category}
64
- :Time: ${this.time}
65
- :Merchant name: ${this.merchantName}
66
- :Taxes: ${this.taxes}
67
- :Total tax: ${this.totalTax}
68
- :Locale: ${this.locale}
69
- `;
70
- return ReceiptV3.cleanOutString(outStr);
71
- }
72
- }
73
- exports.ReceiptV3 = ReceiptV3;
74
- _ReceiptV3_instances = new WeakSet(), _ReceiptV3_checklist = function _ReceiptV3_checklist() {
75
- this.checklist = { taxesMatchTotalIncl: __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_taxesMatchTotal).call(this) };
76
- }, _ReceiptV3_taxesMatchTotal = function _ReceiptV3_taxesMatchTotal() {
77
- // Check taxes and total amount exist
78
- if (this.taxes.length === 0 || this.totalIncl.value === undefined) {
79
- return false;
80
- }
81
- // Reconstruct total_incl from taxes
82
- let totalVat = 0;
83
- let reconstructedTotal = 0;
84
- this.taxes.forEach((tax) => {
85
- if (tax.value === undefined || !tax.rate)
86
- return false;
87
- totalVat += tax.value;
88
- reconstructedTotal += tax.value + (100 * tax.value) / tax.rate;
89
- });
90
- // Sanity check
91
- if (totalVat <= 0)
92
- return false;
93
- // Crate epsilon
94
- const eps = 1 / (100 * totalVat);
95
- if (this.totalIncl.value * (1 - eps) - 0.02 <= reconstructedTotal &&
96
- reconstructedTotal <= this.totalIncl.value * (1 + eps) + 0.02) {
97
- this.taxes.forEach((tax) => {
98
- tax.confidence = 1.0;
99
- });
100
- this.totalTax.confidence = 1.0;
101
- this.totalIncl.confidence = 1.0;
102
- return true;
103
- }
104
- return false;
105
- }, _ReceiptV3_reconstruct = function _ReceiptV3_reconstruct() {
106
- __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstructTotalExclFromTCCAndTaxes).call(this);
107
- __classPrivateFieldGet(this, _ReceiptV3_instances, "m", _ReceiptV3_reconstructTotalTax).call(this);
108
- }, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes = function _ReceiptV3_reconstructTotalExclFromTCCAndTaxes() {
109
- if (this.taxes.length && this.totalIncl.value !== undefined) {
110
- const totalExcl = {
111
- value: this.totalIncl.value - fields_1.TextField.arraySum(this.taxes),
112
- confidence: fields_1.TextField.arrayConfidence(this.taxes) *
113
- this.totalIncl.confidence,
114
- };
115
- this.totalExcl = new fields_1.Amount({
116
- prediction: totalExcl,
117
- valueKey: "value",
118
- reconstructed: true,
119
- });
120
- }
121
- }, _ReceiptV3_reconstructTotalTax = function _ReceiptV3_reconstructTotalTax() {
122
- if (this.taxes.length && this.totalTax.value === undefined) {
123
- const totalTax = {
124
- value: this.taxes
125
- .map((tax) => tax.value || 0)
126
- .reduce((a, b) => a + b, 0),
127
- confidence: fields_1.TextField.arrayConfidence(this.taxes),
128
- };
129
- if (totalTax.value > 0)
130
- this.totalTax = new fields_1.Amount({
131
- prediction: totalTax,
132
- valueKey: "value",
133
- reconstructed: true,
134
- });
135
- }
136
- };
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReceiptV4 = void 0;
4
- const document_1 = require("../document");
5
- const fields_1 = require("../../fields");
6
- class ReceiptV4 extends document_1.Document {
7
- constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
8
- super({
9
- inputSource: inputSource,
10
- pageId: pageId,
11
- orientation: orientation,
12
- extras: extras,
13
- fullText: fullText,
14
- });
15
- this.locale = new fields_1.Locale({
16
- prediction: prediction.locale,
17
- });
18
- this.totalTax = new fields_1.Amount({
19
- prediction: prediction.total_tax,
20
- pageId: pageId,
21
- });
22
- this.totalAmount = new fields_1.Amount({
23
- prediction: prediction.total_amount,
24
- pageId: pageId,
25
- });
26
- this.totalNet = new fields_1.Amount({
27
- prediction: prediction.total_net,
28
- pageId: pageId,
29
- });
30
- this.tip = new fields_1.Amount({
31
- prediction: prediction.tip,
32
- pageId: pageId,
33
- });
34
- this.date = new fields_1.DateField({
35
- prediction: prediction.date,
36
- pageId: pageId,
37
- });
38
- this.category = new fields_1.ClassificationField({
39
- prediction: prediction.category,
40
- });
41
- this.subCategory = new fields_1.ClassificationField({
42
- prediction: prediction.subcategory,
43
- });
44
- this.documentType = new fields_1.TextField({
45
- prediction: prediction.document_type,
46
- pageId: pageId,
47
- });
48
- this.supplier = new fields_1.TextField({
49
- prediction: prediction.supplier,
50
- pageId: pageId,
51
- });
52
- this.time = new fields_1.TextField({
53
- prediction: prediction.time,
54
- pageId: pageId,
55
- });
56
- this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
57
- }
58
- toString() {
59
- const outStr = `Receipt V4 Prediction
60
- =====================
61
- :Filename: ${this.filename}
62
- :Total amount: ${this.totalAmount}
63
- :Total net: ${this.totalNet}
64
- :Tip: ${this.tip}
65
- :Date: ${this.date}
66
- :Category: ${this.category}
67
- :Subcategory: ${this.subCategory}
68
- :Document type: ${this.documentType}
69
- :Time: ${this.time}
70
- :Supplier name: ${this.supplier}
71
- :Taxes: ${this.taxes}
72
- :Total tax: ${this.totalTax}
73
- :Locale: ${this.locale}
74
- `;
75
- return ReceiptV4.cleanOutString(outStr);
76
- }
77
- }
78
- exports.ReceiptV4 = ReceiptV4;
@@ -1,137 +0,0 @@
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 _ReceiptV5_instances, _ReceiptV5_lineItemsSeparator, _ReceiptV5_lineItemsToString;
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ReceiptV5 = void 0;
10
- const document_1 = require("../document");
11
- const fields_1 = require("../../fields");
12
- const receiptV5LineItem_1 = require("./receiptV5LineItem");
13
- /**
14
- * Document data for Expense Receipt, API version 5.
15
- */
16
- class ReceiptV5 extends document_1.Document {
17
- constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
18
- super({
19
- inputSource: inputSource,
20
- pageId: pageId,
21
- orientation: orientation,
22
- extras: extras,
23
- fullText: fullText,
24
- });
25
- _ReceiptV5_instances.add(this);
26
- /** List of line item details. */
27
- this.lineItems = [];
28
- /** List of company registrations associated to the supplier. */
29
- this.supplierCompanyRegistrations = [];
30
- this.category = new fields_1.ClassificationField({
31
- prediction: prediction["category"],
32
- });
33
- this.date = new fields_1.DateField({
34
- prediction: prediction["date"],
35
- pageId: pageId,
36
- });
37
- this.documentType = new fields_1.ClassificationField({
38
- prediction: prediction["document_type"],
39
- });
40
- prediction["line_items"].map((itemPrediction) => this.lineItems.push(new receiptV5LineItem_1.ReceiptV5LineItem({
41
- prediction: itemPrediction,
42
- pageId: pageId,
43
- })));
44
- this.locale = new fields_1.Locale({
45
- prediction: prediction["locale"],
46
- });
47
- this.subcategory = new fields_1.ClassificationField({
48
- prediction: prediction["subcategory"],
49
- });
50
- this.supplierAddress = new fields_1.TextField({
51
- prediction: prediction["supplier_address"],
52
- pageId: pageId,
53
- });
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"],
60
- pageId: pageId,
61
- });
62
- this.supplierPhoneNumber = new fields_1.TextField({
63
- prediction: prediction["supplier_phone_number"],
64
- pageId: pageId,
65
- });
66
- this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
67
- this.time = new fields_1.TextField({
68
- prediction: prediction["time"],
69
- pageId: pageId,
70
- });
71
- this.tip = new fields_1.Amount({
72
- prediction: prediction["tip"],
73
- pageId: pageId,
74
- });
75
- this.totalAmount = new fields_1.Amount({
76
- prediction: prediction["total_amount"],
77
- pageId: pageId,
78
- });
79
- this.totalNet = new fields_1.Amount({
80
- prediction: prediction["total_net"],
81
- pageId: pageId,
82
- });
83
- this.totalTax = new fields_1.Amount({
84
- prediction: prediction["total_tax"],
85
- pageId: pageId,
86
- });
87
- }
88
- toString() {
89
- const outStr = `Receipt V5 Prediction
90
- =====================
91
- :Filename: ${this.filename}
92
- :Expense Locale: ${this.locale}
93
- :Purchase Category: ${this.category}
94
- :Purchase Subcategory: ${this.subcategory}
95
- :Document Type: ${this.documentType}
96
- :Purchase Date: ${this.date}
97
- :Purchase Time: ${this.time}
98
- :Total Amount: ${this.totalAmount}
99
- :Total Net: ${this.totalNet}
100
- :Total Tax: ${this.totalTax}
101
- :Tip and Gratuity: ${this.tip}
102
- :Taxes: ${this.taxes}
103
- :Supplier Name: ${this.supplierName}
104
- :Supplier Company Registrations: ${this.supplierCompanyRegistrations.join(`${" ".repeat(32)}`)}
105
- :Supplier Address: ${this.supplierAddress}
106
- :Supplier Phone Number: ${this.supplierPhoneNumber}
107
- :Line Items: ${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsToString).call(this)}
108
- `;
109
- return ReceiptV5.cleanOutString(outStr);
110
- }
111
- }
112
- exports.ReceiptV5 = ReceiptV5;
113
- _ReceiptV5_instances = new WeakSet(), _ReceiptV5_lineItemsSeparator = function _ReceiptV5_lineItemsSeparator(char) {
114
- let outStr = " ";
115
- outStr += `+${char.repeat(38)}`;
116
- outStr += `+${char.repeat(10)}`;
117
- outStr += `+${char.repeat(14)}`;
118
- outStr += `+${char.repeat(12)}`;
119
- return outStr + "+";
120
- }, _ReceiptV5_lineItemsToString = function _ReceiptV5_lineItemsToString() {
121
- if (!this.lineItems || this.lineItems.length === 0) {
122
- return "";
123
- }
124
- const lines = this.lineItems
125
- .map((item) => item.toTableLine())
126
- .join(`\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}\n `);
127
- let outStr = "";
128
- outStr += `\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}\n `;
129
- outStr += " | Description ";
130
- outStr += " | Quantity";
131
- outStr += " | Total Amount";
132
- outStr += " | Unit Price";
133
- outStr += ` |\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "=")}`;
134
- outStr += `\n ${lines}`;
135
- outStr += `\n${__classPrivateFieldGet(this, _ReceiptV5_instances, "m", _ReceiptV5_lineItemsSeparator).call(this, "-")}`;
136
- return outStr;
137
- };
@@ -1,22 +0,0 @@
1
- import { Document, DocumentConstructorProps } from "../../document";
2
- import { TextField, DateField, PositionField, Amount } from "../../../fields";
3
- export declare class BankCheckV1 extends Document {
4
- /** Payer's bank account number. */
5
- accountNumber: TextField;
6
- /** Amount to be paid. */
7
- amount: Amount;
8
- /** The check number. */
9
- checkNumber: TextField;
10
- /** Check's position in the image. */
11
- checkPosition: PositionField;
12
- /** Date the check was issued. */
13
- issuanceDate: DateField;
14
- /** List of payees (full name or company name). */
15
- payees: TextField[];
16
- /** Payer's bank account routing number. */
17
- routingNumber: TextField;
18
- /** The positions of the signatures on the image. */
19
- signaturesPositions: PositionField;
20
- constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
21
- toString(): string;
22
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BankCheckV1 = void 0;
4
- const document_1 = require("../../document");
5
- const fields_1 = require("../../../fields");
6
- class BankCheckV1 extends document_1.Document {
7
- constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
8
- super({
9
- inputSource: inputSource,
10
- pageId: pageId,
11
- orientation: orientation,
12
- extras: extras,
13
- });
14
- /** List of payees (full name or company name). */
15
- this.payees = [];
16
- this.accountNumber = new fields_1.TextField({
17
- prediction: prediction.account_number,
18
- pageId: pageId,
19
- });
20
- this.checkNumber = new fields_1.TextField({
21
- prediction: prediction.check_number,
22
- pageId: pageId,
23
- });
24
- this.amount = new fields_1.Amount({
25
- prediction: prediction.amount,
26
- pageId: pageId,
27
- });
28
- this.checkPosition = new fields_1.PositionField({
29
- prediction: prediction.check_position,
30
- pageId: pageId,
31
- });
32
- this.issuanceDate = new fields_1.DateField({
33
- prediction: prediction.date,
34
- pageId: pageId,
35
- });
36
- prediction.payees.map((prediction) => this.payees.push(new fields_1.TextField({
37
- prediction: prediction,
38
- pageId: pageId,
39
- })));
40
- this.routingNumber = new fields_1.TextField({
41
- prediction: prediction.routing_number,
42
- pageId: pageId,
43
- });
44
- this.signaturesPositions = new fields_1.PositionField({
45
- prediction: prediction.signatures_positions,
46
- pageId: pageId,
47
- });
48
- }
49
- toString() {
50
- const outStr = `----- US Bank Check V1 -----
51
- Filename: ${this.filename}
52
- Routing number: ${this.routingNumber}
53
- Account number: ${this.accountNumber}
54
- Check number: ${this.checkNumber}
55
- Date: ${this.issuanceDate}
56
- Amount: ${this.amount}
57
- Payees: ${this.payees.map((name) => name.value).join(", ")}
58
- ----------------------
59
- `;
60
- return BankCheckV1.cleanOutString(outStr);
61
- }
62
- }
63
- exports.BankCheckV1 = BankCheckV1;
@@ -1 +0,0 @@
1
- export { BankCheckV1 } from "./bankCheck/bankCheckV1";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BankCheckV1 = void 0;
4
- var bankCheckV1_1 = require("./bankCheck/bankCheckV1");
5
- Object.defineProperty(exports, "BankCheckV1", { enumerable: true, get: function () { return bankCheckV1_1.BankCheckV1; } });
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CompanyRegistration = void 0;
4
- const field_1 = require("./field");
5
- /**
6
- * A company registration item.
7
- */
8
- class CompanyRegistration extends field_1.Field {
9
- constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
10
- super({ prediction, valueKey, reconstructed, pageId });
11
- this.type = prediction.type;
12
- }
13
- }
14
- exports.CompanyRegistration = CompanyRegistration;
@@ -1,27 +0,0 @@
1
- import * as geometry from "../geometry";
2
- export type Word = {
3
- /**
4
- * Contains the relative vertices coordinates (points) of a polygon containing
5
- * the field in the document.
6
- */
7
- polygon: geometry.Polygon;
8
- text: string;
9
- confidence: number;
10
- };
11
- type Line = Word[];
12
- /**
13
- * OCR extraction from the entire document.
14
- */
15
- export declare class FullText {
16
- words: Word[];
17
- /**
18
- * Order all text on a page into lines.
19
- * WARNING: This feature is experimental.
20
- */
21
- toLines(): Line[];
22
- /**
23
- * WARNING: This feature is experimental.
24
- */
25
- toString(): string;
26
- }
27
- export {};