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
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.LocalInputSource = exports.InputSource = exports.INPUT_TYPE_BUFFER = exports.INPUT_TYPE_PATH = exports.INPUT_TYPE_BYTES = exports.INPUT_TYPE_BASE64 = exports.INPUT_TYPE_STREAM = void 0;
|
|
27
27
|
const fileType = __importStar(require("file-type"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
const pdf_1 = require("../pdf");
|
|
@@ -33,7 +33,6 @@ exports.INPUT_TYPE_STREAM = "stream";
|
|
|
33
33
|
exports.INPUT_TYPE_BASE64 = "base64";
|
|
34
34
|
exports.INPUT_TYPE_BYTES = "bytes";
|
|
35
35
|
exports.INPUT_TYPE_PATH = "path";
|
|
36
|
-
exports.INPUT_TYPE_URL = "URL";
|
|
37
36
|
exports.INPUT_TYPE_BUFFER = "buffer";
|
|
38
37
|
const MIMETYPES = new Map([
|
|
39
38
|
[".pdf", "application/pdf"],
|
|
@@ -50,10 +49,15 @@ const ALLOWED_INPUT_TYPES = [
|
|
|
50
49
|
exports.INPUT_TYPE_BASE64,
|
|
51
50
|
exports.INPUT_TYPE_BYTES,
|
|
52
51
|
exports.INPUT_TYPE_PATH,
|
|
53
|
-
exports.INPUT_TYPE_URL,
|
|
54
52
|
exports.INPUT_TYPE_BUFFER,
|
|
55
53
|
];
|
|
56
54
|
class InputSource {
|
|
55
|
+
async init() {
|
|
56
|
+
throw new Error("not Implemented");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.InputSource = InputSource;
|
|
60
|
+
class LocalInputSource extends InputSource {
|
|
57
61
|
/**
|
|
58
62
|
* @param {String} inputType - the type of input used in file ("base64", "path", "dummy").
|
|
59
63
|
* NB: dummy is only used for tests purposes
|
|
@@ -61,6 +65,7 @@ class InputSource {
|
|
|
61
65
|
* NB: Because of async calls, init() should be called after creating the object
|
|
62
66
|
*/
|
|
63
67
|
constructor({ inputType }) {
|
|
68
|
+
super();
|
|
64
69
|
this.filename = "";
|
|
65
70
|
this.mimeType = "";
|
|
66
71
|
// Check if inputType is valid
|
|
@@ -71,9 +76,6 @@ class InputSource {
|
|
|
71
76
|
this.inputType = inputType;
|
|
72
77
|
logger_1.logger.debug(`Loading file from: ${inputType}`);
|
|
73
78
|
}
|
|
74
|
-
async init() {
|
|
75
|
-
throw new Error("not Implemented");
|
|
76
|
-
}
|
|
77
79
|
isPdf() {
|
|
78
80
|
return this.mimeType === "application/pdf";
|
|
79
81
|
}
|
|
@@ -115,4 +117,4 @@ class InputSource {
|
|
|
115
117
|
this.fileObject = processedPdf.file;
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
exports.
|
|
120
|
+
exports.LocalInputSource = LocalInputSource;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { PageOptions, PageOptionsOperation } from "./pageOptions";
|
|
2
2
|
export { Base64Input, BytesInput, PathInput, StreamInput, UrlInput, BufferInput, } from "./sources";
|
|
3
|
-
export { InputSource, INPUT_TYPE_BASE64, INPUT_TYPE_BYTES, INPUT_TYPE_PATH, INPUT_TYPE_STREAM,
|
|
3
|
+
export { InputSource, INPUT_TYPE_BASE64, INPUT_TYPE_BYTES, INPUT_TYPE_PATH, INPUT_TYPE_STREAM, INPUT_TYPE_BUFFER, } from "./base";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INPUT_TYPE_BUFFER = exports.
|
|
3
|
+
exports.INPUT_TYPE_BUFFER = exports.INPUT_TYPE_STREAM = exports.INPUT_TYPE_PATH = exports.INPUT_TYPE_BYTES = exports.INPUT_TYPE_BASE64 = exports.InputSource = exports.BufferInput = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.Base64Input = exports.PageOptionsOperation = void 0;
|
|
4
4
|
var pageOptions_1 = require("./pageOptions");
|
|
5
5
|
Object.defineProperty(exports, "PageOptionsOperation", { enumerable: true, get: function () { return pageOptions_1.PageOptionsOperation; } });
|
|
6
6
|
var sources_1 = require("./sources");
|
|
@@ -16,5 +16,4 @@ Object.defineProperty(exports, "INPUT_TYPE_BASE64", { enumerable: true, get: fun
|
|
|
16
16
|
Object.defineProperty(exports, "INPUT_TYPE_BYTES", { enumerable: true, get: function () { return base_1.INPUT_TYPE_BYTES; } });
|
|
17
17
|
Object.defineProperty(exports, "INPUT_TYPE_PATH", { enumerable: true, get: function () { return base_1.INPUT_TYPE_PATH; } });
|
|
18
18
|
Object.defineProperty(exports, "INPUT_TYPE_STREAM", { enumerable: true, get: function () { return base_1.INPUT_TYPE_STREAM; } });
|
|
19
|
-
Object.defineProperty(exports, "INPUT_TYPE_URL", { enumerable: true, get: function () { return base_1.INPUT_TYPE_URL; } });
|
|
20
19
|
Object.defineProperty(exports, "INPUT_TYPE_BUFFER", { enumerable: true, get: function () { return base_1.INPUT_TYPE_BUFFER; } });
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Readable } from "stream";
|
|
4
4
|
import { Buffer } from "buffer";
|
|
5
|
-
import {
|
|
5
|
+
import { LocalInputSource } from "./base";
|
|
6
6
|
interface PathInputProps {
|
|
7
7
|
inputPath: string;
|
|
8
8
|
}
|
|
9
|
-
export declare class PathInput extends
|
|
9
|
+
export declare class PathInput extends LocalInputSource {
|
|
10
10
|
readonly inputPath: string;
|
|
11
11
|
fileObject: Buffer;
|
|
12
12
|
constructor({ inputPath }: PathInputProps);
|
|
@@ -16,7 +16,7 @@ interface Base64InputProps {
|
|
|
16
16
|
inputString: string;
|
|
17
17
|
filename: string;
|
|
18
18
|
}
|
|
19
|
-
export declare class Base64Input extends
|
|
19
|
+
export declare class Base64Input extends LocalInputSource {
|
|
20
20
|
private inputString;
|
|
21
21
|
fileObject: Buffer;
|
|
22
22
|
constructor({ inputString, filename }: Base64InputProps);
|
|
@@ -26,7 +26,7 @@ interface StreamInputProps {
|
|
|
26
26
|
inputStream: Readable;
|
|
27
27
|
filename: string;
|
|
28
28
|
}
|
|
29
|
-
export declare class StreamInput extends
|
|
29
|
+
export declare class StreamInput extends LocalInputSource {
|
|
30
30
|
private readonly inputStream;
|
|
31
31
|
fileObject: Buffer;
|
|
32
32
|
constructor({ inputStream, filename }: StreamInputProps);
|
|
@@ -37,26 +37,25 @@ interface BytesInputProps {
|
|
|
37
37
|
inputBytes: string;
|
|
38
38
|
filename: string;
|
|
39
39
|
}
|
|
40
|
-
export declare class BytesInput extends
|
|
40
|
+
export declare class BytesInput extends LocalInputSource {
|
|
41
41
|
private inputBytes;
|
|
42
42
|
fileObject: Buffer;
|
|
43
43
|
constructor({ inputBytes, filename }: BytesInputProps);
|
|
44
44
|
init(): Promise<void>;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
url: string;
|
|
48
|
-
}
|
|
49
|
-
export declare class UrlInput extends InputSource {
|
|
46
|
+
export declare class UrlInput {
|
|
50
47
|
private readonly url;
|
|
51
48
|
fileObject: string;
|
|
52
|
-
constructor({ url }:
|
|
49
|
+
constructor({ url }: {
|
|
50
|
+
url: string;
|
|
51
|
+
});
|
|
53
52
|
init(): Promise<void>;
|
|
54
53
|
}
|
|
55
54
|
interface BufferInputProps {
|
|
56
55
|
buffer: Buffer;
|
|
57
56
|
filename: string;
|
|
58
57
|
}
|
|
59
|
-
export declare class BufferInput extends
|
|
58
|
+
export declare class BufferInput extends LocalInputSource {
|
|
60
59
|
constructor({ buffer, filename }: BufferInputProps);
|
|
61
60
|
init(): Promise<void>;
|
|
62
61
|
}
|
|
@@ -30,7 +30,7 @@ const handler_1 = require("../errors/handler");
|
|
|
30
30
|
const buffer_1 = require("buffer");
|
|
31
31
|
const logger_1 = require("../logger");
|
|
32
32
|
const base_1 = require("./base");
|
|
33
|
-
class PathInput extends base_1.
|
|
33
|
+
class PathInput extends base_1.LocalInputSource {
|
|
34
34
|
constructor({ inputPath }) {
|
|
35
35
|
super({
|
|
36
36
|
inputType: base_1.INPUT_TYPE_PATH,
|
|
@@ -46,7 +46,7 @@ class PathInput extends base_1.InputSource {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
exports.PathInput = PathInput;
|
|
49
|
-
class Base64Input extends base_1.
|
|
49
|
+
class Base64Input extends base_1.LocalInputSource {
|
|
50
50
|
constructor({ inputString, filename }) {
|
|
51
51
|
super({
|
|
52
52
|
inputType: base_1.INPUT_TYPE_BASE64,
|
|
@@ -63,7 +63,7 @@ class Base64Input extends base_1.InputSource {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
exports.Base64Input = Base64Input;
|
|
66
|
-
class StreamInput extends base_1.
|
|
66
|
+
class StreamInput extends base_1.LocalInputSource {
|
|
67
67
|
constructor({ inputStream, filename }) {
|
|
68
68
|
super({
|
|
69
69
|
inputType: base_1.INPUT_TYPE_STREAM,
|
|
@@ -86,7 +86,7 @@ class StreamInput extends base_1.InputSource {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
exports.StreamInput = StreamInput;
|
|
89
|
-
class BytesInput extends base_1.
|
|
89
|
+
class BytesInput extends base_1.LocalInputSource {
|
|
90
90
|
constructor({ inputBytes, filename }) {
|
|
91
91
|
super({
|
|
92
92
|
inputType: base_1.INPUT_TYPE_BYTES,
|
|
@@ -103,11 +103,11 @@ class BytesInput extends base_1.InputSource {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
exports.BytesInput = BytesInput;
|
|
106
|
-
|
|
106
|
+
//
|
|
107
|
+
// URL
|
|
108
|
+
//
|
|
109
|
+
class UrlInput {
|
|
107
110
|
constructor({ url }) {
|
|
108
|
-
super({
|
|
109
|
-
inputType: base_1.INPUT_TYPE_URL,
|
|
110
|
-
});
|
|
111
111
|
this.url = url;
|
|
112
112
|
}
|
|
113
113
|
async init() {
|
|
@@ -118,7 +118,7 @@ class UrlInput extends base_1.InputSource {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
exports.UrlInput = UrlInput;
|
|
121
|
-
class BufferInput extends base_1.
|
|
121
|
+
class BufferInput extends base_1.LocalInputSource {
|
|
122
122
|
constructor({ buffer, filename }) {
|
|
123
123
|
super({
|
|
124
124
|
inputType: base_1.INPUT_TYPE_BUFFER,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StringDict } from "./stringDict";
|
|
2
|
+
export declare class ApiRequest {
|
|
3
|
+
error: StringDict;
|
|
4
|
+
resources: string[];
|
|
5
|
+
status: "failure" | "success";
|
|
6
|
+
/** HTTP status code */
|
|
7
|
+
statusCode: number;
|
|
8
|
+
url: string;
|
|
9
|
+
constructor(serverResponse: StringDict);
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiRequest = void 0;
|
|
4
|
+
class ApiRequest {
|
|
5
|
+
constructor(serverResponse) {
|
|
6
|
+
this.error = serverResponse["error"];
|
|
7
|
+
this.resources = serverResponse["resources"];
|
|
8
|
+
this.status = serverResponse["status"];
|
|
9
|
+
this.statusCode = serverResponse["status_code"];
|
|
10
|
+
this.url = serverResponse["url"];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ApiRequest = ApiRequest;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiResponse = void 0;
|
|
4
|
+
const apiRequest_1 = require("./apiRequest");
|
|
5
|
+
class ApiResponse {
|
|
6
|
+
constructor(serverResponse) {
|
|
7
|
+
this.apiRequest = new apiRequest_1.ApiRequest(serverResponse["api_request"]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ApiResponse = ApiResponse;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApiResponse } from "./apiResponse";
|
|
2
|
+
import { StringDict } from "./stringDict";
|
|
3
|
+
import { Inference } from "./inference";
|
|
4
|
+
import { Document } from "./document";
|
|
5
|
+
export declare class Job {
|
|
6
|
+
issuedAt: Date;
|
|
7
|
+
availableAt?: Date;
|
|
8
|
+
id: string;
|
|
9
|
+
status?: "waiting" | "processing" | "completed";
|
|
10
|
+
/**
|
|
11
|
+
* The time taken to process the job, in milliseconds.
|
|
12
|
+
*/
|
|
13
|
+
milliSecsTaken?: number;
|
|
14
|
+
constructor(jsonResponse: StringDict);
|
|
15
|
+
protected datetimeWithTimezone(date: string): Date;
|
|
16
|
+
}
|
|
17
|
+
export declare class AsyncPredictResponse<T extends Inference> extends ApiResponse {
|
|
18
|
+
job: Job;
|
|
19
|
+
document?: Document<T>;
|
|
20
|
+
constructor(inferenceClass: new (httpResponse: StringDict) => T, httpResponse: StringDict);
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncPredictResponse = exports.Job = void 0;
|
|
4
|
+
const apiResponse_1 = require("./apiResponse");
|
|
5
|
+
const document_1 = require("./document");
|
|
6
|
+
class Job {
|
|
7
|
+
constructor(jsonResponse) {
|
|
8
|
+
this.issuedAt = this.datetimeWithTimezone(jsonResponse["issued_at"]);
|
|
9
|
+
if (jsonResponse["available_at"] !== undefined &&
|
|
10
|
+
jsonResponse["available_at"] !== null) {
|
|
11
|
+
this.availableAt = this.datetimeWithTimezone(jsonResponse["available_at"]);
|
|
12
|
+
}
|
|
13
|
+
this.id = jsonResponse["id"];
|
|
14
|
+
this.status = jsonResponse["status"];
|
|
15
|
+
if (this.availableAt !== undefined) {
|
|
16
|
+
this.milliSecsTaken =
|
|
17
|
+
this.availableAt.getTime() - this.issuedAt.getTime();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Hideous thing to make sure dates sent back by the server are parsed correctly in UTC.
|
|
21
|
+
datetimeWithTimezone(date) {
|
|
22
|
+
if (date.search(/\+[0-9]{2}:[0-9]{2}$/) === -1) {
|
|
23
|
+
date += "+00:00";
|
|
24
|
+
}
|
|
25
|
+
return new Date(date);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Job = Job;
|
|
29
|
+
class AsyncPredictResponse extends apiResponse_1.ApiResponse {
|
|
30
|
+
constructor(inferenceClass, httpResponse) {
|
|
31
|
+
super(httpResponse);
|
|
32
|
+
this.job = new Job(httpResponse["job"]);
|
|
33
|
+
this.document =
|
|
34
|
+
httpResponse["document"] !== undefined
|
|
35
|
+
? new document_1.Document(inferenceClass, httpResponse["document"])
|
|
36
|
+
: undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.AsyncPredictResponse = AsyncPredictResponse;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Extras } from "./extras/extras";
|
|
2
|
+
import { Inference } from "./inference";
|
|
3
|
+
import { Ocr } from "./ocr";
|
|
4
|
+
import { StringDict } from "./stringDict";
|
|
5
|
+
export declare class Document<T extends Inference> {
|
|
6
|
+
filename: string;
|
|
7
|
+
inference: T;
|
|
8
|
+
id: string;
|
|
9
|
+
extras?: Extras;
|
|
10
|
+
ocr?: Ocr;
|
|
11
|
+
constructor(inferenceClass: new (httpResponse: StringDict) => T, httpResponse: StringDict);
|
|
12
|
+
toString(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Document = void 0;
|
|
4
|
+
const cropperExtra_1 = require("./extras/cropperExtra");
|
|
5
|
+
const extras_1 = require("./extras/extras");
|
|
6
|
+
class Document {
|
|
7
|
+
constructor(inferenceClass, httpResponse) {
|
|
8
|
+
this.id = httpResponse["id"] ?? "";
|
|
9
|
+
this.filename = httpResponse["name"] ?? "";
|
|
10
|
+
this.ocr = httpResponse["ocr"] ?? undefined;
|
|
11
|
+
this.inference = new inferenceClass(httpResponse["inference"]);
|
|
12
|
+
// Note: this is a convoluted but functional way of being able to implement/use Extras fields
|
|
13
|
+
// as an extension of a Map object (like having an adapted toString() method, for instance)
|
|
14
|
+
if (httpResponse["extras"] &&
|
|
15
|
+
Object.keys(httpResponse["extras"].length > 0)) {
|
|
16
|
+
const extras = {};
|
|
17
|
+
Object.entries(httpResponse["extras"]).forEach(([extraKey, extraValue]) => {
|
|
18
|
+
switch (extraKey) {
|
|
19
|
+
case "cropper":
|
|
20
|
+
extras["cropper"] = new cropperExtra_1.CropperExtra(extraValue);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
this.extras = new extras_1.Extras(extras);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
toString() {
|
|
27
|
+
return `########\nDocument\n########
|
|
28
|
+
:Mindee ID: ${this.id}
|
|
29
|
+
:Filename: ${this.filename}
|
|
30
|
+
|
|
31
|
+
${this.inference?.toString()}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Document = Document;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PositionField } from "../../standard";
|
|
2
|
+
import { StringDict } from "../stringDict";
|
|
3
|
+
import { ExtraField } from "./extras";
|
|
4
|
+
export declare class CropperExtra extends ExtraField {
|
|
5
|
+
cropping: PositionField[];
|
|
6
|
+
constructor(rawPrediction: StringDict, pageId?: number);
|
|
7
|
+
toString(): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CropperExtra = void 0;
|
|
4
|
+
const standard_1 = require("../../standard");
|
|
5
|
+
const summaryHelper_1 = require("../summaryHelper");
|
|
6
|
+
const extras_1 = require("./extras");
|
|
7
|
+
class CropperExtra extends extras_1.ExtraField {
|
|
8
|
+
constructor(rawPrediction, pageId) {
|
|
9
|
+
super();
|
|
10
|
+
this.cropping = [];
|
|
11
|
+
rawPrediction["cropping"] !== undefined &&
|
|
12
|
+
rawPrediction["cropping"].forEach((crop) => {
|
|
13
|
+
this.cropping.push(new standard_1.PositionField({
|
|
14
|
+
prediction: crop,
|
|
15
|
+
pageId: pageId,
|
|
16
|
+
}));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
toString() {
|
|
20
|
+
const cropping = this.cropping
|
|
21
|
+
.map((crop) => crop.toString())
|
|
22
|
+
.join("\n ");
|
|
23
|
+
return (0, summaryHelper_1.cleanOutString)(cropping);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.CropperExtra = CropperExtra;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare abstract class ExtraField {
|
|
2
|
+
}
|
|
3
|
+
interface ExtraDict<T extends ExtraField> {
|
|
4
|
+
[key: string]: T | (() => string);
|
|
5
|
+
}
|
|
6
|
+
export declare class Extras<ExtraT extends ExtraField = ExtraField> implements ExtraDict<ExtraT> {
|
|
7
|
+
[key: string]: ExtraT | (() => string);
|
|
8
|
+
constructor(fields: Record<string, ExtraT>);
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Extras = exports.ExtraField = void 0;
|
|
4
|
+
class ExtraField {
|
|
5
|
+
}
|
|
6
|
+
exports.ExtraField = ExtraField;
|
|
7
|
+
class Extras {
|
|
8
|
+
constructor(fields) {
|
|
9
|
+
Object.keys(fields).length > 0 &&
|
|
10
|
+
Object.keys(fields).forEach((name) => (this[name] = fields[name]));
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return (Object.entries(this)
|
|
14
|
+
.map(([name, extraField]) => name + ":\n" + extraField.toString())
|
|
15
|
+
.join("\n") + "\n");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Extras = Extras;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Document } from "./document";
|
|
2
|
+
export { OrientationField } from "./orientation";
|
|
3
|
+
export { StringDict } from "./stringDict";
|
|
4
|
+
export { Inference } from "./inference";
|
|
5
|
+
export { AsyncPredictResponse } from "./asyncPredictResponse";
|
|
6
|
+
export { PredictResponse } from "./predictResponse";
|
|
7
|
+
export { Prediction } from "./prediction";
|
|
8
|
+
export { Page } from "./page";
|
|
9
|
+
export { cleanOutString, lineSeparator } from "./summaryHelper";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lineSeparator = exports.cleanOutString = exports.Page = exports.Prediction = exports.PredictResponse = exports.AsyncPredictResponse = exports.Inference = exports.OrientationField = exports.Document = void 0;
|
|
4
|
+
var document_1 = require("./document");
|
|
5
|
+
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
|
|
6
|
+
var orientation_1 = require("./orientation");
|
|
7
|
+
Object.defineProperty(exports, "OrientationField", { enumerable: true, get: function () { return orientation_1.OrientationField; } });
|
|
8
|
+
var inference_1 = require("./inference");
|
|
9
|
+
Object.defineProperty(exports, "Inference", { enumerable: true, get: function () { return inference_1.Inference; } });
|
|
10
|
+
var asyncPredictResponse_1 = require("./asyncPredictResponse");
|
|
11
|
+
Object.defineProperty(exports, "AsyncPredictResponse", { enumerable: true, get: function () { return asyncPredictResponse_1.AsyncPredictResponse; } });
|
|
12
|
+
var predictResponse_1 = require("./predictResponse");
|
|
13
|
+
Object.defineProperty(exports, "PredictResponse", { enumerable: true, get: function () { return predictResponse_1.PredictResponse; } });
|
|
14
|
+
var prediction_1 = require("./prediction");
|
|
15
|
+
Object.defineProperty(exports, "Prediction", { enumerable: true, get: function () { return prediction_1.Prediction; } });
|
|
16
|
+
var page_1 = require("./page");
|
|
17
|
+
Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return page_1.Page; } });
|
|
18
|
+
var summaryHelper_1 = require("./summaryHelper");
|
|
19
|
+
Object.defineProperty(exports, "cleanOutString", { enumerable: true, get: function () { return summaryHelper_1.cleanOutString; } });
|
|
20
|
+
Object.defineProperty(exports, "lineSeparator", { enumerable: true, get: function () { return summaryHelper_1.lineSeparator; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StringDict } from "../common";
|
|
2
|
+
import { ExtraField } from "./extras/extras";
|
|
3
|
+
import { Page } from "./page";
|
|
4
|
+
import type { Prediction } from "./prediction";
|
|
5
|
+
import { Product } from "./product";
|
|
6
|
+
export declare abstract class Inference<DocT extends Prediction = Prediction, PageT extends DocT = DocT> {
|
|
7
|
+
isRotationApplied?: boolean;
|
|
8
|
+
product: Product;
|
|
9
|
+
pages: Page<PageT>[];
|
|
10
|
+
prediction: DocT;
|
|
11
|
+
extras?: ExtraField[];
|
|
12
|
+
endpointName?: string;
|
|
13
|
+
endpointVersion?: string;
|
|
14
|
+
constructor(rawPrediction: StringDict);
|
|
15
|
+
toString(): string;
|
|
16
|
+
static cleanOutString(outStr: string): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class InferenceFactory {
|
|
19
|
+
/**
|
|
20
|
+
* Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
|
|
21
|
+
* Note: this is needed to avoid passing anything other than the class of the object to the parse()/enqueue() call.
|
|
22
|
+
* @param inferenceClass Class of the product we are using
|
|
23
|
+
* @returns {Inference} An empty instance of a given product.
|
|
24
|
+
*/
|
|
25
|
+
static getEndpoint<T extends Inference>(inferenceClass: new (httpResponse: StringDict) => T): [string, string];
|
|
26
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InferenceFactory = exports.Inference = void 0;
|
|
4
|
+
class Inference {
|
|
5
|
+
constructor(rawPrediction) {
|
|
6
|
+
this.pages = [];
|
|
7
|
+
this.extras = [];
|
|
8
|
+
this.isRotationApplied = rawPrediction["is_rotation_applied"] ?? undefined;
|
|
9
|
+
this.product = rawPrediction["product"];
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `Inference
|
|
13
|
+
#########
|
|
14
|
+
:Product: ${this.product.name} v${this.product.version}
|
|
15
|
+
:Rotation applied: ${this.isRotationApplied ? "Yes" : "No"}
|
|
16
|
+
|
|
17
|
+
Prediction
|
|
18
|
+
==========
|
|
19
|
+
${this.prediction.toString() || ""}
|
|
20
|
+
|
|
21
|
+
Page Predictions
|
|
22
|
+
================
|
|
23
|
+
|
|
24
|
+
${this.pages.map((e) => e.toString() || "").join("\n")}`;
|
|
25
|
+
}
|
|
26
|
+
static cleanOutString(outStr) {
|
|
27
|
+
const lines = / \n/gm;
|
|
28
|
+
return outStr.replace(lines, "\n");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Inference = Inference;
|
|
32
|
+
class InferenceFactory {
|
|
33
|
+
/**
|
|
34
|
+
* Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
|
|
35
|
+
* Note: this is needed to avoid passing anything other than the class of the object to the parse()/enqueue() call.
|
|
36
|
+
* @param inferenceClass Class of the product we are using
|
|
37
|
+
* @returns {Inference} An empty instance of a given product.
|
|
38
|
+
*/
|
|
39
|
+
static getEndpoint(inferenceClass) {
|
|
40
|
+
if (inferenceClass.name === "CustomV1") {
|
|
41
|
+
throw new Error("Cannot process custom endpoint as OTS API endpoints. Please provide an endpoint name & version manually.");
|
|
42
|
+
}
|
|
43
|
+
const emptyProduct = new inferenceClass({
|
|
44
|
+
prediction: {},
|
|
45
|
+
pages: [],
|
|
46
|
+
});
|
|
47
|
+
if (!emptyProduct.endpointName ||
|
|
48
|
+
!emptyProduct.endpointVersion ||
|
|
49
|
+
emptyProduct.endpointName.length === 0 ||
|
|
50
|
+
emptyProduct.endpointVersion.length === 0) {
|
|
51
|
+
throw new Error(`Error during endpoint verification, no endpoint found for product ${inferenceClass.name}.`);
|
|
52
|
+
}
|
|
53
|
+
return [emptyProduct.endpointName, emptyProduct.endpointVersion];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.InferenceFactory = InferenceFactory;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MvisionV1 = void 0;
|
|
4
|
+
const ocrPage_1 = require("./ocrPage");
|
|
5
|
+
class MvisionV1 {
|
|
6
|
+
constructor(rawPrediction) {
|
|
7
|
+
/** List of words found on the page. */
|
|
8
|
+
this.pages = [];
|
|
9
|
+
rawPrediction["pages"].map((page) => {
|
|
10
|
+
this.pages.push(new ocrPage_1.OcrPage(page));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return this.pages.map((page) => page.toString()).join("\n") + "\n";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.MvisionV1 = MvisionV1;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ocr = void 0;
|
|
4
|
+
const mvisionV1_1 = require("./mvisionV1");
|
|
5
|
+
class Ocr {
|
|
6
|
+
constructor(rawPrediction) {
|
|
7
|
+
this.mVisionV1 = new mvisionV1_1.MvisionV1(rawPrediction["mvision-v1"]);
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return this.mVisionV1.toString();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Ocr = Ocr;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Word } from "../standard";
|
|
2
|
+
import { StringDict } from "./stringDict";
|
|
3
|
+
export declare class OcrPage {
|
|
4
|
+
#private;
|
|
5
|
+
/** Flat list of all words read */
|
|
6
|
+
allWords: Word[];
|
|
7
|
+
/** List of words by which line they are on */
|
|
8
|
+
allLines: Word[][];
|
|
9
|
+
constructor(rawPrediction: StringDict);
|
|
10
|
+
/**
|
|
11
|
+
* Get all words on the page as ordered lines
|
|
12
|
+
* @returns Sorted lines on the pages
|
|
13
|
+
*/
|
|
14
|
+
getAllLines(): Word[][];
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|