mindee 4.0.1 → 4.1.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 +25 -0
- package/package.json +4 -3
- package/src/cli.js +36 -66
- package/src/client.d.ts +76 -32
- package/src/client.js +108 -21
- package/src/http/endpoint.d.ts +36 -0
- package/src/http/endpoint.js +54 -16
- package/src/http/error.d.ts +66 -1
- package/src/http/error.js +196 -4
- package/src/http/index.d.ts +1 -1
- package/src/http/index.js +10 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/input/base.d.ts +1 -0
- package/src/input/base.js +3 -0
- package/src/input/pageOptions.d.ts +4 -0
- package/src/input/pageOptions.js +3 -0
- package/src/input/sources.d.ts +2 -3
- package/src/input/sources.js +2 -1
- package/src/internal.d.ts +5 -0
- package/src/internal.js +31 -0
- package/src/parsing/common/apiRequest.d.ts +9 -0
- package/src/parsing/common/apiRequest.js +5 -0
- package/src/parsing/common/apiResponse.d.ts +15 -0
- package/src/parsing/common/apiResponse.js +15 -0
- package/src/parsing/common/asyncPredictResponse.d.ts +24 -3
- package/src/parsing/common/asyncPredictResponse.js +15 -0
- package/src/parsing/common/document.d.ts +17 -0
- package/src/parsing/common/document.js +16 -4
- package/src/parsing/common/extras/cropperExtra.d.ts +3 -0
- package/src/parsing/common/extras/cropperExtra.js +3 -0
- package/src/parsing/common/extras/extras.d.ts +3 -0
- package/src/parsing/common/extras/extras.js +3 -0
- package/src/parsing/common/inference.d.ts +26 -0
- package/src/parsing/common/inference.js +23 -2
- package/src/parsing/common/mvisionV1.d.ts +3 -0
- package/src/parsing/common/mvisionV1.js +3 -0
- package/src/parsing/common/ocr.d.ts +3 -0
- package/src/parsing/common/ocr.js +3 -0
- package/src/parsing/common/ocrPage.d.ts +3 -0
- package/src/parsing/common/ocrPage.js +3 -0
- package/src/parsing/common/orientation.d.ts +3 -0
- package/src/parsing/common/orientation.js +3 -0
- package/src/parsing/common/page.d.ts +19 -0
- package/src/parsing/common/page.js +15 -0
- package/src/parsing/common/predictResponse.d.ts +11 -0
- package/src/parsing/common/predictResponse.js +10 -0
- package/src/parsing/custom/classificationField.d.ts +3 -0
- package/src/parsing/custom/classificationField.js +3 -0
- package/src/parsing/custom/listField.d.ts +6 -0
- package/src/parsing/custom/listField.js +6 -0
- package/src/parsing/standard/amount.d.ts +3 -0
- package/src/parsing/standard/amount.js +3 -0
- package/src/parsing/standard/base.d.ts +3 -0
- package/src/parsing/standard/base.js +3 -0
- package/src/parsing/standard/locale.d.ts +3 -0
- package/src/parsing/standard/locale.js +3 -0
- package/src/parsing/standard/paymentDetails.d.ts +3 -0
- package/src/parsing/standard/paymentDetails.js +3 -0
- package/src/parsing/standard/position.d.ts +3 -0
- package/src/parsing/standard/position.js +3 -0
- package/src/parsing/standard/tax.d.ts +3 -0
- package/src/parsing/standard/tax.js +3 -0
- package/src/product/cropper/cropperV1.d.ts +7 -0
- package/src/product/cropper/cropperV1.js +6 -0
- package/src/product/cropper/cropperV1Document.d.ts +6 -0
- package/src/product/cropper/cropperV1Document.js +6 -0
- package/src/product/cropper/internal.d.ts +2 -0
- package/src/product/cropper/internal.js +7 -0
- package/src/product/custom/customV1.d.ts +7 -0
- package/src/product/custom/customV1.js +6 -0
- package/src/product/custom/customV1Document.d.ts +16 -0
- package/src/product/custom/customV1Document.js +16 -2
- package/src/product/custom/customV1Page.d.ts +7 -0
- package/src/product/custom/customV1Page.js +7 -0
- package/src/product/custom/internal.d.ts +3 -0
- package/src/product/custom/internal.js +9 -0
- package/src/product/eu/internal.d.ts +1 -0
- package/src/product/eu/internal.js +27 -0
- package/src/product/eu/licensePlate/internal.d.ts +2 -0
- package/src/product/eu/licensePlate/internal.js +7 -0
- package/src/product/eu/licensePlate/licensePlateV1.d.ts +7 -0
- package/src/product/eu/licensePlate/licensePlateV1.js +6 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +3 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.js +3 -0
- package/src/product/financialDocument/financialDocumentV1.d.ts +7 -0
- package/src/product/financialDocument/financialDocumentV1.js +6 -0
- package/src/product/financialDocument/financialDocumentV1Document.d.ts +3 -0
- package/src/product/financialDocument/financialDocumentV1Document.js +3 -0
- package/src/product/financialDocument/internal.d.ts +3 -0
- package/src/product/financialDocument/internal.js +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +7 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +6 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +3 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +3 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +7 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +6 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts +3 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +3 -0
- package/src/product/fr/bankAccountDetails/internal.d.ts +5 -0
- package/src/product/fr/bankAccountDetails/internal.js +13 -0
- package/src/product/fr/carteVitale/carteVitaleV1.d.ts +7 -0
- package/src/product/fr/carteVitale/carteVitaleV1.js +6 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +3 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.js +3 -0
- package/src/product/fr/carteVitale/internal.d.ts +2 -0
- package/src/product/fr/carteVitale/internal.js +7 -0
- package/src/product/fr/idCard/idCardV1.d.ts +7 -0
- package/src/product/fr/idCard/idCardV1.js +6 -0
- package/src/product/fr/idCard/idCardV1Document.d.ts +3 -0
- package/src/product/fr/idCard/idCardV1Document.js +3 -0
- package/src/product/fr/idCard/internal.d.ts +3 -0
- package/src/product/fr/idCard/internal.js +9 -0
- package/src/product/fr/internal.d.ts +3 -0
- package/src/product/fr/internal.js +29 -0
- package/src/product/index.d.ts +0 -1
- package/src/product/index.js +1 -3
- package/src/product/internal.d.ts +11 -0
- package/src/product/internal.js +37 -0
- package/src/product/invoice/internal.d.ts +3 -0
- package/src/product/invoice/internal.js +9 -0
- package/src/product/invoice/invoiceV4.d.ts +7 -0
- package/src/product/invoice/invoiceV4.js +6 -0
- package/src/product/invoice/invoiceV4Document.d.ts +3 -1
- package/src/product/invoice/invoiceV4Document.js +3 -1
- package/src/product/invoice/invoiceV4LineItem.d.ts +9 -0
- package/src/product/invoice/invoiceV4LineItem.js +9 -0
- package/src/product/invoiceSplitter/internal.d.ts +3 -0
- package/src/product/invoiceSplitter/internal.js +9 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +7 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.js +6 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -2
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +7 -1
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +9 -1
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +10 -3
- package/src/product/passport/internal.d.ts +2 -0
- package/src/product/passport/internal.js +7 -0
- package/src/product/passport/passportV1.d.ts +7 -0
- package/src/product/passport/passportV1.js +6 -0
- package/src/product/passport/passportV1Document.d.ts +3 -0
- package/src/product/passport/passportV1Document.js +3 -0
- package/src/product/proofOfAddress/internal.d.ts +2 -0
- package/src/product/proofOfAddress/internal.js +7 -0
- package/src/product/proofOfAddress/proofOfAddressV1.d.ts +7 -0
- package/src/product/proofOfAddress/proofOfAddressV1.js +6 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +3 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.js +3 -0
- package/src/product/receipt/internal.d.ts +5 -0
- package/src/product/receipt/internal.js +13 -0
- package/src/product/receipt/receiptV4.d.ts +7 -0
- package/src/product/receipt/receiptV4.js +5 -0
- package/src/product/receipt/receiptV4Document.d.ts +6 -0
- package/src/product/receipt/receiptV4Document.js +6 -0
- package/src/product/receipt/receiptV5.d.ts +7 -0
- package/src/product/receipt/receiptV5.js +6 -0
- package/src/product/receipt/receiptV5Document.d.ts +3 -0
- package/src/product/receipt/receiptV5Document.js +3 -0
- package/src/product/us/bankCheck/bankCheckV1.d.ts +7 -0
- package/src/product/us/bankCheck/bankCheckV1.js +6 -0
- package/src/product/us/bankCheck/bankCheckV1Document.d.ts +3 -0
- package/src/product/us/bankCheck/bankCheckV1Document.js +3 -0
- package/src/product/us/bankCheck/internal.d.ts +3 -0
- package/src/product/us/bankCheck/internal.js +9 -0
- package/src/product/us/driverLicense/driverLicenseV1.d.ts +7 -0
- package/src/product/us/driverLicense/driverLicenseV1.js +6 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +3 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.js +3 -0
- package/src/product/us/driverLicense/internal.d.ts +3 -0
- package/src/product/us/driverLicense/internal.js +9 -0
- package/src/product/us/internal.d.ts +2 -0
- package/src/product/us/internal.js +28 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiRequest = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Holds the information relating to an API HTTP request.
|
|
6
|
+
*
|
|
7
|
+
* @category API Response
|
|
8
|
+
*/
|
|
4
9
|
class ApiRequest {
|
|
5
10
|
constructor(serverResponse) {
|
|
6
11
|
this.error = serverResponse["error"];
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { ApiRequest } from "./apiRequest";
|
|
2
2
|
import { StringDict } from "./stringDict";
|
|
3
|
+
/** Base wrapper for API requests.
|
|
4
|
+
*
|
|
5
|
+
* @category API Response
|
|
6
|
+
*/
|
|
3
7
|
export declare abstract class ApiResponse {
|
|
8
|
+
/** Initial request sent to the API. */
|
|
4
9
|
apiRequest: ApiRequest;
|
|
10
|
+
/** Raw text representation of the API's response. */
|
|
11
|
+
private readonly rawHttp;
|
|
12
|
+
/**
|
|
13
|
+
* @param serverResponse JSON response from the server.
|
|
14
|
+
*/
|
|
5
15
|
constructor(serverResponse: StringDict);
|
|
16
|
+
/**
|
|
17
|
+
* Raw HTTP request sent from server, as a JSON-like structure
|
|
18
|
+
* @returns The HTTP request
|
|
19
|
+
*/
|
|
20
|
+
getRawHttp(): StringDict;
|
|
6
21
|
}
|
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiResponse = void 0;
|
|
4
4
|
const apiRequest_1 = require("./apiRequest");
|
|
5
|
+
/** Base wrapper for API requests.
|
|
6
|
+
*
|
|
7
|
+
* @category API Response
|
|
8
|
+
*/
|
|
5
9
|
class ApiResponse {
|
|
10
|
+
/**
|
|
11
|
+
* @param serverResponse JSON response from the server.
|
|
12
|
+
*/
|
|
6
13
|
constructor(serverResponse) {
|
|
7
14
|
this.apiRequest = new apiRequest_1.ApiRequest(serverResponse["api_request"]);
|
|
15
|
+
this.rawHttp = serverResponse;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Raw HTTP request sent from server, as a JSON-like structure
|
|
19
|
+
* @returns The HTTP request
|
|
20
|
+
*/
|
|
21
|
+
getRawHttp() {
|
|
22
|
+
return this.rawHttp;
|
|
8
23
|
}
|
|
9
24
|
}
|
|
10
25
|
exports.ApiResponse = ApiResponse;
|
|
@@ -2,20 +2,41 @@ import { ApiResponse } from "./apiResponse";
|
|
|
2
2
|
import { StringDict } from "./stringDict";
|
|
3
3
|
import { Inference } from "./inference";
|
|
4
4
|
import { Document } from "./document";
|
|
5
|
+
/** Wrapper for asynchronous request queues. Holds information regarding a job (queue).
|
|
6
|
+
*
|
|
7
|
+
* @category API Response
|
|
8
|
+
* @category Asynchronous
|
|
9
|
+
*/
|
|
5
10
|
export declare class Job {
|
|
11
|
+
/** Timestamp noting the enqueueing of a document. */
|
|
6
12
|
issuedAt: Date;
|
|
13
|
+
/** Timestamp noting the availability of a prediction for an enqueued document. */
|
|
7
14
|
availableAt?: Date;
|
|
15
|
+
/** ID of the job. */
|
|
8
16
|
id: string;
|
|
17
|
+
/** Status of the job. */
|
|
9
18
|
status?: "waiting" | "processing" | "completed";
|
|
10
|
-
/**
|
|
11
|
-
* The time taken to process the job, in milliseconds.
|
|
12
|
-
*/
|
|
19
|
+
/** The time taken to process the job, in milliseconds. */
|
|
13
20
|
milliSecsTaken?: number;
|
|
14
21
|
constructor(jsonResponse: StringDict);
|
|
15
22
|
protected datetimeWithTimezone(date: string): Date;
|
|
16
23
|
}
|
|
24
|
+
/** Wrapper for asynchronous jobs and parsing results.
|
|
25
|
+
*
|
|
26
|
+
* @category API Response
|
|
27
|
+
* @category Asynchronous
|
|
28
|
+
*/
|
|
17
29
|
export declare class AsyncPredictResponse<T extends Inference> extends ApiResponse {
|
|
30
|
+
/** Job for a queue. */
|
|
18
31
|
job: Job;
|
|
32
|
+
/** Prediction for an asynchronous request. Will not be available so long as the job is not
|
|
33
|
+
* `completed`.
|
|
34
|
+
*/
|
|
19
35
|
document?: Document<T>;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param inferenceClass constructor signature for an inference.
|
|
39
|
+
* @param httpResponse raw http response.
|
|
40
|
+
*/
|
|
20
41
|
constructor(inferenceClass: new (httpResponse: StringDict) => T, httpResponse: StringDict);
|
|
21
42
|
}
|
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AsyncPredictResponse = exports.Job = void 0;
|
|
4
4
|
const apiResponse_1 = require("./apiResponse");
|
|
5
5
|
const document_1 = require("./document");
|
|
6
|
+
/** Wrapper for asynchronous request queues. Holds information regarding a job (queue).
|
|
7
|
+
*
|
|
8
|
+
* @category API Response
|
|
9
|
+
* @category Asynchronous
|
|
10
|
+
*/
|
|
6
11
|
class Job {
|
|
7
12
|
constructor(jsonResponse) {
|
|
8
13
|
this.issuedAt = this.datetimeWithTimezone(jsonResponse["issued_at"]);
|
|
@@ -26,7 +31,17 @@ class Job {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
exports.Job = Job;
|
|
34
|
+
/** Wrapper for asynchronous jobs and parsing results.
|
|
35
|
+
*
|
|
36
|
+
* @category API Response
|
|
37
|
+
* @category Asynchronous
|
|
38
|
+
*/
|
|
29
39
|
class AsyncPredictResponse extends apiResponse_1.ApiResponse {
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param inferenceClass constructor signature for an inference.
|
|
43
|
+
* @param httpResponse raw http response.
|
|
44
|
+
*/
|
|
30
45
|
constructor(inferenceClass, httpResponse) {
|
|
31
46
|
super(httpResponse);
|
|
32
47
|
this.job = new Job(httpResponse["job"]);
|
|
@@ -2,12 +2,29 @@ import { Extras } from "./extras/extras";
|
|
|
2
2
|
import { Inference } from "./inference";
|
|
3
3
|
import { Ocr } from "./ocr";
|
|
4
4
|
import { StringDict } from "./stringDict";
|
|
5
|
+
/**
|
|
6
|
+
* Document prediction wrapper class. Holds the results of a parsed document.
|
|
7
|
+
* @typeParam T an extension of an `Inference`. Mandatory in order to properly create an inference.
|
|
8
|
+
*/
|
|
5
9
|
export declare class Document<T extends Inference> {
|
|
10
|
+
/** File name as sent back by the server. */
|
|
6
11
|
filename: string;
|
|
12
|
+
/** Result of the base inference. */
|
|
7
13
|
inference: T;
|
|
14
|
+
/** Id of the document as sent back by the server. */
|
|
8
15
|
id: string;
|
|
16
|
+
/** Potential `Extras` fields sent back along the prediction. */
|
|
9
17
|
extras?: Extras;
|
|
18
|
+
/** Raw-text response for `allWords` parsing. */
|
|
10
19
|
ocr?: Ocr;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param inferenceClass constructor signature for an inference.
|
|
23
|
+
* @param httpResponse raw http response.
|
|
24
|
+
*/
|
|
11
25
|
constructor(inferenceClass: new (httpResponse: StringDict) => T, httpResponse: StringDict);
|
|
26
|
+
/**
|
|
27
|
+
* Default string representation.
|
|
28
|
+
*/
|
|
12
29
|
toString(): string;
|
|
13
30
|
}
|
|
@@ -3,14 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Document = void 0;
|
|
4
4
|
const cropperExtra_1 = require("./extras/cropperExtra");
|
|
5
5
|
const extras_1 = require("./extras/extras");
|
|
6
|
+
/**
|
|
7
|
+
* Document prediction wrapper class. Holds the results of a parsed document.
|
|
8
|
+
* @typeParam T an extension of an `Inference`. Mandatory in order to properly create an inference.
|
|
9
|
+
*/
|
|
6
10
|
class Document {
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param inferenceClass constructor signature for an inference.
|
|
14
|
+
* @param httpResponse raw http response.
|
|
15
|
+
*/
|
|
7
16
|
constructor(inferenceClass, httpResponse) {
|
|
8
|
-
this.id = httpResponse
|
|
9
|
-
this.filename = httpResponse
|
|
10
|
-
this.ocr = httpResponse
|
|
17
|
+
this.id = httpResponse?.id ?? "";
|
|
18
|
+
this.filename = httpResponse?.name ?? "";
|
|
19
|
+
this.ocr = httpResponse?.ocr ?? undefined;
|
|
11
20
|
this.inference = new inferenceClass(httpResponse["inference"]);
|
|
12
21
|
// 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)
|
|
22
|
+
// as an extension of a Map object (like having an adapted toString() method, for instance).
|
|
14
23
|
if (httpResponse["extras"] &&
|
|
15
24
|
Object.keys(httpResponse["extras"].length > 0)) {
|
|
16
25
|
const extras = {};
|
|
@@ -23,6 +32,9 @@ class Document {
|
|
|
23
32
|
this.extras = new extras_1.Extras(extras);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Default string representation.
|
|
37
|
+
*/
|
|
26
38
|
toString() {
|
|
27
39
|
return `########\nDocument\n########
|
|
28
40
|
:Mindee ID: ${this.id}
|
|
@@ -6,6 +6,9 @@ interface ExtraDict<T extends ExtraField> {
|
|
|
6
6
|
export declare class Extras<ExtraT extends ExtraField = ExtraField> implements ExtraDict<ExtraT> {
|
|
7
7
|
[key: string]: ExtraT | (() => string);
|
|
8
8
|
constructor(fields: Record<string, ExtraT>);
|
|
9
|
+
/**
|
|
10
|
+
* Default string representation.
|
|
11
|
+
*/
|
|
9
12
|
toString(): string;
|
|
10
13
|
}
|
|
11
14
|
export {};
|
|
@@ -9,6 +9,9 @@ class Extras {
|
|
|
9
9
|
Object.keys(fields).length > 0 &&
|
|
10
10
|
Object.keys(fields).forEach((name) => (this[name] = fields[name]));
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Default string representation.
|
|
14
|
+
*/
|
|
12
15
|
toString() {
|
|
13
16
|
return (Object.entries(this)
|
|
14
17
|
.map(([name, extraField]) => name + ":\n" + extraField.toString())
|
|
@@ -3,18 +3,44 @@ import { ExtraField } from "./extras/extras";
|
|
|
3
3
|
import { Page } from "./page";
|
|
4
4
|
import type { Prediction } from "./prediction";
|
|
5
5
|
import { Product } from "./product";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @typeParam DocT an extension of a `Prediction`. Is generic by default to
|
|
9
|
+
* allow for easier optional `PageT` generic typing.
|
|
10
|
+
* @typeParam PageT an extension of a `DocT` (`Prediction`). Should only be set
|
|
11
|
+
* if a document's pages have specific implementation.
|
|
12
|
+
*/
|
|
6
13
|
export declare abstract class Inference<DocT extends Prediction = Prediction, PageT extends DocT = DocT> {
|
|
14
|
+
/** A boolean denoting whether a given inference result was rotated. */
|
|
7
15
|
isRotationApplied?: boolean;
|
|
16
|
+
/** Name and version of a given product. */
|
|
8
17
|
product: Product;
|
|
18
|
+
/** Wrapper for a document's pages prediction. */
|
|
9
19
|
pages: Page<PageT>[];
|
|
20
|
+
/** A document's top-level `Prediction`. */
|
|
10
21
|
prediction: DocT;
|
|
22
|
+
/** Extraneous fields relating to specific tools for some APIs. */
|
|
11
23
|
extras?: ExtraField[];
|
|
24
|
+
/** Name of a document's endpoint. Has a default value for OTS APIs. */
|
|
12
25
|
endpointName?: string;
|
|
26
|
+
/** A document's version. Has a default value for OTS APIs. */
|
|
13
27
|
endpointVersion?: string;
|
|
14
28
|
constructor(rawPrediction: StringDict);
|
|
29
|
+
/**
|
|
30
|
+
* Default string representation.
|
|
31
|
+
*/
|
|
15
32
|
toString(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Takes in an input string and replaces line breaks with `\n`.
|
|
35
|
+
* @param outStr string to cleanup
|
|
36
|
+
* @returns cleaned out string
|
|
37
|
+
*/
|
|
16
38
|
static cleanOutString(outStr: string): string;
|
|
17
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Factory to allow for static-like property access syntax in TypeScript.
|
|
42
|
+
* Used to retrieve endpoint data for standard products.
|
|
43
|
+
*/
|
|
18
44
|
export declare class InferenceFactory {
|
|
19
45
|
/**
|
|
20
46
|
* Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InferenceFactory = exports.Inference = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @typeParam DocT an extension of a `Prediction`. Is generic by default to
|
|
7
|
+
* allow for easier optional `PageT` generic typing.
|
|
8
|
+
* @typeParam PageT an extension of a `DocT` (`Prediction`). Should only be set
|
|
9
|
+
* if a document's pages have specific implementation.
|
|
10
|
+
*/
|
|
4
11
|
class Inference {
|
|
5
12
|
constructor(rawPrediction) {
|
|
13
|
+
/** Wrapper for a document's pages prediction. */
|
|
6
14
|
this.pages = [];
|
|
15
|
+
/** Extraneous fields relating to specific tools for some APIs. */
|
|
7
16
|
this.extras = [];
|
|
8
|
-
this.isRotationApplied = rawPrediction
|
|
9
|
-
this.product = rawPrediction
|
|
17
|
+
this.isRotationApplied = rawPrediction?.is_rotation_applied ?? undefined;
|
|
18
|
+
this.product = rawPrediction?.product;
|
|
10
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Default string representation.
|
|
22
|
+
*/
|
|
11
23
|
toString() {
|
|
12
24
|
return `Inference
|
|
13
25
|
#########
|
|
@@ -23,12 +35,21 @@ Page Predictions
|
|
|
23
35
|
|
|
24
36
|
${this.pages.map((e) => e.toString() || "").join("\n")}`;
|
|
25
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Takes in an input string and replaces line breaks with `\n`.
|
|
40
|
+
* @param outStr string to cleanup
|
|
41
|
+
* @returns cleaned out string
|
|
42
|
+
*/
|
|
26
43
|
static cleanOutString(outStr) {
|
|
27
44
|
const lines = / \n/gm;
|
|
28
45
|
return outStr.replace(lines, "\n");
|
|
29
46
|
}
|
|
30
47
|
}
|
|
31
48
|
exports.Inference = Inference;
|
|
49
|
+
/**
|
|
50
|
+
* Factory to allow for static-like property access syntax in TypeScript.
|
|
51
|
+
* Used to retrieve endpoint data for standard products.
|
|
52
|
+
*/
|
|
32
53
|
class InferenceFactory {
|
|
33
54
|
/**
|
|
34
55
|
* Builds a blank product of the given type & sends back the endpointName & endpointVersion parameters of OTS classes.
|
|
@@ -17,6 +17,9 @@ export declare class OrientationField extends BaseField {
|
|
|
17
17
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
18
18
|
*/
|
|
19
19
|
constructor({ prediction, valueKey, reconstructed, pageId, }: OrientationFieldConstructor);
|
|
20
|
+
/**
|
|
21
|
+
* Default string representation.
|
|
22
|
+
*/
|
|
20
23
|
toString(): string;
|
|
21
24
|
}
|
|
22
25
|
export {};
|
|
@@ -2,11 +2,30 @@ import { Extras } from "./extras/extras";
|
|
|
2
2
|
import { OrientationField } from "./orientation";
|
|
3
3
|
import { Prediction } from "./prediction";
|
|
4
4
|
import { StringDict } from "./stringDict";
|
|
5
|
+
/**
|
|
6
|
+
* Page prediction wrapper class. Holds the results of a parsed document's page.
|
|
7
|
+
* Holds a `Prediction` that's either a document-level Prediction, or inherits from one.
|
|
8
|
+
* @typeParam T an extension of an `Prediction`. Mandatory in order to properly create a page-level prediction.
|
|
9
|
+
*/
|
|
5
10
|
export declare class Page<T extends Prediction> {
|
|
11
|
+
/** The page's index (identifier). */
|
|
6
12
|
id: number;
|
|
13
|
+
/** The page's orientation */
|
|
7
14
|
orientation?: OrientationField;
|
|
15
|
+
/** A page-level prediction. Can either be specific to pages or identical to the document prediction. */
|
|
8
16
|
prediction: T;
|
|
17
|
+
/** Potential `Extras` fields sent back along with the prediction. */
|
|
9
18
|
extras?: Extras;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param inferenceClass constructor signature for an inference.
|
|
22
|
+
* @param httpResponse raw http response.
|
|
23
|
+
* @param pageId the page's index (identifier).
|
|
24
|
+
* @param orientation the page's orientation.
|
|
25
|
+
*/
|
|
10
26
|
constructor(predictionType: new (rawPrediction: StringDict, pageId: number) => T, rawPrediction: StringDict, pageId: number, orientation?: StringDict);
|
|
27
|
+
/**
|
|
28
|
+
* Default string representation.
|
|
29
|
+
*/
|
|
11
30
|
toString(): string;
|
|
12
31
|
}
|
|
@@ -4,7 +4,19 @@ exports.Page = void 0;
|
|
|
4
4
|
const cropperExtra_1 = require("./extras/cropperExtra");
|
|
5
5
|
const extras_1 = require("./extras/extras");
|
|
6
6
|
const orientation_1 = require("./orientation");
|
|
7
|
+
/**
|
|
8
|
+
* Page prediction wrapper class. Holds the results of a parsed document's page.
|
|
9
|
+
* Holds a `Prediction` that's either a document-level Prediction, or inherits from one.
|
|
10
|
+
* @typeParam T an extension of an `Prediction`. Mandatory in order to properly create a page-level prediction.
|
|
11
|
+
*/
|
|
7
12
|
class Page {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param inferenceClass constructor signature for an inference.
|
|
16
|
+
* @param httpResponse raw http response.
|
|
17
|
+
* @param pageId the page's index (identifier).
|
|
18
|
+
* @param orientation the page's orientation.
|
|
19
|
+
*/
|
|
8
20
|
constructor(predictionType, rawPrediction, pageId, orientation) {
|
|
9
21
|
if (pageId !== undefined && orientation !== undefined) {
|
|
10
22
|
this.orientation = new orientation_1.OrientationField({
|
|
@@ -29,6 +41,9 @@ class Page {
|
|
|
29
41
|
this.extras = new extras_1.Extras(extras);
|
|
30
42
|
}
|
|
31
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Default string representation.
|
|
46
|
+
*/
|
|
32
47
|
toString() {
|
|
33
48
|
const title = `Page ${this.id}`;
|
|
34
49
|
return `${title}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { ApiResponse } from "./apiResponse";
|
|
2
2
|
import { Document, Inference, StringDict } from ".";
|
|
3
|
+
/** Wrapper for synchronous prediction response.
|
|
4
|
+
*
|
|
5
|
+
* @category API Response
|
|
6
|
+
* @category Synchronous
|
|
7
|
+
*/
|
|
3
8
|
export declare class PredictResponse<T extends Inference> extends ApiResponse {
|
|
9
|
+
/** A document prediction response. */
|
|
4
10
|
document: Document<T>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param inferenceClass constructor signature for an inference.
|
|
14
|
+
* @param rawPrediction raw http response.
|
|
15
|
+
*/
|
|
5
16
|
constructor(inferenceClass: new (rawPrediction: StringDict) => T, rawPrediction: StringDict);
|
|
6
17
|
}
|
|
@@ -3,7 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PredictResponse = void 0;
|
|
4
4
|
const apiResponse_1 = require("./apiResponse");
|
|
5
5
|
const _1 = require(".");
|
|
6
|
+
/** Wrapper for synchronous prediction response.
|
|
7
|
+
*
|
|
8
|
+
* @category API Response
|
|
9
|
+
* @category Synchronous
|
|
10
|
+
*/
|
|
6
11
|
class PredictResponse extends apiResponse_1.ApiResponse {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param inferenceClass constructor signature for an inference.
|
|
15
|
+
* @param rawPrediction raw http response.
|
|
16
|
+
*/
|
|
7
17
|
constructor(inferenceClass, rawPrediction) {
|
|
8
18
|
super(rawPrediction);
|
|
9
19
|
this.document = new _1.Document(inferenceClass, rawPrediction["document"]);
|
|
@@ -20,6 +20,9 @@ export declare class ListFieldValue {
|
|
|
20
20
|
*/
|
|
21
21
|
polygon: Polygon;
|
|
22
22
|
constructor(prediction: StringDict);
|
|
23
|
+
/**
|
|
24
|
+
* Default string representation.
|
|
25
|
+
*/
|
|
23
26
|
toString(): string;
|
|
24
27
|
}
|
|
25
28
|
export declare class ListField {
|
|
@@ -32,5 +35,8 @@ export declare class ListField {
|
|
|
32
35
|
constructor({ prediction, reconstructed, pageId, }: FieldConstructor);
|
|
33
36
|
contentsList(): Array<string | number>;
|
|
34
37
|
contentsString(separator?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Default string representation.
|
|
40
|
+
*/
|
|
35
41
|
toString(): string;
|
|
36
42
|
}
|
|
@@ -21,6 +21,9 @@ class ListFieldValue {
|
|
|
21
21
|
this.bbox = (0, geometry_1.getBoundingBox)(prediction["polygon"]);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Default string representation.
|
|
26
|
+
*/
|
|
24
27
|
toString() {
|
|
25
28
|
return `${this.content}`;
|
|
26
29
|
}
|
|
@@ -44,6 +47,9 @@ class ListField {
|
|
|
44
47
|
contentsString(separator = " ") {
|
|
45
48
|
return this.values.map((item) => `${item.content}`).join(separator);
|
|
46
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Default string representation.
|
|
52
|
+
*/
|
|
47
53
|
toString() {
|
|
48
54
|
return this.contentsString();
|
|
49
55
|
}
|
|
@@ -13,5 +13,8 @@ export declare class AmountField extends Field {
|
|
|
13
13
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
14
14
|
*/
|
|
15
15
|
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
16
|
+
/**
|
|
17
|
+
* Default string representation.
|
|
18
|
+
*/
|
|
16
19
|
toString(): string;
|
|
17
20
|
}
|
|
@@ -19,5 +19,8 @@ export declare class LocaleField extends BaseField {
|
|
|
19
19
|
* @param {boolean} reconstructed - Is the object reconstructed (not extracted by the API)
|
|
20
20
|
*/
|
|
21
21
|
constructor({ prediction, reconstructed, pageId, }: BaseFieldConstructor);
|
|
22
|
+
/**
|
|
23
|
+
* Default string representation.
|
|
24
|
+
*/
|
|
22
25
|
toString(): string;
|
|
23
26
|
}
|
|
@@ -36,6 +36,9 @@ export declare class PaymentDetailsField extends Field {
|
|
|
36
36
|
* @param {Integer} pageId - Page ID for multi-page document
|
|
37
37
|
*/
|
|
38
38
|
constructor({ prediction, valueKey, accountNumberKey, ibanKey, routingNumberKey, swiftKey, reconstructed, pageId, }: PaymentDetailsConstructor);
|
|
39
|
+
/**
|
|
40
|
+
* Default string representation.
|
|
41
|
+
*/
|
|
39
42
|
toString(): string;
|
|
40
43
|
}
|
|
41
44
|
export {};
|