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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.0.1 - 2023-08-22
4
+ ### Fixes
5
+ * :bug: fixed pre-commit dependency script blocking installs
6
+
7
+
8
+ ## v4.0.0 - 2023-08-14
9
+ ### ¡Breaking Changes!
10
+ * :art: :boom: harmonize response types with other libraries
11
+ * :art: :boom: change endpoint management & syntax
12
+ * :art: :boom: move products to `product` module
13
+
14
+ ### Changes
15
+ * :sparkles: add full support for page-specific attributes
16
+ * :sparkles: add support for FR Id Card
17
+ * :sparkles: add support for US Driver License
18
+ * :sparkles: add auto-generated md documentation
19
+ * :sparkles: add text reconstruction when using the `allWords` parameter (full OCR)
20
+ * :recycle: updated CLI to accommodate for newest changes
21
+ * :coffin: remove InvoiceV3
22
+ * :coffin: remove ReceiptV3
23
+ * :recycle: update tests to accommodate for newest changes
24
+ * :recycle: re-organized parsing module (common/standard/custom)
25
+
26
+
3
27
  ## v3.10.2 - 2023-08-11
4
28
  ### Changes
5
29
  * :loud_sound: better logging of JSON errors
package/README.md CHANGED
@@ -1,7 +1,4 @@
1
- [![License: MIT](https://img.shields.io/github/license/mindee/mindee-api-nodejs)](https://opensource.org/licenses/MIT)
2
- [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mindee/mindee-api-nodejs/test.yml)](https://github.com/mindee/mindee-api-nodejs)
3
- [![NPM Version](https://img.shields.io/npm/v/mindee)](https://www.npmjs.com/package/mindee)
4
- [![Downloads](https://img.shields.io/npm/dm/mindee)](https://www.npmjs.com/package/mindee)
1
+ [![License: MIT](https://img.shields.io/github/license/mindee/mindee-api-nodejs)](https://opensource.org/licenses/MIT) [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mindee/mindee-api-nodejs/test.yml)](https://github.com/mindee/mindee-api-nodejs) [![NPM Version](https://img.shields.io/npm/v/mindee)](https://www.npmjs.com/package/mindee) [![Downloads](https://img.shields.io/npm/dm/mindee)](https://www.npmjs.com/package/mindee)
5
2
 
6
3
  # Mindee API Helper Library for Node.js
7
4
  Quickly and easily connect to Mindee's API services using Node.js.
@@ -29,75 +26,140 @@ const mindee = require("mindee");
29
26
  // Init a new client
30
27
  const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
31
28
 
32
- // Load a file from disk and parse it
33
- const apiResponse = mindeeClient
34
- .docFromPath("/path/to/the/file.ext")
35
- .parse(mindee.InvoiceV4);
29
+ // Load a file from disk
30
+ const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
31
+
32
+ // Parse it on the API of your choice
33
+ const apiResponse = mindeeClient.parse(mindee.product.InvoiceV4, inputSource);
34
+ ```
35
+
36
+ **Note:** Files can also be loaded from:
37
+
38
+ A URL (`https` only):
39
+ ```js
40
+ const inputSource = mindeeClient.docFromUrl("https://my-url");
41
+ ```
42
+
43
+ A base64 encoded string:
44
+ ```js
45
+ const inputSource = mindeeClient.docFromBase64(myInputString, "my-file-name")
46
+ ```
47
+
48
+ A stream:
49
+ ```js
50
+ const inputSource = mindeeClient.docFromBuffer(myReadableStream, "my-file-name")
51
+ ```
52
+
53
+ A buffer:
54
+ ```js
55
+ const inputSource = mindeeClient.docFromBuffer(myBuffer, "my-file-name")
36
56
  ```
37
57
 
38
58
  #### Region-Specific Documents
59
+
60
+ Region-Specific Documents use the following syntax:
61
+
39
62
  ```js
40
63
  const mindee = require("mindee");
41
64
  // for TS or modules:
42
65
  // import * as mindee from "mindee";
43
66
 
44
- // Init a new client
45
67
  const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
46
68
 
47
- // Load a file from disk and parse it
48
- const apiResponse = mindeeClient
49
- .docFromPath("/path/to/the/file.ext")
50
- .parse(mindee.fr.IdCardV1);
69
+ const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
70
+
71
+ // The IdCardV1 product belongs to mindee.product.fr, not mindee.product itself
72
+ const apiResponse = mindeeClient.parse(mindee.product.fr.IdCardV1, inputSource);
51
73
  ```
52
74
 
53
75
  #### Custom Documents (API Builder)
76
+
77
+ Custom documents will require you to provide their endpoint manually.
78
+
54
79
  ```js
55
80
  const mindee = require("mindee");
56
81
  // for TS or modules:
57
82
  // import * as mindee from "mindee";
58
83
 
59
- // Init a new client and add your document endpoint
60
- const mindeeClient = new mindee.Client({ apiKey: "my-api-key" })
61
- .addEndpoint({
62
- accountName: "my-account",
63
- endpointName: "my-endpoint",
64
- });
84
+ // Init a new client
85
+ const mindeeClient = new mindee.Client({
86
+ apiKey: "my-api-key"
87
+ });
88
+
89
+ // Load a file from disk
90
+ const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
65
91
 
66
- // Load a file from disk and parse it
92
+ // Create a custom endpoint for your product
93
+ const customEndpoint = mindeeClient.createEndpoint(
94
+ "my-endpoint",
95
+ "my-account",
96
+ "my-version" // will default to 1 if not provided
97
+ );
98
+
99
+ // Parse it
67
100
  const apiResponse = mindeeClient
68
- .docFromPath("/path/to/the/file.ext")
69
- .parse(mindee.CustomV1, { endpointName: "my-endpoint" });
101
+ .parse(
102
+ mindee.product.CustomV1,
103
+ inputSource,
104
+ {
105
+ endpoint: customEndpoint
106
+ }
107
+ );
70
108
  ```
71
109
 
72
110
  ### Handling the Return
73
111
  ```js
74
112
  // Handle the response Promise
75
113
  apiResponse.then((resp) => {
76
-
77
- // The `document` property can be undefined:
78
- // * TypeScript will not compile without this guard clause
79
- // (or consider using the '?' notation)
80
- // * JavaScript will be very happy to produce subtle bugs
81
- // without this guard clause
82
- if (resp.document === undefined) return;
83
-
84
- // full object
85
- console.log(resp.document);
86
-
87
- // string summary
114
+ // print a string summary
88
115
  console.log(resp.document.toString());
116
+
117
+ // individual pages (array)
118
+ console.log(res.document.inference.pages);
89
119
  });
90
120
  ```
91
121
 
92
- ## Further Reading
93
- There's more to it than that for those that need more features, or want to
94
- customize the experience.
122
+ ### Additional Options
123
+ Options to pass when sending a file to be parsed.
124
+
125
+ #### Page Options
126
+ Allows only sending certain pages in a PDF.
95
127
 
96
- All the juicy details are described in the
97
- **[Official Guide](https://developers.mindee.com/docs/nodejs-sdk)**.
128
+ In this example we only send the first, penultimate, and last pages:
98
129
 
99
- You can also take a look at the
100
- **[Reference Documentation](https://mindee.github.io/mindee-api-nodejs/)**.
130
+ ```js
131
+ const apiResponse = mindeeClient.parse(
132
+ mindee.product.InvoiceV4,
133
+ inputSource,
134
+ {
135
+ pageOptions: {
136
+ pageIndexes: [0, -2, -1],
137
+ operation: mindee.PageOptionsOperation.KeepOnly,
138
+ onMinPages: 2
139
+ }
140
+ });
141
+ ```
142
+
143
+ ## Further Reading
144
+ Complete details on the working of the library are available in the following guides:
145
+
146
+ * [Node.js Getting Started](https://developers.mindee.com/docs/nodejs-getting-started)
147
+ * [Node.js Custom OCR](https://developers.mindee.com/docs/nodejs-api-builder)
148
+ * [Node.js Invoice OCR](https://developers.mindee.com/docs/nodejs-invoice-ocr)
149
+ * [Node.js Receipt OCR](https://developers.mindee.com/docs/nodejs-receipt-ocr)
150
+ * [Node.js Financial Document OCR](https://developers.mindee.com/docs/nodejs-financial-document-ocr)
151
+ * [Node.js Passport OCR](https://developers.mindee.com/docs/nodejs-passport-ocr)
152
+ * [Node.js Proof of Address OCR](https://developers.mindee.com/docs/nodejs-proof-of-address-ocr)
153
+ * [Node.js EU License Plate OCR](https://developers.mindee.com/docs/nodejs-eu-license-plates-ocr)
154
+ * [Node.js FR Bank Account Detail OCR](https://developers.mindee.com/docs/nodejs-fr-bank-account-details-ocr)
155
+ * [Node.js FR Carte Vitale OCR](https://developers.mindee.com/docs/nodejs-fr-carte-vitale-ocr)
156
+ * [Node.js FR ID Card OCR](https://developers.mindee.com/docs/nodejs-fr-id-card-ocr)
157
+ * [Node.js US Bank Check OCR](https://developers.mindee.com/docs/nodejs-us-bank-checks-ocr)
158
+ * [Node.js US Driver License OCR](https://developers.mindee.com/docs/nodejs-us-driver-license-ocr)
159
+ * [Node.js Cropper API](https://developers.mindee.com/docs/nodejs-cropper-api)
160
+ * [Node.js Invoice Splitter API](https://developers.mindee.com/docs/nodejs-invoice-splitter-api)
161
+
162
+ You can also take a look at the **[Reference Documentation](https://mindee.github.io/mindee-api-nodejs/)**.
101
163
 
102
164
  ## License
103
165
  Copyright © Mindee
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "3.10.2",
3
+ "version": "4.0.1",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -10,8 +10,8 @@
10
10
  "build-for-dist": "tsc --build && cp LICENSE README.md CHANGELOG.md ./dist",
11
11
  "clean": "rm -rf ./dist ./docs/_build",
12
12
  "test": "mocha 'tests/**/*.spec.ts'",
13
- "lint-fix": "eslint './src/**/*.ts' --fix",
14
13
  "lint": "eslint './src/**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'",
14
+ "lint-fix": "eslint './src/**/*.ts' --fix",
15
15
  "docs": "typedoc --out docs/_build ./src/index.ts",
16
16
  "docs-for-dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/"
17
17
  },
@@ -40,16 +40,15 @@
40
40
  "homepage": "https://mindee.com/",
41
41
  "devDependencies": {
42
42
  "@types/chai": "^4.3.4",
43
+ "@types/lint-staged": "^13.2.0",
43
44
  "@types/mocha": "^9.1.1",
44
45
  "@types/node": "^18.15.11",
45
46
  "@typescript-eslint/eslint-plugin": "^5.57.1",
46
47
  "@typescript-eslint/parser": "^5.57.1",
47
48
  "chai": "^4.3.7",
48
49
  "eslint": "^8.32.0",
49
- "eslint-config-prettier": "^8.6.0",
50
- "eslint-plugin-prettier": "^4.2.1",
50
+ "lint-staged": "^13.2.3",
51
51
  "mocha": "^10.1.0",
52
- "prettier": "^2.8.1",
53
52
  "ts-node": "^10.9.1",
54
53
  "typedoc": "~0.23",
55
54
  "typescript": "^5.0.4"
package/src/cli.js CHANGED
@@ -25,10 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.cli = void 0;
27
27
  const commander_1 = require("commander");
28
- const _1 = require("./");
29
- const api_1 = require("./api");
28
+ const product = __importStar(require("./product"));
30
29
  const client_1 = require("./client");
31
- const inputs_1 = require("./inputs");
30
+ const input_1 = require("./input");
32
31
  const console = __importStar(require("console"));
33
32
  const program = new commander_1.Command();
34
33
  const COMMAND_CUSTOM = "custom";
@@ -42,8 +41,18 @@ const CLI_COMMAND_CONFIG = new Map([
42
41
  COMMAND_CUSTOM,
43
42
  {
44
43
  displayName: "Custom Document",
45
- docClass: _1.CustomV1,
46
- fullText: false,
44
+ docClass: product.CustomV1,
45
+ allWords: false,
46
+ async: false,
47
+ sync: true,
48
+ },
49
+ ],
50
+ [
51
+ "cropper",
52
+ {
53
+ displayName: "Cropper",
54
+ docClass: product.CropperV1,
55
+ allWords: false,
47
56
  async: false,
48
57
  sync: true,
49
58
  },
@@ -52,8 +61,8 @@ const CLI_COMMAND_CONFIG = new Map([
52
61
  "invoice",
53
62
  {
54
63
  displayName: "Invoice",
55
- docClass: _1.InvoiceV4,
56
- fullText: true,
64
+ docClass: product.InvoiceV4,
65
+ allWords: true,
57
66
  async: false,
58
67
  sync: true,
59
68
  },
@@ -62,8 +71,8 @@ const CLI_COMMAND_CONFIG = new Map([
62
71
  "invoice-splitter",
63
72
  {
64
73
  displayName: "Invoice Splitter",
65
- docClass: _1.InvoiceSplitterV1,
66
- fullText: false,
74
+ docClass: product.InvoiceSplitterV1,
75
+ allWords: false,
67
76
  async: true,
68
77
  sync: false,
69
78
  },
@@ -72,8 +81,8 @@ const CLI_COMMAND_CONFIG = new Map([
72
81
  "receipt",
73
82
  {
74
83
  displayName: "Expense Receipt",
75
- docClass: _1.ReceiptV5,
76
- fullText: true,
84
+ docClass: product.ReceiptV5,
85
+ allWords: true,
77
86
  async: false,
78
87
  sync: true,
79
88
  },
@@ -82,8 +91,8 @@ const CLI_COMMAND_CONFIG = new Map([
82
91
  "passport",
83
92
  {
84
93
  displayName: "Passport",
85
- docClass: _1.PassportV1,
86
- fullText: false,
94
+ docClass: product.PassportV1,
95
+ allWords: false,
87
96
  async: false,
88
97
  sync: true,
89
98
  },
@@ -92,8 +101,8 @@ const CLI_COMMAND_CONFIG = new Map([
92
101
  "financial",
93
102
  {
94
103
  displayName: "Financial Document",
95
- docClass: _1.FinancialDocumentV1,
96
- fullText: true,
104
+ docClass: product.FinancialDocumentV1,
105
+ allWords: true,
97
106
  async: false,
98
107
  sync: true,
99
108
  },
@@ -102,8 +111,8 @@ const CLI_COMMAND_CONFIG = new Map([
102
111
  "fr-id-card",
103
112
  {
104
113
  displayName: "FR ID Card",
105
- docClass: _1.fr.IdCardV1,
106
- fullText: false,
114
+ docClass: product.fr.IdCardV1,
115
+ allWords: false,
107
116
  async: false,
108
117
  sync: true,
109
118
  },
@@ -112,8 +121,8 @@ const CLI_COMMAND_CONFIG = new Map([
112
121
  "fr-bank-account-details",
113
122
  {
114
123
  displayName: "FR Bank Account Details",
115
- docClass: _1.fr.BankAccountDetailsV1,
116
- fullText: false,
124
+ docClass: product.fr.BankAccountDetailsV2,
125
+ allWords: false,
117
126
  async: false,
118
127
  sync: true,
119
128
  },
@@ -122,8 +131,8 @@ const CLI_COMMAND_CONFIG = new Map([
122
131
  "fr-carte-vitale",
123
132
  {
124
133
  displayName: "FR Carte Vitale",
125
- docClass: _1.fr.CarteVitaleV1,
126
- fullText: false,
134
+ docClass: product.fr.CarteVitaleV1,
135
+ allWords: false,
127
136
  async: false,
128
137
  sync: true,
129
138
  },
@@ -132,8 +141,8 @@ const CLI_COMMAND_CONFIG = new Map([
132
141
  "eu-license-plate",
133
142
  {
134
143
  displayName: "EU License Plate",
135
- docClass: _1.eu.LicensePlateV1,
136
- fullText: false,
144
+ docClass: product.eu.LicensePlateV1,
145
+ allWords: false,
137
146
  async: false,
138
147
  sync: true,
139
148
  },
@@ -142,18 +151,8 @@ const CLI_COMMAND_CONFIG = new Map([
142
151
  "us-bank-check",
143
152
  {
144
153
  displayName: "US Bank Check",
145
- docClass: _1.us.BankCheckV1,
146
- fullText: false,
147
- async: false,
148
- sync: true,
149
- },
150
- ],
151
- [
152
- "mvision",
153
- {
154
- displayName: "Mindee Vision",
155
- docClass: _1.MindeeVisionV1,
156
- fullText: false,
154
+ docClass: product.us.BankCheckV1,
155
+ allWords: false,
157
156
  async: false,
158
157
  sync: true,
159
158
  },
@@ -162,17 +161,11 @@ const CLI_COMMAND_CONFIG = new Map([
162
161
  //
163
162
  // EXECUTE THE COMMANDS
164
163
  //
165
- function initClient(command, options) {
164
+ function initClient(options) {
166
165
  const mindeeClient = new client_1.Client({
167
166
  apiKey: options.apiKey,
168
167
  debug: options.debug,
169
168
  });
170
- if (command === COMMAND_CUSTOM) {
171
- mindeeClient.addEndpoint({
172
- accountName: options.user,
173
- endpointName: options.documentType,
174
- });
175
- }
176
169
  return mindeeClient;
177
170
  }
178
171
  function getConfig(command) {
@@ -182,45 +175,78 @@ function getConfig(command) {
182
175
  }
183
176
  return conf;
184
177
  }
185
- function getPredictParams(command, options, conf) {
178
+ function getPageOptions(options) {
186
179
  let pageOptions = undefined;
187
180
  if (options.cutPages) {
188
181
  pageOptions = {
189
- operation: inputs_1.PageOptionsOperation.KeepOnly,
182
+ operation: input_1.PageOptionsOperation.KeepOnly,
190
183
  pageIndexes: [0, 1, 2, 3, 4],
191
184
  onMinPages: 5,
192
185
  };
193
186
  }
187
+ return pageOptions;
188
+ }
189
+ function getPredictParams(options) {
194
190
  const predictParams = {
195
- endpointName: command === COMMAND_CUSTOM ? options.documentType : conf.docClass.name,
196
- accountName: command === COMMAND_CUSTOM ? options.user : api_1.STANDARD_API_OWNER,
197
- fullText: options.fullText,
198
- pageOptions: pageOptions,
191
+ allWords: options.allWords,
192
+ cropper: options.cropper,
199
193
  };
200
194
  return predictParams;
201
195
  }
202
196
  async function callParse(command, inputPath, options) {
203
197
  const conf = getConfig(command);
204
- const mindeeClient = initClient(command, options);
205
- const predictParams = getPredictParams(command, options, conf);
206
- const doc = mindeeClient.docFromPath(inputPath);
207
- const response = await doc.parse(conf.docClass, predictParams);
208
- printResponse(response, options);
198
+ const mindeeClient = initClient(options);
199
+ const predictParams = getPredictParams(options);
200
+ const pageOptions = getPageOptions(options);
201
+ const inputSource = mindeeClient.docFromPath(inputPath);
202
+ let response;
203
+ if (command === COMMAND_CUSTOM) {
204
+ const customEndpoint = mindeeClient.createEndpoint(options.endpoint, options.account, options.version);
205
+ response = await mindeeClient.parse(conf.docClass, inputSource, {
206
+ endpoint: customEndpoint,
207
+ pageOptions: pageOptions,
208
+ allWords: predictParams.allWords,
209
+ cropper: predictParams.cropper,
210
+ });
211
+ }
212
+ else {
213
+ response = await mindeeClient.parse(conf.docClass, inputSource, {
214
+ pageOptions: pageOptions,
215
+ allWords: predictParams.allWords,
216
+ cropper: predictParams.cropper,
217
+ });
218
+ }
219
+ printResponse(response.document, options);
209
220
  }
210
221
  async function callEnqueue(command, inputPath, options) {
211
222
  const conf = getConfig(command);
212
- const mindeeClient = initClient(command, options);
213
- const predictParams = getPredictParams(command, options, conf);
214
- const doc = mindeeClient.docFromPath(inputPath);
215
- const response = await doc.enqueue(conf.docClass, predictParams);
223
+ const mindeeClient = initClient(options);
224
+ const predictParams = getPredictParams(options);
225
+ const pageOptions = getPageOptions(options);
226
+ const inputSource = mindeeClient.docFromPath(inputPath);
227
+ let response;
228
+ if (command === COMMAND_CUSTOM) {
229
+ const customEndpoint = mindeeClient.createEndpoint(options.endpoint, options.account, options.version);
230
+ response = await mindeeClient.enqueue(conf.docClass, inputSource, {
231
+ endpoint: customEndpoint,
232
+ pageOptions: pageOptions,
233
+ allWords: predictParams.allWords,
234
+ cropper: predictParams.cropper,
235
+ });
236
+ }
237
+ else {
238
+ response = await mindeeClient.enqueue(conf.docClass, inputSource, {
239
+ pageOptions: pageOptions,
240
+ allWords: predictParams.allWords,
241
+ cropper: predictParams.cropper,
242
+ });
243
+ }
216
244
  console.log(response.job);
217
245
  }
218
246
  async function callParseQueued(command, queueId, options) {
219
247
  const conf = getConfig(command);
220
- const mindeeClient = initClient(command, options);
221
- const predictParams = getPredictParams(command, options, conf);
222
- const doc = mindeeClient.docForAsync();
223
- const response = await doc.parseQueued(conf.docClass, queueId, predictParams);
248
+ const mindeeClient = initClient(options);
249
+ const response = await mindeeClient.parseQueued(conf.docClass, queueId);
224
250
  if (response.document !== undefined) {
225
251
  printResponse(response.document, options);
226
252
  }
@@ -228,19 +254,19 @@ async function callParseQueued(command, queueId, options) {
228
254
  console.log(response.job);
229
255
  }
230
256
  }
231
- function printResponse(response, options) {
232
- if (options.fullText) {
233
- response.pages.forEach((page) => {
234
- console.log(page.fullText?.toString());
257
+ function printResponse(document, options) {
258
+ if (options.allWords) {
259
+ document.ocr?.mVisionV1.pages.forEach((page) => {
260
+ console.log(page.allWords.toString());
235
261
  });
236
262
  }
237
263
  if (options.pages) {
238
- response.pages.forEach((page) => {
264
+ document.inference.pages.forEach((page) => {
239
265
  console.log(`\n${page}`);
240
266
  });
241
267
  }
242
- if (response.document) {
243
- console.log(`\n${response.document}`);
268
+ if (document) {
269
+ console.log(`\n${document}`);
244
270
  }
245
271
  }
246
272
  //
@@ -251,8 +277,8 @@ function addMainOptions(prog) {
251
277
  }
252
278
  function addPostOptions(prog, info) {
253
279
  prog.option("-c, --cut-pages", "keep only the first 5 pages of the document");
254
- if (info.fullText) {
255
- prog.option("-t, --full-text", "include full document text in response");
280
+ if (info.allWords) {
281
+ prog.option("-w, --all-words", "to get all the words in the current document. False by default.");
256
282
  }
257
283
  prog.argument("<input_path>", "full path to the file");
258
284
  }