mindee 3.1.0 → 3.1.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.
- package/CHANGELOG.md +4 -0
- package/README.md +29 -23
- package/package.json +1 -1
- package/src/cli.js +8 -7
- package/src/client.js +1 -1
- package/src/documents/fr/index.d.ts +1 -0
- package/src/documents/fr/index.js +5 -0
- package/src/documents/index.d.ts +9 -17
- package/src/documents/index.js +33 -18
- package/src/documents/us/index.d.ts +1 -0
- package/src/documents/us/index.js +5 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +3 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -13,8 +13,9 @@ npm install mindee
|
|
|
13
13
|
|
|
14
14
|
Finally, Node.js away!
|
|
15
15
|
|
|
16
|
-
###
|
|
16
|
+
### Loading a File and Parsing It
|
|
17
17
|
|
|
18
|
+
#### Global Documents
|
|
18
19
|
```js
|
|
19
20
|
const mindee = require("mindee");
|
|
20
21
|
// for TS or modules:
|
|
@@ -24,30 +25,27 @@ const mindee = require("mindee");
|
|
|
24
25
|
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
|
|
25
26
|
|
|
26
27
|
// Load a file from disk and parse it
|
|
27
|
-
const
|
|
28
|
-
.docFromPath("/path/to/the/
|
|
28
|
+
const apiResponse = mindeeClient
|
|
29
|
+
.docFromPath("/path/to/the/file.ext")
|
|
29
30
|
.parse(mindee.InvoiceV3);
|
|
31
|
+
```
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// (or consider using the '?' notation)
|
|
37
|
-
// * JavaScript will be very happy to produce subtle bugs
|
|
38
|
-
// without this guard clause
|
|
39
|
-
if (resp.document === undefined) return;
|
|
33
|
+
#### Region-Specific Documents
|
|
34
|
+
```js
|
|
35
|
+
const mindee = require("mindee");
|
|
36
|
+
// for TS or modules:
|
|
37
|
+
// import * as mindee from "mindee";
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// Init a new client
|
|
40
|
+
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// Load a file from disk and parse it
|
|
43
|
+
const apiResponse = mindeeClient
|
|
44
|
+
.docFromPath("/path/to/the/file.ext")
|
|
45
|
+
.parse(mindee.fr.IdCardV1);
|
|
47
46
|
```
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
#### Custom Documents (API Builder)
|
|
51
49
|
```js
|
|
52
50
|
const mindee = require("mindee");
|
|
53
51
|
// for TS or modules:
|
|
@@ -61,15 +59,23 @@ const mindeeClient = new mindee.Client({ apiKey: "my-api-key" })
|
|
|
61
59
|
});
|
|
62
60
|
|
|
63
61
|
// Load a file from disk and parse it
|
|
64
|
-
const
|
|
65
|
-
.docFromPath("/path/to/the/
|
|
62
|
+
const apiResponse = mindeeClient
|
|
63
|
+
.docFromPath("/path/to/the/file.ext")
|
|
66
64
|
.parse(mindee.CustomV1, { endpointName: "wsnine" });
|
|
65
|
+
```
|
|
67
66
|
|
|
67
|
+
### Handling the Return
|
|
68
|
+
```js
|
|
68
69
|
// Print a brief summary of the parsed data
|
|
69
|
-
|
|
70
|
+
invoiceResponse.then((resp) => {
|
|
70
71
|
|
|
72
|
+
// The document property can be undefined:
|
|
73
|
+
// * TypeScript will throw an error without this guard clause
|
|
74
|
+
// (or consider using the '?' notation)
|
|
75
|
+
// * JavaScript will be very happy to produce subtle bugs
|
|
76
|
+
// without this guard clause
|
|
71
77
|
if (resp.document === undefined) return;
|
|
72
|
-
|
|
78
|
+
|
|
73
79
|
// full object
|
|
74
80
|
console.log(resp.document);
|
|
75
81
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cli = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const documents_1 = require("./documents");
|
|
6
|
+
const fr_1 = require("./documents/fr");
|
|
6
7
|
const api_1 = require("./api");
|
|
7
8
|
const client_1 = require("./client");
|
|
8
9
|
const program = new commander_1.Command();
|
|
@@ -17,7 +18,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
17
18
|
COMMAND_INVOICE,
|
|
18
19
|
{
|
|
19
20
|
description: "Invoice V3",
|
|
20
|
-
docType: documents_1.
|
|
21
|
+
docType: documents_1.InvoiceV3.name,
|
|
21
22
|
fullText: true,
|
|
22
23
|
},
|
|
23
24
|
],
|
|
@@ -25,7 +26,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
25
26
|
COMMAND_RECEIPT,
|
|
26
27
|
{
|
|
27
28
|
description: "Expense Receipt V4",
|
|
28
|
-
docType: documents_1.
|
|
29
|
+
docType: documents_1.ReceiptV4.name,
|
|
29
30
|
fullText: true,
|
|
30
31
|
},
|
|
31
32
|
],
|
|
@@ -33,7 +34,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
33
34
|
COMMAND_PASSPORT,
|
|
34
35
|
{
|
|
35
36
|
description: "Passport V1",
|
|
36
|
-
docType: documents_1.
|
|
37
|
+
docType: documents_1.PassportV1.name,
|
|
37
38
|
fullText: false,
|
|
38
39
|
},
|
|
39
40
|
],
|
|
@@ -41,7 +42,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
41
42
|
COMMAND_FINANCIAL,
|
|
42
43
|
{
|
|
43
44
|
description: "Financial Document V1 (receipt or invoice)",
|
|
44
|
-
docType: documents_1.
|
|
45
|
+
docType: documents_1.FinancialDocumentV1.name,
|
|
45
46
|
fullText: true,
|
|
46
47
|
},
|
|
47
48
|
],
|
|
@@ -49,7 +50,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
49
50
|
COMMAND_FR_ID_CARD,
|
|
50
51
|
{
|
|
51
52
|
description: "FR ID Card V1",
|
|
52
|
-
docType:
|
|
53
|
+
docType: fr_1.IdCardV1.name,
|
|
53
54
|
fullText: false,
|
|
54
55
|
},
|
|
55
56
|
],
|
|
@@ -57,7 +58,7 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
57
58
|
COMMAND_CUSTOM,
|
|
58
59
|
{
|
|
59
60
|
description: "A custom document",
|
|
60
|
-
docType: documents_1.
|
|
61
|
+
docType: documents_1.CustomV1.name,
|
|
61
62
|
fullText: false,
|
|
62
63
|
},
|
|
63
64
|
],
|
|
@@ -105,7 +106,7 @@ async function predictCall(command, inputPath, options) {
|
|
|
105
106
|
response = await doc.parse(documents_1.PassportV1, predictParams);
|
|
106
107
|
break;
|
|
107
108
|
case COMMAND_FR_ID_CARD:
|
|
108
|
-
response = await doc.parse(
|
|
109
|
+
response = await doc.parse(fr_1.IdCardV1, predictParams);
|
|
109
110
|
break;
|
|
110
111
|
case COMMAND_CUSTOM:
|
|
111
112
|
response = await doc.parse(documents_1.CustomV1, predictParams);
|
package/src/client.js
CHANGED
|
@@ -97,7 +97,7 @@ class Client {
|
|
|
97
97
|
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.CropperV1.name], new documentConfig_1.DocumentConfig(documents_1.CropperV1, [
|
|
98
98
|
new api_1.StandardEndpoint("cropper", "1", this.apiKey),
|
|
99
99
|
]));
|
|
100
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.IdCardV1.name], new documentConfig_1.DocumentConfig(documents_1.IdCardV1, [
|
|
100
|
+
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.IdCardV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.IdCardV1, [
|
|
101
101
|
new api_1.StandardEndpoint("idcard_fr", "1", this.apiKey),
|
|
102
102
|
]));
|
|
103
103
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IdCardV1 } from "./idCard/idCardV1";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdCardV1 = void 0;
|
|
4
|
+
var idCardV1_1 = require("./idCard/idCardV1");
|
|
5
|
+
Object.defineProperty(exports, "IdCardV1", { enumerable: true, get: function () { return idCardV1_1.IdCardV1; } });
|
package/src/documents/index.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { IdCardV1 } from "./fr/idCard/idCardV1";
|
|
1
|
+
export { InvoiceV3 } from "./invoice/invoiceV3";
|
|
2
|
+
export { ReceiptV3 } from "./receipt/receiptV3";
|
|
3
|
+
export { ReceiptV4 } from "./receipt/receiptV4";
|
|
4
|
+
export { PassportV1 } from "./passport/passportV1";
|
|
5
|
+
export { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1";
|
|
6
|
+
export { CustomV1 } from "./custom";
|
|
7
|
+
export { CropperV1 } from "./cropper/cropperV1";
|
|
9
8
|
export { Document, DocumentConstructorProps, DocumentSig } from "./document";
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export declare const DOC_TYPE_INVOICE_V3: string;
|
|
13
|
-
export declare const DOC_TYPE_RECEIPT_V3: string;
|
|
14
|
-
export declare const DOC_TYPE_RECEIPT_V4: string;
|
|
15
|
-
export declare const DOC_TYPE_PASSPORT_V1: string;
|
|
16
|
-
export declare const DOC_TYPE_FINANCIAL_V1: string;
|
|
17
|
-
export declare const DOC_TYPE_CROPPER_V1: string;
|
|
18
|
-
export declare const DOC_TYPE_IDCARD_V1: string;
|
|
9
|
+
export * as fr from "./fr";
|
|
10
|
+
export * as us from "./us";
|
package/src/documents/index.js
CHANGED
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
26
|
+
exports.us = exports.fr = exports.Document = exports.CropperV1 = exports.CustomV1 = exports.FinancialDocumentV1 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.InvoiceV3 = void 0;
|
|
27
|
+
var invoiceV3_1 = require("./invoice/invoiceV3");
|
|
5
28
|
Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
|
|
6
|
-
|
|
29
|
+
var receiptV3_1 = require("./receipt/receiptV3");
|
|
7
30
|
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return receiptV3_1.ReceiptV3; } });
|
|
8
|
-
|
|
31
|
+
var receiptV4_1 = require("./receipt/receiptV4");
|
|
9
32
|
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return receiptV4_1.ReceiptV4; } });
|
|
10
|
-
|
|
33
|
+
var passportV1_1 = require("./passport/passportV1");
|
|
11
34
|
Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } });
|
|
12
|
-
|
|
35
|
+
var financialDocumentV1_1 = require("./financialDocument/financialDocumentV1");
|
|
13
36
|
Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return financialDocumentV1_1.FinancialDocumentV1; } });
|
|
14
|
-
|
|
37
|
+
var custom_1 = require("./custom");
|
|
15
38
|
Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return custom_1.CustomV1; } });
|
|
16
|
-
|
|
39
|
+
var cropperV1_1 = require("./cropper/cropperV1");
|
|
17
40
|
Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return cropperV1_1.CropperV1; } });
|
|
18
|
-
const idCardV1_1 = require("./fr/idCard/idCardV1");
|
|
19
|
-
Object.defineProperty(exports, "IdCardV1", { enumerable: true, get: function () { return idCardV1_1.IdCardV1; } });
|
|
20
41
|
var document_1 = require("./document");
|
|
21
42
|
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.DOC_TYPE_RECEIPT_V3 = receiptV3_1.ReceiptV3.name;
|
|
25
|
-
exports.DOC_TYPE_RECEIPT_V4 = receiptV4_1.ReceiptV4.name;
|
|
26
|
-
exports.DOC_TYPE_PASSPORT_V1 = passportV1_1.PassportV1.name;
|
|
27
|
-
exports.DOC_TYPE_FINANCIAL_V1 = financialDocumentV1_1.FinancialDocumentV1.name;
|
|
28
|
-
exports.DOC_TYPE_CROPPER_V1 = cropperV1_1.CropperV1.name;
|
|
29
|
-
exports.DOC_TYPE_IDCARD_V1 = idCardV1_1.IdCardV1.name;
|
|
43
|
+
exports.fr = __importStar(require("./fr"));
|
|
44
|
+
exports.us = __importStar(require("./us"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BankCheckV1 } from "./bankCheck/bankCheckV1";
|
|
@@ -0,0 +1,5 @@
|
|
|
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; } });
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CustomV1, FinancialDocumentV1, InvoiceV3, PassportV1, ReceiptV3, ReceiptV4, CropperV1,
|
|
1
|
+
export { CustomV1, FinancialDocumentV1, InvoiceV3, PassportV1, ReceiptV3, ReceiptV4, CropperV1, fr, us, } from "./documents";
|
|
2
2
|
export { Client } from "./client";
|
|
3
3
|
export { PageOptionsOperation } from "./inputs";
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageOptionsOperation = exports.Client = exports.
|
|
3
|
+
exports.PageOptionsOperation = exports.Client = exports.us = exports.fr = exports.CropperV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PassportV1 = exports.InvoiceV3 = exports.FinancialDocumentV1 = exports.CustomV1 = void 0;
|
|
4
4
|
var documents_1 = require("./documents");
|
|
5
5
|
Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return documents_1.CustomV1; } });
|
|
6
6
|
Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return documents_1.FinancialDocumentV1; } });
|
|
@@ -9,7 +9,8 @@ Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function (
|
|
|
9
9
|
Object.defineProperty(exports, "ReceiptV3", { enumerable: true, get: function () { return documents_1.ReceiptV3; } });
|
|
10
10
|
Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return documents_1.ReceiptV4; } });
|
|
11
11
|
Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return documents_1.CropperV1; } });
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "fr", { enumerable: true, get: function () { return documents_1.fr; } });
|
|
13
|
+
Object.defineProperty(exports, "us", { enumerable: true, get: function () { return documents_1.us; } });
|
|
13
14
|
var client_1 = require("./client");
|
|
14
15
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
15
16
|
var inputs_1 = require("./inputs");
|