mindee 4.8.2 → 4.9.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 +17 -0
- package/README.md +6 -3
- package/package.json +1 -1
- package/src/cli.js +40 -0
- package/src/errors/handler.d.ts +4 -2
- package/src/errors/handler.js +5 -1
- package/src/errors/index.d.ts +1 -1
- package/src/errors/index.js +3 -3
- package/src/errors/{MindeeError.d.ts → mindeeError.d.ts} +6 -0
- package/src/errors/{MindeeError.js → mindeeError.js} +6 -0
- package/src/http/apiSettings.js +1 -0
- package/src/http/endpoint.js +11 -16
- package/src/http/error.d.ts +1 -1
- package/src/http/error.js +7 -3
- package/src/http/index.d.ts +1 -0
- package/src/http/index.js +5 -1
- package/src/http/responseValidation.d.ts +23 -0
- package/src/http/responseValidation.js +66 -0
- package/src/input/pageOptions.d.ts +6 -2
- package/src/input/pageOptions.js +3 -1
- package/src/internal.d.ts +5 -3
- package/src/internal.js +6 -4
- package/src/parsing/common/asyncPredictResponse.d.ts +2 -0
- package/src/product/barcodeReader/barcodeReaderV1.js +6 -1
- package/src/product/cropper/cropperV1.js +6 -1
- package/src/product/eu/driverLicense/driverLicenseV1.d.ts +17 -0
- package/src/product/eu/driverLicense/driverLicenseV1.js +28 -0
- package/src/product/eu/driverLicense/driverLicenseV1Document.d.ts +36 -0
- package/src/product/eu/driverLicense/driverLicenseV1Document.js +79 -0
- package/src/product/eu/driverLicense/driverLicenseV1Page.d.ts +14 -0
- package/src/product/eu/driverLicense/driverLicenseV1Page.js +29 -0
- package/src/product/eu/driverLicense/internal.d.ts +2 -0
- package/src/product/eu/driverLicense/internal.js +7 -0
- package/src/product/eu/index.d.ts +1 -0
- package/src/product/eu/index.js +3 -1
- package/src/product/eu/internal.d.ts +1 -0
- package/src/product/eu/internal.js +2 -1
- package/src/product/eu/licensePlate/licensePlateV1.js +6 -1
- package/src/product/financialDocument/financialDocumentV1.js +6 -1
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +6 -1
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +6 -1
- package/src/product/fr/carteGrise/carteGriseV1.js +6 -1
- package/src/product/fr/carteVitale/carteVitaleV1.js +6 -1
- package/src/product/fr/idCard/idCardV1.js +6 -1
- package/src/product/fr/idCard/idCardV2.js +6 -1
- package/src/product/index.d.ts +3 -0
- package/src/product/index.js +7 -1
- package/src/product/internal.d.ts +2 -0
- package/src/product/internal.js +3 -1
- package/src/product/internationalId/internal.d.ts +4 -0
- package/src/product/internationalId/internal.js +11 -0
- package/src/product/internationalId/internationalIdV1.d.ts +16 -0
- package/src/product/internationalId/internationalIdV1.js +27 -0
- package/src/product/internationalId/internationalIdV1Document.d.ts +42 -0
- package/src/product/internationalId/internationalIdV1Document.js +101 -0
- package/src/product/internationalId/internationalIdV2.d.ts +16 -0
- package/src/product/internationalId/internationalIdV2.js +27 -0
- package/src/product/internationalId/internationalIdV2Document.d.ts +46 -0
- package/src/product/internationalId/internationalIdV2Document.js +111 -0
- package/src/product/invoice/invoiceV4.js +6 -1
- package/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.js +6 -1
- package/src/product/passport/passportV1.js +6 -1
- package/src/product/proofOfAddress/proofOfAddressV1.js +6 -1
- package/src/product/receipt/receiptV5.js +6 -1
- package/src/product/resume/internal.d.ts +7 -0
- package/src/product/resume/internal.js +17 -0
- package/src/product/resume/resumeV1.d.ts +16 -0
- package/src/product/resume/resumeV1.js +27 -0
- package/src/product/resume/resumeV1Certificate.d.ts +34 -0
- package/src/product/resume/resumeV1Certificate.js +87 -0
- package/src/product/resume/resumeV1Document.d.ts +51 -0
- package/src/product/resume/resumeV1Document.js +197 -0
- package/src/product/resume/resumeV1Education.d.ts +40 -0
- package/src/product/resume/resumeV1Education.js +117 -0
- package/src/product/resume/resumeV1Language.d.ts +30 -0
- package/src/product/resume/resumeV1Language.js +67 -0
- package/src/product/resume/resumeV1ProfessionalExperience.d.ts +42 -0
- package/src/product/resume/resumeV1ProfessionalExperience.js +127 -0
- package/src/product/resume/resumeV1SocialNetworksUrl.d.ts +30 -0
- package/src/product/resume/resumeV1SocialNetworksUrl.js +67 -0
- package/src/product/us/bankCheck/bankCheckV1.js +6 -1
- package/src/product/us/driverLicense/driverLicenseV1.js +6 -1
- package/src/product/us/w9/w9V1.js +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v4.9.1 - 2024-03-05
|
|
4
|
+
### Changes
|
|
5
|
+
* :recycle: update error handling to account for future evolutions
|
|
6
|
+
* :recycle: expose the input, geometry & imageOperations modules in internals for better fine-tuning
|
|
7
|
+
* :recycle: fix inconsistencies with naming conventions
|
|
8
|
+
* :memo: add missing reference documentation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## v4.9.0 - 2024-02-21
|
|
12
|
+
### Changes
|
|
13
|
+
* :sparkles: add support for resume V1
|
|
14
|
+
* :sparkles: add support for International ID v2
|
|
15
|
+
* :sparkles: add support for EU Driver License V1
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
:memo: misc doc fixes
|
|
19
|
+
|
|
3
20
|
## v4.8.2 - 2024-02-09
|
|
4
21
|
### Changes
|
|
5
22
|
* :recycle: increased update time for async retries
|
package/README.md
CHANGED
|
@@ -147,17 +147,20 @@ Complete details on the working of the library are available in the following gu
|
|
|
147
147
|
* [Node.js Generated API](https://developers.mindee.com/docs/nodejs-generated-api)
|
|
148
148
|
* [Node.js Custom OCR](https://developers.mindee.com/docs/nodejs-api-builder)
|
|
149
149
|
* [Node.js Invoice OCR](https://developers.mindee.com/docs/nodejs-invoice-ocr)
|
|
150
|
+
* [Node.js International Id OCR](https://developers.mindee.com/docs/nodejs-international-id-ocr)
|
|
150
151
|
* [Node.js Receipt OCR](https://developers.mindee.com/docs/nodejs-receipt-ocr)
|
|
152
|
+
* [Node.js Resume OCR](https://developers.mindee.com/docs/nodejs-resume-ocr)
|
|
151
153
|
* [Node.js Financial Document OCR](https://developers.mindee.com/docs/nodejs-financial-document-ocr)
|
|
152
154
|
* [Node.js Passport OCR](https://developers.mindee.com/docs/nodejs-passport-ocr)
|
|
153
155
|
* [Node.js Proof of Address OCR](https://developers.mindee.com/docs/nodejs-proof-of-address-ocr)
|
|
154
156
|
* [Node.js EU License Plate OCR](https://developers.mindee.com/docs/nodejs-eu-license-plates-ocr)
|
|
157
|
+
* [Node.js EU Driver License OCR](https://developers.mindee.com/docs/nodejs-eu-driver-license-ocr)
|
|
155
158
|
* [Node.js FR Bank Account Detail OCR](https://developers.mindee.com/docs/nodejs-fr-bank-account-details-ocr)
|
|
156
159
|
* [Node.js FR Carte Vitale OCR](https://developers.mindee.com/docs/nodejs-fr-carte-vitale-ocr)
|
|
157
160
|
* [Node.js FR ID Card OCR](https://developers.mindee.com/docs/nodejs-fr-id-card-ocr)
|
|
158
161
|
* [Node.js US Bank Check OCR](https://developers.mindee.com/docs/nodejs-us-bank-checks-ocr)
|
|
159
|
-
* [Node.js US W9 OCR](https://developers.mindee.com/docs/nodejs-us-
|
|
160
|
-
* [Node.js US Driver License OCR](https://developers.mindee.com/docs/nodejs-us-
|
|
162
|
+
* [Node.js US W9 OCR](https://developers.mindee.com/docs/nodejs-us-w9-ocr)
|
|
163
|
+
* [Node.js US Driver License OCR](https://developers.mindee.com/docs/nodejs-us-driver-license-ocr)
|
|
161
164
|
* [Node.js Barcode Reader API](https://developers.mindee.com/docs/nodejs-barcode-reader-api)
|
|
162
165
|
* [Node.js Cropper API](https://developers.mindee.com/docs/nodejs-cropper-api)
|
|
163
166
|
* [Node.js Invoice Splitter API](https://developers.mindee.com/docs/nodejs-invoice-splitter-api)
|
|
@@ -171,4 +174,4 @@ Copyright © Mindee
|
|
|
171
174
|
Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
172
175
|
|
|
173
176
|
## Questions?
|
|
174
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-
|
|
177
|
+
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -68,6 +68,16 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
68
68
|
sync: true,
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
|
+
[
|
|
72
|
+
"international-id",
|
|
73
|
+
{
|
|
74
|
+
displayName: "International Id",
|
|
75
|
+
docClass: product.InternationalIdV2,
|
|
76
|
+
allWords: false,
|
|
77
|
+
async: true,
|
|
78
|
+
sync: false,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
71
81
|
[
|
|
72
82
|
"invoice",
|
|
73
83
|
{
|
|
@@ -98,6 +108,16 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
98
108
|
sync: true,
|
|
99
109
|
},
|
|
100
110
|
],
|
|
111
|
+
[
|
|
112
|
+
"resume",
|
|
113
|
+
{
|
|
114
|
+
displayName: "Resume",
|
|
115
|
+
docClass: product.ResumeV1,
|
|
116
|
+
allWords: false,
|
|
117
|
+
async: true,
|
|
118
|
+
sync: false,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
101
121
|
[
|
|
102
122
|
"passport",
|
|
103
123
|
{
|
|
@@ -158,6 +178,16 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
158
178
|
sync: true,
|
|
159
179
|
},
|
|
160
180
|
],
|
|
181
|
+
[
|
|
182
|
+
"eu-driver-license",
|
|
183
|
+
{
|
|
184
|
+
displayName: "EU Driver License",
|
|
185
|
+
docClass: product.eu.DriverLicenseV1,
|
|
186
|
+
allWords: false,
|
|
187
|
+
async: false,
|
|
188
|
+
sync: true,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
161
191
|
[
|
|
162
192
|
"us-bank-check",
|
|
163
193
|
{
|
|
@@ -168,6 +198,16 @@ const CLI_COMMAND_CONFIG = new Map([
|
|
|
168
198
|
sync: true,
|
|
169
199
|
},
|
|
170
200
|
],
|
|
201
|
+
[
|
|
202
|
+
"us-driver-license",
|
|
203
|
+
{
|
|
204
|
+
displayName: "US Driver License",
|
|
205
|
+
docClass: product.us.DriverLicenseV1,
|
|
206
|
+
allWords: false,
|
|
207
|
+
async: false,
|
|
208
|
+
sync: true,
|
|
209
|
+
},
|
|
210
|
+
],
|
|
171
211
|
]);
|
|
172
212
|
//
|
|
173
213
|
// EXECUTE THE COMMANDS
|
package/src/errors/handler.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error handling class.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ErrorHandler {
|
|
2
5
|
throwOnError: boolean;
|
|
3
6
|
constructor(throwOnError?: boolean);
|
|
4
7
|
throw(error: Error): void;
|
|
5
8
|
}
|
|
6
9
|
export declare const errorHandler: ErrorHandler;
|
|
7
|
-
export {};
|
package/src/errors/handler.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorHandler = void 0;
|
|
3
|
+
exports.errorHandler = exports.ErrorHandler = void 0;
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
|
+
/**
|
|
6
|
+
* Custom Error handling class.
|
|
7
|
+
*/
|
|
5
8
|
class ErrorHandler {
|
|
6
9
|
constructor(throwOnError = true) {
|
|
7
10
|
this.throwOnError = throwOnError;
|
|
@@ -15,4 +18,5 @@ class ErrorHandler {
|
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
}
|
|
21
|
+
exports.ErrorHandler = ErrorHandler;
|
|
18
22
|
exports.errorHandler = new ErrorHandler();
|
package/src/errors/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MindeeError, MindeeMimeTypeError } from "./
|
|
1
|
+
export { MindeeError, MindeeMimeTypeError } from "./mindeeError";
|
package/src/errors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MindeeMimeTypeError = exports.MindeeError = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "MindeeError", { enumerable: true, get: function () { return
|
|
6
|
-
Object.defineProperty(exports, "MindeeMimeTypeError", { enumerable: true, get: function () { return
|
|
4
|
+
var mindeeError_1 = require("./mindeeError");
|
|
5
|
+
Object.defineProperty(exports, "MindeeError", { enumerable: true, get: function () { return mindeeError_1.MindeeError; } });
|
|
6
|
+
Object.defineProperty(exports, "MindeeMimeTypeError", { enumerable: true, get: function () { return mindeeError_1.MindeeMimeTypeError; } });
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Mindee Error custom class.
|
|
3
|
+
*/
|
|
1
4
|
export declare class MindeeError extends Error {
|
|
2
5
|
constructor(message: string);
|
|
3
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Custom Mindee error relating to improper mimetypes in inputs.
|
|
9
|
+
*/
|
|
4
10
|
export declare class MindeeMimeTypeError extends MindeeError {
|
|
5
11
|
constructor(message: string);
|
|
6
12
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MindeeMimeTypeError = exports.MindeeError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Main Mindee Error custom class.
|
|
6
|
+
*/
|
|
4
7
|
class MindeeError extends Error {
|
|
5
8
|
constructor(message) {
|
|
6
9
|
super(message);
|
|
@@ -8,6 +11,9 @@ class MindeeError extends Error {
|
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
exports.MindeeError = MindeeError;
|
|
14
|
+
/**
|
|
15
|
+
* Custom Mindee error relating to improper mimetypes in inputs.
|
|
16
|
+
*/
|
|
11
17
|
class MindeeMimeTypeError extends MindeeError {
|
|
12
18
|
constructor(message) {
|
|
13
19
|
super(message);
|
package/src/http/apiSettings.js
CHANGED
|
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ApiSettings = exports.STANDARD_API_OWNER = exports.API_HOST_ENVVAR_NAME = exports.API_KEY_ENVVAR_NAME = void 0;
|
|
27
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
27
28
|
const logger_1 = require("../logger");
|
|
28
29
|
const package_json_1 = require("../../package.json");
|
|
29
30
|
const os = __importStar(require("os"));
|
package/src/http/endpoint.js
CHANGED
|
@@ -15,6 +15,7 @@ const form_data_1 = __importDefault(require("form-data"));
|
|
|
15
15
|
const base_1 = require("../input/base");
|
|
16
16
|
const error_1 = require("./error");
|
|
17
17
|
const baseEndpoint_1 = require("./baseEndpoint");
|
|
18
|
+
const responseValidation_1 = require("./responseValidation");
|
|
18
19
|
/**
|
|
19
20
|
* Endpoint for a product (OTS or Custom).
|
|
20
21
|
*/
|
|
@@ -40,9 +41,8 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
|
|
|
40
41
|
await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_cutDocPages).call(this, params.inputDoc, params.pageOptions);
|
|
41
42
|
}
|
|
42
43
|
const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictReqPost).call(this, params.inputDoc, params.includeWords, params.cropper);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(0, error_1.handleError)(this.urlName, response, statusCode, response.messageObj?.statusMessage);
|
|
44
|
+
if (!(0, responseValidation_1.isValidSyncResponse)(response)) {
|
|
45
|
+
(0, error_1.handleError)(this.urlName, response, response.messageObj?.statusMessage);
|
|
46
46
|
}
|
|
47
47
|
return response;
|
|
48
48
|
}
|
|
@@ -59,9 +59,8 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
|
|
|
59
59
|
await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_cutDocPages).call(this, params.inputDoc, params.pageOptions);
|
|
60
60
|
}
|
|
61
61
|
const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_predictAsyncReqPost).call(this, params.inputDoc, params.includeWords, params.cropper);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(0, error_1.handleError)(this.urlName, response, statusCode, response.messageObj?.statusMessage);
|
|
62
|
+
if (!(0, responseValidation_1.isValidAsyncResponse)(response)) {
|
|
63
|
+
(0, error_1.handleError)(this.urlName, response, response.messageObj?.statusMessage);
|
|
65
64
|
}
|
|
66
65
|
return response;
|
|
67
66
|
}
|
|
@@ -75,10 +74,8 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
|
|
|
75
74
|
async getQueuedDocument(queueId) {
|
|
76
75
|
const queueResponse = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentQueueReqGet).call(this, queueId);
|
|
77
76
|
const queueStatusCode = queueResponse.messageObj.statusCode;
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
queueStatusCode > 400) {
|
|
81
|
-
(0, error_1.handleError)(this.urlName, queueResponse, queueStatusCode, queueResponse.messageObj?.statusMessage);
|
|
77
|
+
if (!(0, responseValidation_1.isValidAsyncResponse)(queueResponse)) {
|
|
78
|
+
(0, error_1.handleError)(this.urlName, queueResponse, queueResponse.messageObj?.statusMessage);
|
|
82
79
|
}
|
|
83
80
|
if (queueStatusCode === 302 &&
|
|
84
81
|
queueResponse.messageObj.headers.location !== undefined) {
|
|
@@ -95,9 +92,8 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
|
|
|
95
92
|
*/
|
|
96
93
|
async getDocument(documentId) {
|
|
97
94
|
const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentGetReq).call(this, documentId);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(0, error_1.handleError)("document", response, statusCode, response.messageObj?.statusMessage);
|
|
95
|
+
if (!(0, responseValidation_1.isValidAsyncResponse)(response)) {
|
|
96
|
+
(0, error_1.handleError)("document", response, response.messageObj?.statusMessage);
|
|
101
97
|
}
|
|
102
98
|
return response;
|
|
103
99
|
}
|
|
@@ -108,9 +104,8 @@ class Endpoint extends baseEndpoint_1.BaseEndpoint {
|
|
|
108
104
|
*/
|
|
109
105
|
async sendFeedback(documentId, feedback) {
|
|
110
106
|
const response = await __classPrivateFieldGet(this, _Endpoint_instances, "m", _Endpoint_documentFeedbackPutReq).call(this, documentId, feedback);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
(0, error_1.handleError)("feedback", response, statusCode, response.messageObj?.statusMessage);
|
|
107
|
+
if (!(0, responseValidation_1.isValidSyncResponse)(response)) {
|
|
108
|
+
(0, error_1.handleError)("feedback", response, response.messageObj?.statusMessage);
|
|
114
109
|
}
|
|
115
110
|
return response;
|
|
116
111
|
}
|
package/src/http/error.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MindeeError } from "../errors";
|
|
2
2
|
import { StringDict } from "../parsing/common";
|
|
3
3
|
import { EndpointResponse } from "./baseEndpoint";
|
|
4
|
-
export declare function handleError(urlName: string, response: EndpointResponse,
|
|
4
|
+
export declare function handleError(urlName: string, response: EndpointResponse, serverError?: string): void;
|
|
5
5
|
/**
|
|
6
6
|
* `Error` wrapper for server (HTTP) errors.
|
|
7
7
|
* Is used when an error is lacking a handled error code.
|
package/src/http/error.js
CHANGED
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = exports.handleError = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
const handler_1 = require("../errors/handler");
|
|
6
|
-
function handleError(urlName, response,
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function handleError(urlName, response, serverError) {
|
|
7
|
+
let code;
|
|
8
|
+
if (response.messageObj.statusCode && !Number.isNaN(response.data.statusCode)) {
|
|
9
|
+
code = response.messageObj.statusCode;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
code = 500;
|
|
9
13
|
}
|
|
10
14
|
let errorObj;
|
|
11
15
|
try {
|
package/src/http/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { Endpoint } from "./endpoint";
|
|
|
2
2
|
export { EndpointResponse } from "./baseEndpoint";
|
|
3
3
|
export { STANDARD_API_OWNER, API_KEY_ENVVAR_NAME, ApiSettings, } from "./apiSettings";
|
|
4
4
|
export { MindeeHttpError, MindeeHttp400Error, MindeeHttp401Error, MindeeHttp403Error, MindeeHttp404Error, MindeeHttp413Error, MindeeHttp429Error, MindeeHttp500Error, MindeeHttp504Error, handleError, } from "./error";
|
|
5
|
+
export { isValidSyncResponse, isValidAsyncResponse, cleanRequestData, } from "./responseValidation";
|
package/src/http/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleError = exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = exports.ApiSettings = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = exports.Endpoint = void 0;
|
|
3
|
+
exports.cleanRequestData = exports.isValidAsyncResponse = exports.isValidSyncResponse = exports.handleError = exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = exports.ApiSettings = exports.API_KEY_ENVVAR_NAME = exports.STANDARD_API_OWNER = exports.Endpoint = void 0;
|
|
4
4
|
var endpoint_1 = require("./endpoint");
|
|
5
5
|
Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return endpoint_1.Endpoint; } });
|
|
6
6
|
var apiSettings_1 = require("./apiSettings");
|
|
@@ -18,3 +18,7 @@ Object.defineProperty(exports, "MindeeHttp429Error", { enumerable: true, get: fu
|
|
|
18
18
|
Object.defineProperty(exports, "MindeeHttp500Error", { enumerable: true, get: function () { return error_1.MindeeHttp500Error; } });
|
|
19
19
|
Object.defineProperty(exports, "MindeeHttp504Error", { enumerable: true, get: function () { return error_1.MindeeHttp504Error; } });
|
|
20
20
|
Object.defineProperty(exports, "handleError", { enumerable: true, get: function () { return error_1.handleError; } });
|
|
21
|
+
var responseValidation_1 = require("./responseValidation");
|
|
22
|
+
Object.defineProperty(exports, "isValidSyncResponse", { enumerable: true, get: function () { return responseValidation_1.isValidSyncResponse; } });
|
|
23
|
+
Object.defineProperty(exports, "isValidAsyncResponse", { enumerable: true, get: function () { return responseValidation_1.isValidAsyncResponse; } });
|
|
24
|
+
Object.defineProperty(exports, "cleanRequestData", { enumerable: true, get: function () { return responseValidation_1.cleanRequestData; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EndpointResponse } from "./baseEndpoint";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the synchronous response is valid. Returns True if the response is valid.
|
|
4
|
+
*
|
|
5
|
+
* @param response an endpoint response object.
|
|
6
|
+
* @returns bool
|
|
7
|
+
*/
|
|
8
|
+
export declare function isValidSyncResponse(response: EndpointResponse): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the asynchronous response is valid. Also checks if it is a valid synchronous response.
|
|
11
|
+
* Returns True if the response is valid.
|
|
12
|
+
*
|
|
13
|
+
* @param response an endpoint response object.
|
|
14
|
+
* @returns bool
|
|
15
|
+
*/
|
|
16
|
+
export declare function isValidAsyncResponse(response: EndpointResponse): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks and correct the response object depending on the possible kinds of returns.
|
|
19
|
+
*
|
|
20
|
+
* @param response an endpoint response object.
|
|
21
|
+
* @returns EndpointResponse Returns the job error if the error is due to parsing, returns the http error otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export declare function cleanRequestData(response: EndpointResponse): EndpointResponse;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanRequestData = exports.isValidAsyncResponse = exports.isValidSyncResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the synchronous response is valid. Returns True if the response is valid.
|
|
6
|
+
*
|
|
7
|
+
* @param response an endpoint response object.
|
|
8
|
+
* @returns bool
|
|
9
|
+
*/
|
|
10
|
+
function isValidSyncResponse(response) {
|
|
11
|
+
if (!response.messageObj || !response.messageObj.statusCode) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return !(isNaN(response.messageObj.statusCode) || parseInt(response.messageObj.statusCode.toString()) < 200 || parseInt(response.messageObj.statusCode.toString()) > 302);
|
|
15
|
+
}
|
|
16
|
+
exports.isValidSyncResponse = isValidSyncResponse;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the asynchronous response is valid. Also checks if it is a valid synchronous response.
|
|
19
|
+
* Returns True if the response is valid.
|
|
20
|
+
*
|
|
21
|
+
* @param response an endpoint response object.
|
|
22
|
+
* @returns bool
|
|
23
|
+
*/
|
|
24
|
+
function isValidAsyncResponse(response) {
|
|
25
|
+
if (!isValidSyncResponse(response)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (response.messageObj.statusCode) {
|
|
29
|
+
if (response.messageObj.statusCode >= 300 && response.messageObj.statusCode <= 302) {
|
|
30
|
+
// Skip next check for redirections as the final payload will be checked anyway.
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
else if (response.messageObj.statusCode < 200 || response.messageObj.statusCode > 302) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!response.data["job"]) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return !(response.data["job"] && response.data["job"]["error"] && Object.keys(response.data["job"]["error"]).length > 0);
|
|
41
|
+
}
|
|
42
|
+
exports.isValidAsyncResponse = isValidAsyncResponse;
|
|
43
|
+
/**
|
|
44
|
+
* Checks and correct the response object depending on the possible kinds of returns.
|
|
45
|
+
*
|
|
46
|
+
* @param response an endpoint response object.
|
|
47
|
+
* @returns EndpointResponse Returns the job error if the error is due to parsing, returns the http error otherwise.
|
|
48
|
+
*/
|
|
49
|
+
function cleanRequestData(response) {
|
|
50
|
+
if (response.messageObj &&
|
|
51
|
+
response.messageObj.statusCode &&
|
|
52
|
+
(response.messageObj.statusCode < 200 ||
|
|
53
|
+
response.messageObj.statusCode > 302)) {
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
if (response.data) {
|
|
57
|
+
if (response.data["api_request"] && response.data["api_request"]["status_code"] && parseInt(response.data["api_request"]["status_code"].toString()) > 399) {
|
|
58
|
+
response.messageObj.statusCode = parseInt(response.data["api_request"]["status_code"].toString());
|
|
59
|
+
}
|
|
60
|
+
if (response.data["job"] && response.data["job"]["error"] && Object.keys(response.data["job"]["error"]).length > 0) {
|
|
61
|
+
response.messageObj.statusCode = 500;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
exports.cleanRequestData = cleanRequestData;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Options to pass to the `parse` method for cutting multi-page documents.
|
|
3
|
+
*/
|
|
2
4
|
export interface PageOptions {
|
|
3
5
|
/**
|
|
4
6
|
* Zero-based list of page indexes.
|
|
@@ -15,7 +17,9 @@ export interface PageOptions {
|
|
|
15
17
|
*/
|
|
16
18
|
onMinPages: number;
|
|
17
19
|
}
|
|
18
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Operation to apply on the document, given the page indexes specified.
|
|
22
|
+
*/
|
|
19
23
|
export declare enum PageOptionsOperation {
|
|
20
24
|
/** Only keep pages matching the provided indexes. */
|
|
21
25
|
KeepOnly = "KEEP_ONLY",
|
package/src/input/pageOptions.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PageOptionsOperation = void 0;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Operation to apply on the document, given the page indexes specified.
|
|
6
|
+
*/
|
|
5
7
|
var PageOptionsOperation;
|
|
6
8
|
(function (PageOptionsOperation) {
|
|
7
9
|
/** Only keep pages matching the provided indexes. */
|
package/src/internal.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export * as
|
|
2
|
-
export * as parsing from "./parsing";
|
|
3
|
-
export * as pdf from "./pdf";
|
|
1
|
+
export * as input from "./input";
|
|
4
2
|
export * as geometry from "./geometry";
|
|
5
3
|
export * as http from "./http";
|
|
4
|
+
export * as imageOperations from "./imageOperations/internal";
|
|
5
|
+
export * as parsing from "./parsing";
|
|
6
|
+
export * as pdf from "./pdf";
|
|
7
|
+
export * as product from "./product/internal";
|
package/src/internal.js
CHANGED
|
@@ -23,9 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
28
|
-
exports.parsing = __importStar(require("./parsing"));
|
|
29
|
-
exports.pdf = __importStar(require("./pdf"));
|
|
26
|
+
exports.product = exports.pdf = exports.parsing = exports.imageOperations = exports.http = exports.geometry = exports.input = void 0;
|
|
27
|
+
exports.input = __importStar(require("./input"));
|
|
30
28
|
exports.geometry = __importStar(require("./geometry"));
|
|
31
29
|
exports.http = __importStar(require("./http"));
|
|
30
|
+
exports.imageOperations = __importStar(require("./imageOperations/internal"));
|
|
31
|
+
exports.parsing = __importStar(require("./parsing"));
|
|
32
|
+
exports.pdf = __importStar(require("./pdf"));
|
|
33
|
+
exports.product = __importStar(require("./product/internal"));
|
|
@@ -12,6 +12,8 @@ export declare class Job {
|
|
|
12
12
|
issuedAt: Date;
|
|
13
13
|
/** Timestamp noting the availability of a prediction for an enqueued document. */
|
|
14
14
|
availableAt?: Date;
|
|
15
|
+
/** Information about an error that occurred during the job processing. */
|
|
16
|
+
error?: StringDict;
|
|
15
17
|
/** ID of the job. */
|
|
16
18
|
id: string;
|
|
17
19
|
/** Status of the job. */
|
|
@@ -16,7 +16,12 @@ class BarcodeReaderV1 extends common_1.Inference {
|
|
|
16
16
|
/** The document's pages. */
|
|
17
17
|
this.pages = [];
|
|
18
18
|
this.prediction = new barcodeReaderV1Document_1.BarcodeReaderV1Document(rawPrediction["prediction"]);
|
|
19
|
-
|
|
19
|
+
rawPrediction["pages"].forEach((page) => {
|
|
20
|
+
if (page.prediction !== undefined && page.prediction !== null &&
|
|
21
|
+
Object.keys(page.prediction).length > 0) {
|
|
22
|
+
this.pages.push(new common_1.Page(barcodeReaderV1Document_1.BarcodeReaderV1Document, page, page["id"], page["orientation"]));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
exports.BarcodeReaderV1 = BarcodeReaderV1;
|
|
@@ -17,7 +17,12 @@ class CropperV1 extends common_1.Inference {
|
|
|
17
17
|
/** The document's pages. */
|
|
18
18
|
this.pages = [];
|
|
19
19
|
this.prediction = new cropperV1Document_1.CropperV1Document();
|
|
20
|
-
|
|
20
|
+
rawPrediction["pages"].forEach((page) => {
|
|
21
|
+
if (page.prediction !== undefined && page.prediction !== null &&
|
|
22
|
+
Object.keys(page.prediction).length > 0) {
|
|
23
|
+
this.pages.push(new common_1.Page(cropperV1Page_1.CropperV1Page, page, page["id"], page["orientation"]));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
exports.CropperV1 = CropperV1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Inference, StringDict, Page } from "../../../parsing/common";
|
|
2
|
+
import { DriverLicenseV1Document } from "./driverLicenseV1Document";
|
|
3
|
+
import { DriverLicenseV1Page } from "./driverLicenseV1Page";
|
|
4
|
+
/**
|
|
5
|
+
* Inference prediction for Driver License, API version 1.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DriverLicenseV1 extends Inference {
|
|
8
|
+
/** The endpoint's name. */
|
|
9
|
+
endpointName: string;
|
|
10
|
+
/** The endpoint's version. */
|
|
11
|
+
endpointVersion: string;
|
|
12
|
+
/** The document-level prediction. */
|
|
13
|
+
prediction: DriverLicenseV1Document;
|
|
14
|
+
/** The document's pages. */
|
|
15
|
+
pages: Page<DriverLicenseV1Page>[];
|
|
16
|
+
constructor(rawPrediction: StringDict);
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DriverLicenseV1 = void 0;
|
|
4
|
+
const common_1 = require("../../../parsing/common");
|
|
5
|
+
const driverLicenseV1Document_1 = require("./driverLicenseV1Document");
|
|
6
|
+
const driverLicenseV1Page_1 = require("./driverLicenseV1Page");
|
|
7
|
+
/**
|
|
8
|
+
* Inference prediction for Driver License, API version 1.
|
|
9
|
+
*/
|
|
10
|
+
class DriverLicenseV1 extends common_1.Inference {
|
|
11
|
+
constructor(rawPrediction) {
|
|
12
|
+
super(rawPrediction);
|
|
13
|
+
/** The endpoint's name. */
|
|
14
|
+
this.endpointName = "eu_driver_license";
|
|
15
|
+
/** The endpoint's version. */
|
|
16
|
+
this.endpointVersion = "1";
|
|
17
|
+
/** The document's pages. */
|
|
18
|
+
this.pages = [];
|
|
19
|
+
this.prediction = new driverLicenseV1Document_1.DriverLicenseV1Document(rawPrediction["prediction"]);
|
|
20
|
+
rawPrediction["pages"].forEach((page) => {
|
|
21
|
+
if (page.prediction !== undefined && page.prediction !== null &&
|
|
22
|
+
Object.keys(page.prediction).length > 0) {
|
|
23
|
+
this.pages.push(new common_1.Page(driverLicenseV1Page_1.DriverLicenseV1Page, page, page["id"], page["orientation"]));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DriverLicenseV1 = DriverLicenseV1;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Prediction, StringDict } from "../../../parsing/common";
|
|
2
|
+
import { DateField, StringField } from "../../../parsing/standard";
|
|
3
|
+
/**
|
|
4
|
+
* Document data for Driver License, API version 1.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DriverLicenseV1Document implements Prediction {
|
|
7
|
+
/** EU driver license holders address */
|
|
8
|
+
address: StringField;
|
|
9
|
+
/** EU driver license holders categories */
|
|
10
|
+
category: StringField;
|
|
11
|
+
/** Country code extracted as a string. */
|
|
12
|
+
countryCode: StringField;
|
|
13
|
+
/** The date of birth of the document holder */
|
|
14
|
+
dateOfBirth: DateField;
|
|
15
|
+
/** ID number of the Document. */
|
|
16
|
+
documentId: StringField;
|
|
17
|
+
/** Date the document expires */
|
|
18
|
+
expiryDate: DateField;
|
|
19
|
+
/** First name(s) of the driver license holder */
|
|
20
|
+
firstName: StringField;
|
|
21
|
+
/** Authority that issued the document */
|
|
22
|
+
issueAuthority: StringField;
|
|
23
|
+
/** Date the document was issued */
|
|
24
|
+
issueDate: DateField;
|
|
25
|
+
/** Last name of the driver license holder. */
|
|
26
|
+
lastName: StringField;
|
|
27
|
+
/** Machine-readable license number */
|
|
28
|
+
mrz: StringField;
|
|
29
|
+
/** Place where the driver license holder was born */
|
|
30
|
+
placeOfBirth: StringField;
|
|
31
|
+
constructor(rawPrediction: StringDict, pageId?: number);
|
|
32
|
+
/**
|
|
33
|
+
* Default string representation.
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|