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.
- package/CHANGELOG.md +19 -0
- package/README.md +103 -41
- package/package.json +6 -6
- package/src/cli.js +96 -70
- package/src/client.d.ts +34 -65
- package/src/client.js +108 -172
- package/src/geometry/boundingBox.d.ts +5 -0
- package/src/geometry/boundingBox.js +2 -0
- package/src/geometry/boundingBoxUtils.d.ts +22 -0
- package/src/geometry/boundingBoxUtils.js +66 -0
- package/src/geometry/index.d.ts +6 -0
- package/src/geometry/index.js +21 -0
- package/src/geometry/minMax.d.ts +4 -0
- package/src/geometry/minMax.js +2 -0
- package/src/geometry/point.d.ts +2 -0
- package/src/geometry/point.js +2 -0
- package/src/geometry/polygon.d.ts +4 -0
- package/src/geometry/polygon.js +7 -0
- package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
- package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
- package/src/http/endpoint.d.ts +44 -0
- package/src/http/endpoint.js +188 -0
- package/src/http/error.d.ts +2 -0
- package/src/http/error.js +9 -0
- package/src/http/index.d.ts +3 -0
- package/src/http/index.js +11 -0
- package/src/http/mindeeApi.d.ts +20 -0
- package/src/http/mindeeApi.js +73 -0
- package/src/index.d.ts +4 -4
- package/src/index.js +33 -26
- package/src/{inputs → input}/base.d.ts +4 -3
- package/src/{inputs → input}/base.js +9 -7
- package/src/{inputs → input}/index.d.ts +1 -1
- package/src/{inputs → input}/index.js +1 -2
- package/src/{inputs → input}/sources.d.ts +10 -11
- package/src/{inputs → input}/sources.js +9 -9
- package/src/parsing/common/apiRequest.d.ts +10 -0
- package/src/parsing/common/apiRequest.js +13 -0
- package/src/parsing/common/apiResponse.d.ts +6 -0
- package/src/parsing/common/apiResponse.js +10 -0
- package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
- package/src/parsing/common/asyncPredictResponse.js +39 -0
- package/src/parsing/common/document.d.ts +13 -0
- package/src/parsing/common/document.js +34 -0
- package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
- package/src/parsing/common/extras/cropperExtra.js +26 -0
- package/src/parsing/common/extras/extras.d.ts +11 -0
- package/src/parsing/common/extras/extras.js +18 -0
- package/src/parsing/common/index.d.ts +9 -0
- package/src/parsing/common/index.js +20 -0
- package/src/parsing/common/inference.d.ts +26 -0
- package/src/parsing/common/inference.js +56 -0
- package/src/parsing/common/mvisionV1.d.ts +8 -0
- package/src/parsing/common/mvisionV1.js +17 -0
- package/src/parsing/common/ocr.d.ts +8 -0
- package/src/parsing/common/ocr.js +13 -0
- package/src/parsing/common/ocrPage.d.ts +16 -0
- package/src/parsing/common/ocrPage.js +66 -0
- package/src/{fields → parsing/common}/orientation.d.ts +2 -2
- package/src/{fields → parsing/common}/orientation.js +4 -4
- package/src/parsing/common/page.d.ts +12 -0
- package/src/parsing/common/page.js +40 -0
- package/src/parsing/common/predictResponse.d.ts +6 -0
- package/src/parsing/common/predictResponse.js +12 -0
- package/src/parsing/common/prediction.d.ts +2 -0
- package/src/parsing/common/prediction.js +6 -0
- package/src/parsing/common/product.d.ts +4 -0
- package/src/parsing/common/product.js +2 -0
- package/src/parsing/common/stringDict.d.ts +3 -0
- package/src/parsing/common/stringDict.js +2 -0
- package/src/parsing/common/summaryHelper.d.ts +8 -0
- package/src/parsing/common/summaryHelper.js +22 -0
- package/src/parsing/custom/classificationField.d.ts +16 -0
- package/src/parsing/custom/classificationField.js +14 -0
- package/src/parsing/custom/index.d.ts +3 -0
- package/src/parsing/custom/index.js +12 -0
- package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
- package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
- package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
- package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
- package/src/parsing/index.d.ts +3 -0
- package/src/parsing/index.js +29 -0
- package/src/{fields → parsing/standard}/amount.d.ts +2 -2
- package/src/{fields → parsing/standard}/amount.js +5 -5
- package/src/{fields → parsing/standard}/base.d.ts +5 -5
- package/src/{fields → parsing/standard}/base.js +3 -2
- package/src/{fields → parsing/standard}/classification.d.ts +1 -1
- package/src/{fields → parsing/standard}/classification.js +3 -3
- package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
- package/src/parsing/standard/companyRegistration.js +14 -0
- package/src/{fields → parsing/standard}/date.d.ts +1 -1
- package/src/{fields → parsing/standard}/date.js +2 -2
- package/src/{fields → parsing/standard}/field.d.ts +3 -4
- package/src/{fields → parsing/standard}/field.js +6 -7
- package/src/parsing/standard/index.d.ts +12 -0
- package/src/parsing/standard/index.js +27 -0
- package/src/{fields → parsing/standard}/locale.d.ts +4 -4
- package/src/parsing/standard/locale.js +42 -0
- package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
- package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
- package/src/{fields → parsing/standard}/position.d.ts +2 -2
- package/src/{fields → parsing/standard}/position.js +5 -5
- package/src/{fields → parsing/standard}/tax.d.ts +3 -3
- package/src/{fields → parsing/standard}/tax.js +3 -3
- package/src/{fields → parsing/standard}/text.d.ts +2 -2
- package/src/{fields → parsing/standard}/text.js +4 -4
- package/src/parsing/standard/word.d.ts +10 -0
- package/src/parsing/standard/word.js +2 -0
- package/src/pdf/pdfOperation.d.ts +1 -1
- package/src/pdf/pdfOperation.js +3 -3
- package/src/product/cropper/cropperV1.d.ts +9 -0
- package/src/product/cropper/cropperV1.js +16 -0
- package/src/product/cropper/cropperV1Document.d.ts +8 -0
- package/src/product/cropper/cropperV1Document.js +26 -0
- package/src/product/custom/customV1.d.ts +10 -0
- package/src/product/custom/customV1.js +17 -0
- package/src/product/custom/customV1Document.d.ts +9 -0
- package/src/product/custom/customV1Document.js +43 -0
- package/src/product/custom/customV1Page.d.ts +7 -0
- package/src/product/custom/customV1Page.js +24 -0
- package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
- package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
- package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
- package/src/product/financialDocument/financialDocumentV1.js +16 -0
- package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
- package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
- package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
- package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
- package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
- package/src/product/fr/idCard/idCardV1.d.ts +10 -0
- package/src/product/fr/idCard/idCardV1.js +17 -0
- package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
- package/src/product/fr/idCard/idCardV1Document.js +70 -0
- package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
- package/src/product/fr/idCard/idCardV1Page.js +23 -0
- package/src/{documents → product}/index.d.ts +2 -7
- package/src/{documents → product}/index.js +3 -14
- package/src/product/invoice/invoiceV4.d.ts +9 -0
- package/src/product/invoice/invoiceV4.js +16 -0
- package/src/product/invoice/invoiceV4Document.d.ts +44 -0
- package/src/product/invoice/invoiceV4Document.js +146 -0
- package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
- package/src/product/invoice/invoiceV4LineItem.js +101 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
- package/src/product/passport/passportV1.d.ts +9 -0
- package/src/product/passport/passportV1.js +16 -0
- package/src/product/passport/passportV1Document.d.ts +31 -0
- package/src/product/passport/passportV1Document.js +75 -0
- package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
- package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
- package/src/product/receipt/receiptV4.d.ts +9 -0
- package/src/product/receipt/receiptV4.js +15 -0
- package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
- package/src/product/receipt/receiptV4Document.js +67 -0
- package/src/product/receipt/receiptV5.d.ts +9 -0
- package/src/product/receipt/receiptV5.js +16 -0
- package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
- package/src/product/receipt/receiptV5Document.js +108 -0
- package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
- package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
- package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
- package/src/product/us/bankCheck/bankCheckV1.js +17 -0
- package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
- package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
- package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
- package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
- package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
- package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
- package/src/product/us/index.d.ts +2 -0
- package/src/product/us/index.js +7 -0
- package/src/api/documentResponse.d.ts +0 -25
- package/src/api/documentResponse.js +0 -50
- package/src/api/endpoint.d.ts +0 -63
- package/src/api/endpoint.js +0 -216
- package/src/api/index.d.ts +0 -3
- package/src/api/index.js +0 -13
- package/src/api/predictResponse.d.ts +0 -33
- package/src/api/predictResponse.js +0 -52
- package/src/documents/cropper/cropperV1.d.ts +0 -7
- package/src/documents/cropper/cropperV1.js +0 -35
- package/src/documents/custom/customV1.d.ts +0 -10
- package/src/documents/custom/customV1.js +0 -53
- package/src/documents/document.d.ts +0 -47
- package/src/documents/document.js +0 -76
- package/src/documents/documentConfig.d.ts +0 -42
- package/src/documents/documentConfig.js +0 -118
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
- package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
- package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
- package/src/documents/financialDocument/financialDocumentV0.js +0 -140
- package/src/documents/financialDocument/financialDocumentV1.js +0 -197
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
- package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
- package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
- package/src/documents/fr/idCard/idCardV1.js +0 -79
- package/src/documents/invoice/checks.d.ts +0 -5
- package/src/documents/invoice/checks.js +0 -87
- package/src/documents/invoice/invoiceLineItem.js +0 -66
- package/src/documents/invoice/invoiceV3.d.ts +0 -49
- package/src/documents/invoice/invoiceV3.js +0 -156
- package/src/documents/invoice/invoiceV4.d.ts +0 -45
- package/src/documents/invoice/invoiceV4.js +0 -166
- package/src/documents/invoice/reconstruction.d.ts +0 -6
- package/src/documents/invoice/reconstruction.js +0 -78
- package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
- package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
- package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
- package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
- package/src/documents/passport/passportV1.d.ts +0 -43
- package/src/documents/passport/passportV1.js +0 -220
- package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
- package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
- package/src/documents/receipt/receiptV3.d.ts +0 -25
- package/src/documents/receipt/receiptV3.js +0 -136
- package/src/documents/receipt/receiptV4.js +0 -78
- package/src/documents/receipt/receiptV5.js +0 -137
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
- package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
- package/src/documents/us/index.d.ts +0 -1
- package/src/documents/us/index.js +0 -5
- package/src/fields/companyRegistration.js +0 -14
- package/src/fields/fullText.d.ts +0 -27
- package/src/fields/fullText.js +0 -92
- package/src/fields/index.d.ts +0 -12
- package/src/fields/index.js +0 -28
- package/src/fields/locale.js +0 -45
- package/src/math/index.d.ts +0 -1
- package/src/math/index.js +0 -5
- package/src/math/precision.d.ts +0 -1
- package/src/math/precision.js +0 -13
- /package/src/{inputs → input}/pageOptions.d.ts +0 -0
- /package/src/{inputs → input}/pageOptions.js +0 -0
- /package/src/{documents → product}/eu/index.d.ts +0 -0
- /package/src/{documents → product}/eu/index.js +0 -0
- /package/src/{documents → product}/fr/index.d.ts +0 -0
- /package/src/{documents → product}/fr/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v4.0.0 - 2023-08-14
|
|
4
|
+
### ¡Breaking Changes!
|
|
5
|
+
* :art: :boom: harmonize response types with other libraries
|
|
6
|
+
* :art: :boom: change endpoint management & syntax
|
|
7
|
+
* :art: :boom: move products to `product` module
|
|
8
|
+
|
|
9
|
+
### Changes
|
|
10
|
+
* :sparkles: add full support for page-specific attributes
|
|
11
|
+
* :sparkles: add support for FR Id Card
|
|
12
|
+
* :sparkles: add support for US Driver License
|
|
13
|
+
* :sparkles: add auto-generated md documentation
|
|
14
|
+
* :sparkles: add text reconstruction when using the `allWords` parameter (full OCR)
|
|
15
|
+
* :recycle: updated CLI to accommodate for newest changes
|
|
16
|
+
* :coffin: remove InvoiceV3
|
|
17
|
+
* :coffin: remove ReceiptV3
|
|
18
|
+
* :recycle: update tests to accommodate for newest changes
|
|
19
|
+
* :recycle: re-organized parsing module (common/standard/custom)
|
|
20
|
+
|
|
21
|
+
|
|
3
22
|
## v3.10.2 - 2023-08-11
|
|
4
23
|
### Changes
|
|
5
24
|
* :loud_sound: better logging of JSON errors
|
package/README.md
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
[](https://opensource.org/licenses/MIT)
|
|
2
|
-
[](https://github.com/mindee/mindee-api-nodejs)
|
|
3
|
-
[](https://www.npmjs.com/package/mindee)
|
|
4
|
-
[](https://www.npmjs.com/package/mindee)
|
|
1
|
+
[](https://opensource.org/licenses/MIT) [](https://github.com/mindee/mindee-api-nodejs) [](https://www.npmjs.com/package/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
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
60
|
-
const mindeeClient = new mindee.Client({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
-
|
|
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
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "bin/mindee.js",
|
|
@@ -10,10 +10,10 @@
|
|
|
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.'",
|
|
15
14
|
"docs": "typedoc --out docs/_build ./src/index.ts",
|
|
16
|
-
"docs-for-dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/"
|
|
15
|
+
"docs-for-dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/",
|
|
16
|
+
"postinstall": "husky install"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"src/*",
|
|
@@ -40,16 +40,16 @@
|
|
|
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
|
-
"
|
|
50
|
-
"
|
|
50
|
+
"husky": "^8.0.3",
|
|
51
|
+
"lint-staged": "^13.2.3",
|
|
51
52
|
"mocha": "^10.1.0",
|
|
52
|
-
"prettier": "^2.8.1",
|
|
53
53
|
"ts-node": "^10.9.1",
|
|
54
54
|
"typedoc": "~0.23",
|
|
55
55
|
"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
|
|
29
|
-
const api_1 = require("./api");
|
|
28
|
+
const product = __importStar(require("./product"));
|
|
30
29
|
const client_1 = require("./client");
|
|
31
|
-
const
|
|
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:
|
|
46
|
-
|
|
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:
|
|
56
|
-
|
|
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:
|
|
66
|
-
|
|
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:
|
|
76
|
-
|
|
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:
|
|
86
|
-
|
|
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:
|
|
96
|
-
|
|
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:
|
|
106
|
-
|
|
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:
|
|
116
|
-
|
|
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:
|
|
126
|
-
|
|
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:
|
|
136
|
-
|
|
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:
|
|
146
|
-
|
|
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(
|
|
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
|
|
178
|
+
function getPageOptions(options) {
|
|
186
179
|
let pageOptions = undefined;
|
|
187
180
|
if (options.cutPages) {
|
|
188
181
|
pageOptions = {
|
|
189
|
-
operation:
|
|
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
|
-
|
|
196
|
-
|
|
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(
|
|
205
|
-
const predictParams = getPredictParams(
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
|
|
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(
|
|
213
|
-
const predictParams = getPredictParams(
|
|
214
|
-
const
|
|
215
|
-
const
|
|
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(
|
|
221
|
-
const
|
|
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(
|
|
232
|
-
if (options.
|
|
233
|
-
|
|
234
|
-
console.log(page.
|
|
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
|
-
|
|
264
|
+
document.inference.pages.forEach((page) => {
|
|
239
265
|
console.log(`\n${page}`);
|
|
240
266
|
});
|
|
241
267
|
}
|
|
242
|
-
if (
|
|
243
|
-
console.log(`\n${
|
|
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.
|
|
255
|
-
prog.option("-
|
|
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
|
}
|