mindee 3.10.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +103 -41
- package/package.json +6 -6
- package/src/cli.js +96 -70
- package/src/client.d.ts +34 -65
- package/src/client.js +108 -172
- package/src/geometry/boundingBox.d.ts +5 -0
- package/src/geometry/boundingBox.js +2 -0
- package/src/geometry/boundingBoxUtils.d.ts +22 -0
- package/src/geometry/boundingBoxUtils.js +66 -0
- package/src/geometry/index.d.ts +6 -0
- package/src/geometry/index.js +21 -0
- package/src/geometry/minMax.d.ts +4 -0
- package/src/geometry/minMax.js +2 -0
- package/src/geometry/point.d.ts +2 -0
- package/src/geometry/point.js +2 -0
- package/src/geometry/polygon.d.ts +4 -0
- package/src/geometry/polygon.js +7 -0
- package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
- package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
- package/src/http/endpoint.d.ts +44 -0
- package/src/http/endpoint.js +188 -0
- package/src/http/error.d.ts +2 -0
- package/src/http/error.js +9 -0
- package/src/http/index.d.ts +3 -0
- package/src/http/index.js +11 -0
- package/src/http/mindeeApi.d.ts +20 -0
- package/src/http/mindeeApi.js +73 -0
- package/src/index.d.ts +4 -4
- package/src/index.js +33 -26
- package/src/{inputs → input}/base.d.ts +4 -3
- package/src/{inputs → input}/base.js +9 -7
- package/src/{inputs → input}/index.d.ts +1 -1
- package/src/{inputs → input}/index.js +1 -2
- package/src/{inputs → input}/sources.d.ts +10 -11
- package/src/{inputs → input}/sources.js +9 -9
- package/src/parsing/common/apiRequest.d.ts +10 -0
- package/src/parsing/common/apiRequest.js +13 -0
- package/src/parsing/common/apiResponse.d.ts +6 -0
- package/src/parsing/common/apiResponse.js +10 -0
- package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
- package/src/parsing/common/asyncPredictResponse.js +39 -0
- package/src/parsing/common/document.d.ts +13 -0
- package/src/parsing/common/document.js +34 -0
- package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
- package/src/parsing/common/extras/cropperExtra.js +26 -0
- package/src/parsing/common/extras/extras.d.ts +11 -0
- package/src/parsing/common/extras/extras.js +18 -0
- package/src/parsing/common/index.d.ts +9 -0
- package/src/parsing/common/index.js +20 -0
- package/src/parsing/common/inference.d.ts +26 -0
- package/src/parsing/common/inference.js +56 -0
- package/src/parsing/common/mvisionV1.d.ts +8 -0
- package/src/parsing/common/mvisionV1.js +17 -0
- package/src/parsing/common/ocr.d.ts +8 -0
- package/src/parsing/common/ocr.js +13 -0
- package/src/parsing/common/ocrPage.d.ts +16 -0
- package/src/parsing/common/ocrPage.js +66 -0
- package/src/{fields → parsing/common}/orientation.d.ts +2 -2
- package/src/{fields → parsing/common}/orientation.js +4 -4
- package/src/parsing/common/page.d.ts +12 -0
- package/src/parsing/common/page.js +40 -0
- package/src/parsing/common/predictResponse.d.ts +6 -0
- package/src/parsing/common/predictResponse.js +12 -0
- package/src/parsing/common/prediction.d.ts +2 -0
- package/src/parsing/common/prediction.js +6 -0
- package/src/parsing/common/product.d.ts +4 -0
- package/src/parsing/common/product.js +2 -0
- package/src/parsing/common/stringDict.d.ts +3 -0
- package/src/parsing/common/stringDict.js +2 -0
- package/src/parsing/common/summaryHelper.d.ts +8 -0
- package/src/parsing/common/summaryHelper.js +22 -0
- package/src/parsing/custom/classificationField.d.ts +16 -0
- package/src/parsing/custom/classificationField.js +14 -0
- package/src/parsing/custom/index.d.ts +3 -0
- package/src/parsing/custom/index.js +12 -0
- package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
- package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
- package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
- package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
- package/src/parsing/index.d.ts +3 -0
- package/src/parsing/index.js +29 -0
- package/src/{fields → parsing/standard}/amount.d.ts +2 -2
- package/src/{fields → parsing/standard}/amount.js +5 -5
- package/src/{fields → parsing/standard}/base.d.ts +5 -5
- package/src/{fields → parsing/standard}/base.js +3 -2
- package/src/{fields → parsing/standard}/classification.d.ts +1 -1
- package/src/{fields → parsing/standard}/classification.js +3 -3
- package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
- package/src/parsing/standard/companyRegistration.js +14 -0
- package/src/{fields → parsing/standard}/date.d.ts +1 -1
- package/src/{fields → parsing/standard}/date.js +2 -2
- package/src/{fields → parsing/standard}/field.d.ts +3 -4
- package/src/{fields → parsing/standard}/field.js +6 -7
- package/src/parsing/standard/index.d.ts +12 -0
- package/src/parsing/standard/index.js +27 -0
- package/src/{fields → parsing/standard}/locale.d.ts +4 -4
- package/src/parsing/standard/locale.js +42 -0
- package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
- package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
- package/src/{fields → parsing/standard}/position.d.ts +2 -2
- package/src/{fields → parsing/standard}/position.js +5 -5
- package/src/{fields → parsing/standard}/tax.d.ts +3 -3
- package/src/{fields → parsing/standard}/tax.js +3 -3
- package/src/{fields → parsing/standard}/text.d.ts +2 -2
- package/src/{fields → parsing/standard}/text.js +4 -4
- package/src/parsing/standard/word.d.ts +10 -0
- package/src/parsing/standard/word.js +2 -0
- package/src/pdf/pdfOperation.d.ts +1 -1
- package/src/pdf/pdfOperation.js +3 -3
- package/src/product/cropper/cropperV1.d.ts +9 -0
- package/src/product/cropper/cropperV1.js +16 -0
- package/src/product/cropper/cropperV1Document.d.ts +8 -0
- package/src/product/cropper/cropperV1Document.js +26 -0
- package/src/product/custom/customV1.d.ts +10 -0
- package/src/product/custom/customV1.js +17 -0
- package/src/product/custom/customV1Document.d.ts +9 -0
- package/src/product/custom/customV1Document.js +43 -0
- package/src/product/custom/customV1Page.d.ts +7 -0
- package/src/product/custom/customV1Page.js +24 -0
- package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
- package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
- package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
- package/src/product/financialDocument/financialDocumentV1.js +16 -0
- package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
- package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
- package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
- package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
- package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
- package/src/product/fr/idCard/idCardV1.d.ts +10 -0
- package/src/product/fr/idCard/idCardV1.js +17 -0
- package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
- package/src/product/fr/idCard/idCardV1Document.js +70 -0
- package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
- package/src/product/fr/idCard/idCardV1Page.js +23 -0
- package/src/{documents → product}/index.d.ts +2 -7
- package/src/{documents → product}/index.js +3 -14
- package/src/product/invoice/invoiceV4.d.ts +9 -0
- package/src/product/invoice/invoiceV4.js +16 -0
- package/src/product/invoice/invoiceV4Document.d.ts +44 -0
- package/src/product/invoice/invoiceV4Document.js +146 -0
- package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
- package/src/product/invoice/invoiceV4LineItem.js +101 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
- package/src/product/passport/passportV1.d.ts +9 -0
- package/src/product/passport/passportV1.js +16 -0
- package/src/product/passport/passportV1Document.d.ts +31 -0
- package/src/product/passport/passportV1Document.js +75 -0
- package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
- package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
- package/src/product/receipt/receiptV4.d.ts +9 -0
- package/src/product/receipt/receiptV4.js +15 -0
- package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
- package/src/product/receipt/receiptV4Document.js +67 -0
- package/src/product/receipt/receiptV5.d.ts +9 -0
- package/src/product/receipt/receiptV5.js +16 -0
- package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
- package/src/product/receipt/receiptV5Document.js +108 -0
- package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
- package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
- package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
- package/src/product/us/bankCheck/bankCheckV1.js +17 -0
- package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
- package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
- package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
- package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
- package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
- package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
- package/src/product/us/index.d.ts +2 -0
- package/src/product/us/index.js +7 -0
- package/src/api/documentResponse.d.ts +0 -25
- package/src/api/documentResponse.js +0 -50
- package/src/api/endpoint.d.ts +0 -63
- package/src/api/endpoint.js +0 -216
- package/src/api/index.d.ts +0 -3
- package/src/api/index.js +0 -13
- package/src/api/predictResponse.d.ts +0 -33
- package/src/api/predictResponse.js +0 -52
- package/src/documents/cropper/cropperV1.d.ts +0 -7
- package/src/documents/cropper/cropperV1.js +0 -35
- package/src/documents/custom/customV1.d.ts +0 -10
- package/src/documents/custom/customV1.js +0 -53
- package/src/documents/document.d.ts +0 -47
- package/src/documents/document.js +0 -76
- package/src/documents/documentConfig.d.ts +0 -42
- package/src/documents/documentConfig.js +0 -118
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
- package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
- package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
- package/src/documents/financialDocument/financialDocumentV0.js +0 -140
- package/src/documents/financialDocument/financialDocumentV1.js +0 -197
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
- package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
- package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
- package/src/documents/fr/idCard/idCardV1.js +0 -79
- package/src/documents/invoice/checks.d.ts +0 -5
- package/src/documents/invoice/checks.js +0 -87
- package/src/documents/invoice/invoiceLineItem.js +0 -66
- package/src/documents/invoice/invoiceV3.d.ts +0 -49
- package/src/documents/invoice/invoiceV3.js +0 -156
- package/src/documents/invoice/invoiceV4.d.ts +0 -45
- package/src/documents/invoice/invoiceV4.js +0 -166
- package/src/documents/invoice/reconstruction.d.ts +0 -6
- package/src/documents/invoice/reconstruction.js +0 -78
- package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
- package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
- package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
- package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
- package/src/documents/passport/passportV1.d.ts +0 -43
- package/src/documents/passport/passportV1.js +0 -220
- package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
- package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
- package/src/documents/receipt/receiptV3.d.ts +0 -25
- package/src/documents/receipt/receiptV3.js +0 -136
- package/src/documents/receipt/receiptV4.js +0 -78
- package/src/documents/receipt/receiptV5.js +0 -137
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
- package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
- package/src/documents/us/index.d.ts +0 -1
- package/src/documents/us/index.js +0 -5
- package/src/fields/companyRegistration.js +0 -14
- package/src/fields/fullText.d.ts +0 -27
- package/src/fields/fullText.js +0 -92
- package/src/fields/index.d.ts +0 -12
- package/src/fields/index.js +0 -28
- package/src/fields/locale.js +0 -45
- package/src/math/index.d.ts +0 -1
- package/src/math/index.js +0 -5
- package/src/math/precision.d.ts +0 -1
- package/src/math/precision.js +0 -13
- /package/src/{inputs → input}/pageOptions.d.ts +0 -0
- /package/src/{inputs → input}/pageOptions.js +0 -0
- /package/src/{documents → product}/eu/index.d.ts +0 -0
- /package/src/{documents → product}/eu/index.js +0 -0
- /package/src/{documents → product}/fr/index.d.ts +0 -0
- /package/src/{documents → product}/fr/index.js +0 -0
package/src/client.d.ts
CHANGED
|
@@ -1,68 +1,28 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Readable } from "stream";
|
|
4
|
-
import { InputSource, PageOptions } from "./
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { DocumentConfig } from "./documents/documentConfig";
|
|
8
|
-
type DocConfigs = Map<string[], DocumentConfig<any>>;
|
|
4
|
+
import { InputSource, PageOptions } from "./input";
|
|
5
|
+
import { Endpoint } from "./http";
|
|
6
|
+
import { Inference, AsyncPredictResponse, StringDict, PredictResponse } from "./parsing/common";
|
|
9
7
|
export interface PredictOptions {
|
|
10
|
-
/**
|
|
11
|
-
* For custom endpoints, the "API name" field in the "Settings" page of the API Builder.
|
|
12
|
-
*
|
|
13
|
-
* Do not set for standard (off the shelf) endpoints.
|
|
14
|
-
*/
|
|
15
8
|
endpointName?: string;
|
|
16
|
-
/**
|
|
17
|
-
* For custom endpoints, your account or organization's username on the API Builder.
|
|
18
|
-
* This is normally not required unless you have a custom endpoint which has the
|
|
19
|
-
* same name as standard (off the shelf) endpoint.
|
|
20
|
-
*
|
|
21
|
-
* Do not set for standard (off the shelf) endpoints.
|
|
22
|
-
*/
|
|
23
9
|
accountName?: string;
|
|
10
|
+
endpointVersion?: string;
|
|
11
|
+
endpoint?: Endpoint;
|
|
24
12
|
/**
|
|
25
13
|
* Whether to include the full text for each page.
|
|
26
14
|
*
|
|
27
15
|
* This performs a full OCR operation on the server and will increase response time.
|
|
28
16
|
*/
|
|
29
|
-
|
|
17
|
+
allWords?: boolean;
|
|
30
18
|
/**
|
|
31
19
|
* Whether to include cropper results for each page.
|
|
32
20
|
*
|
|
33
21
|
* This performs a cropping operation on the server and will increase response time.
|
|
34
22
|
*/
|
|
35
23
|
cropper?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* If set, remove pages from the document as specified.
|
|
38
|
-
*
|
|
39
|
-
* This is done before sending the file to the server and is useful to avoid page limitations.
|
|
40
|
-
*/
|
|
41
24
|
pageOptions?: PageOptions;
|
|
42
25
|
}
|
|
43
|
-
export declare class DocumentClient {
|
|
44
|
-
docConfigs: DocConfigs;
|
|
45
|
-
inputSource?: InputSource;
|
|
46
|
-
constructor(docConfigs: DocConfigs, inputSource?: InputSource);
|
|
47
|
-
/**
|
|
48
|
-
* Send a document to a synchronous endpoint and parse the predictions.
|
|
49
|
-
* @param documentClass
|
|
50
|
-
* @param params
|
|
51
|
-
*/
|
|
52
|
-
parse<DocType extends Document>(documentClass: DocumentSig<DocType>, params?: PredictOptions): Promise<Response<DocType>>;
|
|
53
|
-
/**
|
|
54
|
-
* Send the document to an asynchronous endpoint and return its ID in the queue.
|
|
55
|
-
* @param documentClass
|
|
56
|
-
* @param params
|
|
57
|
-
*/
|
|
58
|
-
enqueue<DocType extends Document>(documentClass: DocumentSig<DocType>, params?: PredictOptions): Promise<AsyncPredictResponse<DocType>>;
|
|
59
|
-
parseQueued<DocType extends Document>(documentClass: DocumentSig<DocType>, queueId: string, params?: {
|
|
60
|
-
endpointName?: string;
|
|
61
|
-
accountName?: string;
|
|
62
|
-
}): Promise<AsyncPredictResponse<DocType>>;
|
|
63
|
-
protected getBooleanParam(param?: boolean): boolean;
|
|
64
|
-
protected getDocConfig<DocType extends Document>(documentClass: DocumentSig<DocType>, endpointName?: string, accountName?: string): DocumentConfig<DocType>;
|
|
65
|
-
}
|
|
66
26
|
export interface CustomConfigParams {
|
|
67
27
|
/** Your organization's username on the API Builder. */
|
|
68
28
|
accountName: string;
|
|
@@ -86,57 +46,66 @@ export interface ClientOptions {
|
|
|
86
46
|
* Mindee Client
|
|
87
47
|
*/
|
|
88
48
|
export declare class Client {
|
|
89
|
-
|
|
49
|
+
#private;
|
|
90
50
|
protected apiKey: string;
|
|
91
51
|
/**
|
|
92
52
|
* @param options
|
|
93
53
|
*/
|
|
94
|
-
constructor({ apiKey, throwOnError, debug
|
|
95
|
-
protected addStandardEndpoints(): void;
|
|
54
|
+
constructor({ apiKey, throwOnError, debug }?: ClientOptions);
|
|
96
55
|
/**
|
|
97
|
-
*
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @param version
|
|
56
|
+
* Send a document to a synchronous endpoint and parse the predictions.
|
|
57
|
+
* @param productClass
|
|
58
|
+
* @param params
|
|
101
59
|
*/
|
|
102
|
-
|
|
60
|
+
parse<T extends Inference>(productClass: new (httpResponse: StringDict) => T, inputSource: InputSource, params?: PredictOptions): Promise<PredictResponse<T>>;
|
|
61
|
+
/**
|
|
62
|
+
* Send the document to an asynchronous endpoint and return its ID in the queue.
|
|
63
|
+
* @param productClass
|
|
64
|
+
* @param params
|
|
65
|
+
*/
|
|
66
|
+
enqueue<T extends Inference>(productClass: new (httpResponse: StringDict) => T, inputSource: InputSource, params?: PredictOptions): Promise<AsyncPredictResponse<T>>;
|
|
67
|
+
parseQueued<T extends Inference>(productClass: new (httpResponse: StringDict) => T, queueId: string, params?: PredictOptions): Promise<AsyncPredictResponse<T>>;
|
|
68
|
+
protected getBooleanParam(param?: boolean): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a custom endpoint with the given values. Raises an error if the endpoint is invalid.
|
|
71
|
+
* @param productClass Class of the product
|
|
72
|
+
* @param endpointName Name of a custom Endpoint
|
|
73
|
+
* @param accountName Name of the account tied to the active Endpoint
|
|
74
|
+
* @param version Version of a custom Endpoint
|
|
75
|
+
*/
|
|
76
|
+
createEndpoint(endpointName: string, accountName: string, endpointVersion?: string): Endpoint;
|
|
103
77
|
/**
|
|
104
78
|
* Load an input document from a local path.
|
|
105
79
|
* @param inputPath
|
|
106
80
|
*/
|
|
107
|
-
docFromPath(inputPath: string):
|
|
81
|
+
docFromPath(inputPath: string): InputSource;
|
|
108
82
|
/**
|
|
109
83
|
* Load an input document from a base64 encoded string.
|
|
110
84
|
* @param inputString
|
|
111
85
|
* @param filename
|
|
112
86
|
*/
|
|
113
|
-
docFromBase64(inputString: string, filename: string):
|
|
87
|
+
docFromBase64(inputString: string, filename: string): InputSource;
|
|
114
88
|
/**
|
|
115
89
|
* Load an input document from a `stream.Readable` object.
|
|
116
90
|
* @param inputStream
|
|
117
91
|
* @param filename
|
|
118
92
|
*/
|
|
119
|
-
docFromStream(inputStream: Readable, filename: string):
|
|
93
|
+
docFromStream(inputStream: Readable, filename: string): InputSource;
|
|
120
94
|
/**
|
|
121
95
|
* Load an input document from a bytes string.
|
|
122
96
|
* @param inputBytes
|
|
123
97
|
* @param filename
|
|
124
98
|
*/
|
|
125
|
-
docFromBytes(inputBytes: string, filename: string):
|
|
99
|
+
docFromBytes(inputBytes: string, filename: string): InputSource;
|
|
126
100
|
/**
|
|
127
101
|
* Load an input document from a URL.
|
|
128
102
|
* @param url
|
|
129
103
|
*/
|
|
130
|
-
docFromUrl(url: string):
|
|
104
|
+
docFromUrl(url: string): InputSource;
|
|
131
105
|
/**
|
|
132
106
|
* Load an input document from a Buffer.
|
|
133
107
|
* @param buffer
|
|
134
108
|
* @param filename
|
|
135
109
|
*/
|
|
136
|
-
docFromBuffer(buffer: Buffer, filename: string):
|
|
137
|
-
/**
|
|
138
|
-
* Load an empty input document from an asynchronous call.
|
|
139
|
-
*/
|
|
140
|
-
docForAsync(): DocumentClient;
|
|
110
|
+
docFromBuffer(buffer: Buffer, filename: string): InputSource;
|
|
141
111
|
}
|
|
142
|
-
export {};
|
package/src/client.js
CHANGED
|
@@ -1,199 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _Client_instances, _Client_buildEndpoint, _Client_initializeOTSEndpoint, _Client_cleanAccountName, _Client_getEndpoint;
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client =
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const documentConfig_1 = require("./documents/documentConfig");
|
|
9
|
+
exports.Client = void 0;
|
|
10
|
+
const input_1 = require("./input");
|
|
11
|
+
const http_1 = require("./http");
|
|
12
|
+
const common_1 = require("./parsing/common");
|
|
8
13
|
const handler_1 = require("./errors/handler");
|
|
9
14
|
const logger_1 = require("./logger");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const inference_1 = require("./parsing/common/inference");
|
|
16
|
+
const product_1 = require("./product");
|
|
17
|
+
/**
|
|
18
|
+
* Mindee Client
|
|
19
|
+
*/
|
|
20
|
+
class Client {
|
|
21
|
+
/**
|
|
22
|
+
* @param options
|
|
23
|
+
*/
|
|
24
|
+
constructor({ apiKey, throwOnError, debug } = {
|
|
25
|
+
apiKey: "",
|
|
26
|
+
throwOnError: true,
|
|
27
|
+
debug: false,
|
|
28
|
+
}) {
|
|
29
|
+
_Client_instances.add(this);
|
|
30
|
+
this.apiKey = apiKey ? apiKey : "";
|
|
31
|
+
handler_1.errorHandler.throwOnError = throwOnError ?? true;
|
|
32
|
+
logger_1.logger.level =
|
|
33
|
+
debug ?? process.env.MINDEE_DEBUG
|
|
34
|
+
? logger_1.LOG_LEVELS["debug"]
|
|
35
|
+
: logger_1.LOG_LEVELS["warn"];
|
|
36
|
+
logger_1.logger.debug("Client initialized");
|
|
14
37
|
}
|
|
15
38
|
/**
|
|
16
39
|
* Send a document to a synchronous endpoint and parse the predictions.
|
|
17
|
-
* @param
|
|
40
|
+
* @param productClass
|
|
18
41
|
* @param params
|
|
19
42
|
*/
|
|
20
|
-
async parse(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
cropper: false,
|
|
43
|
+
async parse(productClass, inputSource, params = {
|
|
44
|
+
endpoint: undefined,
|
|
45
|
+
allWords: undefined,
|
|
46
|
+
cropper: undefined,
|
|
25
47
|
pageOptions: undefined,
|
|
26
48
|
}) {
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
49
|
+
const endpoint = params?.endpoint ?? __classPrivateFieldGet(this, _Client_instances, "m", _Client_initializeOTSEndpoint).call(this, productClass);
|
|
50
|
+
if (inputSource === undefined) {
|
|
29
51
|
throw new Error("The 'parse' function requires an input document.");
|
|
30
52
|
}
|
|
31
|
-
|
|
32
|
-
inputDoc:
|
|
33
|
-
includeWords: this.getBooleanParam(params.
|
|
53
|
+
const rawPrediction = await endpoint.predict({
|
|
54
|
+
inputDoc: inputSource,
|
|
55
|
+
includeWords: this.getBooleanParam(params.allWords),
|
|
34
56
|
pageOptions: params.pageOptions,
|
|
35
57
|
cropper: this.getBooleanParam(params.cropper),
|
|
36
58
|
});
|
|
59
|
+
return new common_1.PredictResponse(productClass, rawPrediction.data);
|
|
37
60
|
}
|
|
38
61
|
/**
|
|
39
62
|
* Send the document to an asynchronous endpoint and return its ID in the queue.
|
|
40
|
-
* @param
|
|
63
|
+
* @param productClass
|
|
41
64
|
* @param params
|
|
42
65
|
*/
|
|
43
|
-
async enqueue(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
cropper: false,
|
|
48
|
-
pageOptions: undefined,
|
|
49
|
-
}) {
|
|
50
|
-
const docConfig = this.getDocConfig(documentClass, params.endpointName, params.accountName);
|
|
51
|
-
if (this.inputSource === undefined) {
|
|
52
|
-
throw new Error("The 'enqueue' function requires an input document.");
|
|
66
|
+
async enqueue(productClass, inputSource, params = {}) {
|
|
67
|
+
const endpoint = params?.endpoint ?? __classPrivateFieldGet(this, _Client_instances, "m", _Client_initializeOTSEndpoint).call(this, productClass);
|
|
68
|
+
if (inputSource === undefined) {
|
|
69
|
+
throw new Error("The 'parse' function requires an input document.");
|
|
53
70
|
}
|
|
54
|
-
|
|
55
|
-
inputDoc:
|
|
56
|
-
includeWords: this.getBooleanParam(params.
|
|
57
|
-
pageOptions: params
|
|
71
|
+
const rawResponse = await endpoint.predictAsync({
|
|
72
|
+
inputDoc: inputSource,
|
|
73
|
+
includeWords: this.getBooleanParam(params.allWords),
|
|
74
|
+
pageOptions: params?.pageOptions,
|
|
58
75
|
cropper: this.getBooleanParam(params.cropper),
|
|
59
76
|
});
|
|
77
|
+
return new common_1.AsyncPredictResponse(productClass, rawResponse.data);
|
|
60
78
|
}
|
|
61
|
-
async parseQueued(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const docConfig = this.getDocConfig(documentClass, params.endpointName, params.accountName);
|
|
66
|
-
return await docConfig.getQueuedDocument(queueId);
|
|
79
|
+
async parseQueued(productClass, queueId, params = {}) {
|
|
80
|
+
const endpoint = params?.endpoint ?? __classPrivateFieldGet(this, _Client_instances, "m", _Client_initializeOTSEndpoint).call(this, productClass);
|
|
81
|
+
const docResponse = await endpoint.getQueuedDocument(queueId);
|
|
82
|
+
return new common_1.AsyncPredictResponse(productClass, docResponse.data);
|
|
67
83
|
}
|
|
68
84
|
getBooleanParam(param) {
|
|
69
85
|
return param !== undefined ? param : false;
|
|
70
86
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
throw `Document type not configured: '${docType}'`;
|
|
83
|
-
}
|
|
84
|
-
let configKey = [];
|
|
85
|
-
if (found.length === 1) {
|
|
86
|
-
configKey = found[0];
|
|
87
|
+
/**
|
|
88
|
+
* Creates a custom endpoint with the given values. Raises an error if the endpoint is invalid.
|
|
89
|
+
* @param productClass Class of the product
|
|
90
|
+
* @param endpointName Name of a custom Endpoint
|
|
91
|
+
* @param accountName Name of the account tied to the active Endpoint
|
|
92
|
+
* @param version Version of a custom Endpoint
|
|
93
|
+
*/
|
|
94
|
+
createEndpoint(endpointName, accountName, endpointVersion) {
|
|
95
|
+
const cleanAccountName = __classPrivateFieldGet(this, _Client_instances, "m", _Client_cleanAccountName).call(this, product_1.CustomV1, accountName);
|
|
96
|
+
if (!endpointName || endpointName.length === 0) {
|
|
97
|
+
throw new Error("Missing parameter 'endpointName' for custom build!");
|
|
87
98
|
}
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
let cleanEndpointVersion;
|
|
100
|
+
if (!endpointVersion || endpointVersion.length === 0) {
|
|
101
|
+
logger_1.logger.debug("Warning: No version provided for a custom build, will attempt to poll version 1 by default.");
|
|
102
|
+
cleanEndpointVersion = "1";
|
|
90
103
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// TODO: raise error printing all usernames
|
|
94
|
-
throw `Couldn't find the config '${configKey}'`;
|
|
104
|
+
else {
|
|
105
|
+
cleanEndpointVersion = endpointVersion;
|
|
95
106
|
}
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.DocumentClient = DocumentClient;
|
|
100
|
-
/**
|
|
101
|
-
* Mindee Client
|
|
102
|
-
*/
|
|
103
|
-
class Client {
|
|
104
|
-
/**
|
|
105
|
-
* @param options
|
|
106
|
-
*/
|
|
107
|
-
constructor({ apiKey = "", throwOnError = true, debug = false, }) {
|
|
108
|
-
this.docConfigs = new Map();
|
|
109
|
-
this.apiKey = apiKey;
|
|
110
|
-
handler_1.errorHandler.throwOnError = throwOnError;
|
|
111
|
-
logger_1.logger.level =
|
|
112
|
-
debug ?? process.env.MINDEE_DEBUG
|
|
113
|
-
? logger_1.LOG_LEVELS["debug"]
|
|
114
|
-
: logger_1.LOG_LEVELS["warn"];
|
|
115
|
-
logger_1.logger.debug("Client initialized");
|
|
116
|
-
this.addStandardEndpoints();
|
|
117
|
-
}
|
|
118
|
-
// TODO: init only those endpoints we actually need.
|
|
119
|
-
addStandardEndpoints() {
|
|
120
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.FinancialDocumentV0.name], new documentConfig_1.FinancialDocV0Config(this.apiKey));
|
|
121
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.FinancialDocumentV1.name], new documentConfig_1.DocumentConfig(documents_1.FinancialDocumentV1, [
|
|
122
|
-
new api_1.StandardEndpoint("financial_document", "1", this.apiKey),
|
|
123
|
-
]));
|
|
124
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV3.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV3, [
|
|
125
|
-
new api_1.StandardEndpoint("invoices", "3", this.apiKey),
|
|
126
|
-
]));
|
|
127
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceV4.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceV4, [
|
|
128
|
-
new api_1.StandardEndpoint("invoices", "4", this.apiKey),
|
|
129
|
-
]));
|
|
130
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.InvoiceSplitterV1.name], new documentConfig_1.DocumentConfig(documents_1.InvoiceSplitterV1, [
|
|
131
|
-
new api_1.StandardEndpoint("invoice_splitter", "1", this.apiKey),
|
|
132
|
-
]));
|
|
133
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV3.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV3, [
|
|
134
|
-
new api_1.StandardEndpoint("expense_receipts", "3", this.apiKey),
|
|
135
|
-
]));
|
|
136
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV4.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV4, [
|
|
137
|
-
new api_1.StandardEndpoint("expense_receipts", "4", this.apiKey),
|
|
138
|
-
]));
|
|
139
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ReceiptV5.name], new documentConfig_1.DocumentConfig(documents_1.ReceiptV5, [
|
|
140
|
-
new api_1.StandardEndpoint("expense_receipts", "5", this.apiKey),
|
|
141
|
-
]));
|
|
142
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.PassportV1.name], new documentConfig_1.DocumentConfig(documents_1.PassportV1, [
|
|
143
|
-
new api_1.StandardEndpoint("passport", "1", this.apiKey),
|
|
144
|
-
]));
|
|
145
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.CropperV1.name], new documentConfig_1.DocumentConfig(documents_1.CropperV1, [
|
|
146
|
-
new api_1.StandardEndpoint("cropper", "1", this.apiKey),
|
|
147
|
-
]));
|
|
148
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.IdCardV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.IdCardV1, [
|
|
149
|
-
new api_1.StandardEndpoint("idcard_fr", "1", this.apiKey),
|
|
150
|
-
]));
|
|
151
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.us.BankCheckV1.name], new documentConfig_1.DocumentConfig(documents_1.us.BankCheckV1, [
|
|
152
|
-
new api_1.StandardEndpoint("bank_check", "1", this.apiKey),
|
|
153
|
-
]));
|
|
154
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV1, [
|
|
155
|
-
new api_1.StandardEndpoint("bank_account_details", "1", this.apiKey),
|
|
156
|
-
]));
|
|
157
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.BankAccountDetailsV2.name], new documentConfig_1.DocumentConfig(documents_1.fr.BankAccountDetailsV2, [
|
|
158
|
-
new api_1.StandardEndpoint("bank_account_details", "2", this.apiKey),
|
|
159
|
-
]));
|
|
160
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.fr.CarteVitaleV1.name], new documentConfig_1.DocumentConfig(documents_1.fr.CarteVitaleV1, [
|
|
161
|
-
new api_1.StandardEndpoint("carte_vitale", "1", this.apiKey),
|
|
162
|
-
]));
|
|
163
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.eu.LicensePlateV1.name], new documentConfig_1.DocumentConfig(documents_1.eu.LicensePlateV1, [
|
|
164
|
-
new api_1.StandardEndpoint("license_plates", "1", this.apiKey),
|
|
165
|
-
]));
|
|
166
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.MindeeVisionV1.name], new documentConfig_1.DocumentConfig(documents_1.MindeeVisionV1, [
|
|
167
|
-
new api_1.StandardEndpoint("mindee_vision", "1", this.apiKey),
|
|
168
|
-
]));
|
|
169
|
-
this.docConfigs.set([api_1.STANDARD_API_OWNER, documents_1.ProofOfAddressV1.name], new documentConfig_1.DocumentConfig(documents_1.ProofOfAddressV1, [
|
|
170
|
-
new api_1.StandardEndpoint("proof_of_address", "1", this.apiKey),
|
|
171
|
-
]));
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Add a custom endpoint to the client.
|
|
175
|
-
* @param accountName
|
|
176
|
-
* @param endpointName
|
|
177
|
-
* @param version
|
|
178
|
-
*/
|
|
179
|
-
addEndpoint({ accountName, endpointName, version = "1", }) {
|
|
180
|
-
this.docConfigs.set([accountName, endpointName], new documentConfig_1.CustomDocConfig({
|
|
181
|
-
accountName: accountName,
|
|
182
|
-
endpointName: endpointName,
|
|
183
|
-
version: version,
|
|
184
|
-
apiKey: this.apiKey,
|
|
185
|
-
}));
|
|
186
|
-
return this;
|
|
107
|
+
return __classPrivateFieldGet(this, _Client_instances, "m", _Client_buildEndpoint).call(this, endpointName, cleanAccountName, cleanEndpointVersion);
|
|
187
108
|
}
|
|
188
109
|
/**
|
|
189
110
|
* Load an input document from a local path.
|
|
190
111
|
* @param inputPath
|
|
191
112
|
*/
|
|
192
113
|
docFromPath(inputPath) {
|
|
193
|
-
|
|
114
|
+
return new input_1.PathInput({
|
|
194
115
|
inputPath: inputPath,
|
|
195
116
|
});
|
|
196
|
-
return new DocumentClient(this.docConfigs, doc);
|
|
197
117
|
}
|
|
198
118
|
/**
|
|
199
119
|
* Load an input document from a base64 encoded string.
|
|
@@ -201,11 +121,10 @@ class Client {
|
|
|
201
121
|
* @param filename
|
|
202
122
|
*/
|
|
203
123
|
docFromBase64(inputString, filename) {
|
|
204
|
-
|
|
124
|
+
return new input_1.Base64Input({
|
|
205
125
|
inputString: inputString,
|
|
206
126
|
filename: filename,
|
|
207
127
|
});
|
|
208
|
-
return new DocumentClient(this.docConfigs, doc);
|
|
209
128
|
}
|
|
210
129
|
/**
|
|
211
130
|
* Load an input document from a `stream.Readable` object.
|
|
@@ -213,11 +132,10 @@ class Client {
|
|
|
213
132
|
* @param filename
|
|
214
133
|
*/
|
|
215
134
|
docFromStream(inputStream, filename) {
|
|
216
|
-
|
|
135
|
+
return new input_1.StreamInput({
|
|
217
136
|
inputStream: inputStream,
|
|
218
137
|
filename: filename,
|
|
219
138
|
});
|
|
220
|
-
return new DocumentClient(this.docConfigs, doc);
|
|
221
139
|
}
|
|
222
140
|
/**
|
|
223
141
|
* Load an input document from a bytes string.
|
|
@@ -225,21 +143,19 @@ class Client {
|
|
|
225
143
|
* @param filename
|
|
226
144
|
*/
|
|
227
145
|
docFromBytes(inputBytes, filename) {
|
|
228
|
-
|
|
146
|
+
return new input_1.BytesInput({
|
|
229
147
|
inputBytes: inputBytes,
|
|
230
148
|
filename: filename,
|
|
231
149
|
});
|
|
232
|
-
return new DocumentClient(this.docConfigs, doc);
|
|
233
150
|
}
|
|
234
151
|
/**
|
|
235
152
|
* Load an input document from a URL.
|
|
236
153
|
* @param url
|
|
237
154
|
*/
|
|
238
155
|
docFromUrl(url) {
|
|
239
|
-
|
|
156
|
+
return new input_1.UrlInput({
|
|
240
157
|
url: url,
|
|
241
158
|
});
|
|
242
|
-
return new DocumentClient(this.docConfigs, doc);
|
|
243
159
|
}
|
|
244
160
|
/**
|
|
245
161
|
* Load an input document from a Buffer.
|
|
@@ -247,17 +163,37 @@ class Client {
|
|
|
247
163
|
* @param filename
|
|
248
164
|
*/
|
|
249
165
|
docFromBuffer(buffer, filename) {
|
|
250
|
-
|
|
166
|
+
return new input_1.BufferInput({
|
|
251
167
|
buffer: buffer,
|
|
252
168
|
filename: filename,
|
|
253
169
|
});
|
|
254
|
-
return new DocumentClient(this.docConfigs, doc);
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Load an empty input document from an asynchronous call.
|
|
258
|
-
*/
|
|
259
|
-
docForAsync() {
|
|
260
|
-
return new DocumentClient(this.docConfigs);
|
|
261
170
|
}
|
|
262
171
|
}
|
|
263
172
|
exports.Client = Client;
|
|
173
|
+
_Client_instances = new WeakSet(), _Client_buildEndpoint = function _Client_buildEndpoint(endpointName, accountName, endpointVersion) {
|
|
174
|
+
const apiSettings = new http_1.MindeeApi({
|
|
175
|
+
apiKey: this.apiKey,
|
|
176
|
+
urlName: endpointName,
|
|
177
|
+
version: endpointVersion,
|
|
178
|
+
owner: accountName,
|
|
179
|
+
});
|
|
180
|
+
return new http_1.Endpoint(endpointName, accountName, endpointVersion, apiSettings);
|
|
181
|
+
}, _Client_initializeOTSEndpoint = function _Client_initializeOTSEndpoint(productClass) {
|
|
182
|
+
if (productClass.name === "CustomV1") {
|
|
183
|
+
throw new Error("Incorrect parameters for Custom build.");
|
|
184
|
+
}
|
|
185
|
+
const [endpointName, endpointVersion] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getEndpoint).call(this, productClass);
|
|
186
|
+
return __classPrivateFieldGet(this, _Client_instances, "m", _Client_buildEndpoint).call(this, endpointName, http_1.STANDARD_API_OWNER, endpointVersion);
|
|
187
|
+
}, _Client_cleanAccountName = function _Client_cleanAccountName(productClass, accountName) {
|
|
188
|
+
if (productClass.name === "CustomV1") {
|
|
189
|
+
if (!accountName || accountName.length === 0) {
|
|
190
|
+
logger_1.logger.debug(`Warning: no account name provided for custom build, ${http_1.STANDARD_API_OWNER} will be used by default`);
|
|
191
|
+
return http_1.STANDARD_API_OWNER;
|
|
192
|
+
}
|
|
193
|
+
return accountName;
|
|
194
|
+
}
|
|
195
|
+
return http_1.STANDARD_API_OWNER;
|
|
196
|
+
}, _Client_getEndpoint = function _Client_getEndpoint(productClass) {
|
|
197
|
+
const [endpointName, endpointVersion] = inference_1.InferenceFactory.getEndpoint(productClass);
|
|
198
|
+
return [endpointName, endpointVersion];
|
|
199
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BoundingBox, BBox } from "./boundingBox";
|
|
2
|
+
import { Polygon } from "./polygon";
|
|
3
|
+
/**
|
|
4
|
+
* Given a Polygon, calculate a polygon that encompasses all points.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getBoundingBox(polygon: Polygon): BoundingBox;
|
|
7
|
+
/**
|
|
8
|
+
* Given a BBox, generate the associated bounding box.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getBoundingBoxFromBBox(bbox: BBox): BoundingBox;
|
|
11
|
+
/**
|
|
12
|
+
* Given 2 bbox, merge them.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeBbox(bbox1: BBox, bbox2: BBox): BBox;
|
|
15
|
+
/**
|
|
16
|
+
* Given a Polygon, calculate a bounding box that encompasses all points.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getBbox(polygon: Polygon): BBox;
|
|
19
|
+
/**
|
|
20
|
+
* Given polygons, calculate a bounding box that encompasses all points.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getBBoxForPolygons(polygons: Polygon[]): BBox;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBBoxForPolygons = exports.getBbox = exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Given a Polygon, calculate a polygon that encompasses all points.
|
|
6
|
+
*/
|
|
7
|
+
function getBoundingBox(polygon) {
|
|
8
|
+
const bbox = getBbox(polygon);
|
|
9
|
+
return [
|
|
10
|
+
[bbox[0], bbox[1]],
|
|
11
|
+
[bbox[2], bbox[1]],
|
|
12
|
+
[bbox[2], bbox[3]],
|
|
13
|
+
[bbox[0], bbox[3]],
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
exports.getBoundingBox = getBoundingBox;
|
|
17
|
+
/**
|
|
18
|
+
* Given a BBox, generate the associated bounding box.
|
|
19
|
+
*/
|
|
20
|
+
function getBoundingBoxFromBBox(bbox) {
|
|
21
|
+
return [
|
|
22
|
+
[bbox[0], bbox[1]],
|
|
23
|
+
[bbox[2], bbox[1]],
|
|
24
|
+
[bbox[2], bbox[3]],
|
|
25
|
+
[bbox[0], bbox[3]],
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
exports.getBoundingBoxFromBBox = getBoundingBoxFromBBox;
|
|
29
|
+
/**
|
|
30
|
+
* Given 2 bbox, merge them.
|
|
31
|
+
*/
|
|
32
|
+
function mergeBbox(bbox1, bbox2) {
|
|
33
|
+
return [
|
|
34
|
+
Math.min(bbox1[0], bbox2[0]),
|
|
35
|
+
Math.min(bbox1[1], bbox2[1]),
|
|
36
|
+
Math.max(bbox1[2], bbox2[2]),
|
|
37
|
+
Math.max(bbox1[3], bbox2[3]),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
exports.mergeBbox = mergeBbox;
|
|
41
|
+
/**
|
|
42
|
+
* Given a Polygon, calculate a bounding box that encompasses all points.
|
|
43
|
+
*/
|
|
44
|
+
function getBbox(polygon) {
|
|
45
|
+
const allY = polygon.map((point) => point[1]);
|
|
46
|
+
const allX = polygon.map((point) => point[0]);
|
|
47
|
+
const yMin = Math.min(...allY);
|
|
48
|
+
const yMax = Math.max(...allY);
|
|
49
|
+
const xMin = Math.min(...allX);
|
|
50
|
+
const xMax = Math.max(...allX);
|
|
51
|
+
return [xMin, yMin, xMax, yMax];
|
|
52
|
+
}
|
|
53
|
+
exports.getBbox = getBbox;
|
|
54
|
+
/**
|
|
55
|
+
* Given polygons, calculate a bounding box that encompasses all points.
|
|
56
|
+
*/
|
|
57
|
+
function getBBoxForPolygons(polygons) {
|
|
58
|
+
const allY = polygons.flatMap((polygon) => polygon.map((point) => point[1]));
|
|
59
|
+
const allX = polygons.flatMap((polygon) => polygon.map((point) => point[0]));
|
|
60
|
+
const yMin = Math.min(...allY);
|
|
61
|
+
const yMax = Math.max(...allY);
|
|
62
|
+
const xMin = Math.min(...allX);
|
|
63
|
+
const xMax = Math.max(...allX);
|
|
64
|
+
return [xMin, yMin, xMax, yMax];
|
|
65
|
+
}
|
|
66
|
+
exports.getBBoxForPolygons = getBBoxForPolygons;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Polygon } from "./polygon";
|
|
2
|
+
export { compareOnX, compareOnY, getCentroid, isPointInPolygonX, isPointInPolygonY, relativeX, relativeY, getMinMaxX, getMinMaxY, } from "./polygonUtils";
|
|
3
|
+
export { BoundingBox, BBox } from "./boundingBox";
|
|
4
|
+
export { getBbox, getBBoxForPolygons, getBoundingBox, getBoundingBoxFromBBox, mergeBbox, } from "./boundingBoxUtils";
|
|
5
|
+
export { MinMax } from "./minMax";
|
|
6
|
+
export { Point } from "./point";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = exports.getBBoxForPolygons = exports.getBbox = exports.getMinMaxY = exports.getMinMaxX = exports.relativeY = exports.relativeX = exports.isPointInPolygonY = exports.isPointInPolygonX = exports.getCentroid = exports.compareOnY = exports.compareOnX = exports.Polygon = void 0;
|
|
4
|
+
var polygon_1 = require("./polygon");
|
|
5
|
+
Object.defineProperty(exports, "Polygon", { enumerable: true, get: function () { return polygon_1.Polygon; } });
|
|
6
|
+
var polygonUtils_1 = require("./polygonUtils");
|
|
7
|
+
Object.defineProperty(exports, "compareOnX", { enumerable: true, get: function () { return polygonUtils_1.compareOnX; } });
|
|
8
|
+
Object.defineProperty(exports, "compareOnY", { enumerable: true, get: function () { return polygonUtils_1.compareOnY; } });
|
|
9
|
+
Object.defineProperty(exports, "getCentroid", { enumerable: true, get: function () { return polygonUtils_1.getCentroid; } });
|
|
10
|
+
Object.defineProperty(exports, "isPointInPolygonX", { enumerable: true, get: function () { return polygonUtils_1.isPointInPolygonX; } });
|
|
11
|
+
Object.defineProperty(exports, "isPointInPolygonY", { enumerable: true, get: function () { return polygonUtils_1.isPointInPolygonY; } });
|
|
12
|
+
Object.defineProperty(exports, "relativeX", { enumerable: true, get: function () { return polygonUtils_1.relativeX; } });
|
|
13
|
+
Object.defineProperty(exports, "relativeY", { enumerable: true, get: function () { return polygonUtils_1.relativeY; } });
|
|
14
|
+
Object.defineProperty(exports, "getMinMaxX", { enumerable: true, get: function () { return polygonUtils_1.getMinMaxX; } });
|
|
15
|
+
Object.defineProperty(exports, "getMinMaxY", { enumerable: true, get: function () { return polygonUtils_1.getMinMaxY; } });
|
|
16
|
+
var boundingBoxUtils_1 = require("./boundingBoxUtils");
|
|
17
|
+
Object.defineProperty(exports, "getBbox", { enumerable: true, get: function () { return boundingBoxUtils_1.getBbox; } });
|
|
18
|
+
Object.defineProperty(exports, "getBBoxForPolygons", { enumerable: true, get: function () { return boundingBoxUtils_1.getBBoxForPolygons; } });
|
|
19
|
+
Object.defineProperty(exports, "getBoundingBox", { enumerable: true, get: function () { return boundingBoxUtils_1.getBoundingBox; } });
|
|
20
|
+
Object.defineProperty(exports, "getBoundingBoxFromBBox", { enumerable: true, get: function () { return boundingBoxUtils_1.getBoundingBoxFromBBox; } });
|
|
21
|
+
Object.defineProperty(exports, "mergeBbox", { enumerable: true, get: function () { return boundingBoxUtils_1.mergeBbox; } });
|