mindee 5.3.1 → 5.5.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 +12 -0
- package/package.json +1 -1
- package/src/http/apiCore.d.ts +1 -0
- package/src/http/apiCore.js +21 -3
- package/src/image/extractedImage.d.ts +5 -5
- package/src/image/extractedImage.js +2 -2
- package/src/image/extractedImages.d.ts +4 -0
- package/src/image/extractedImages.js +5 -0
- package/src/image/imageExtractor.d.ts +2 -2
- package/src/image/imageExtractor.js +4 -3
- package/src/image/index.d.ts +1 -0
- package/src/image/index.js +1 -0
- package/src/pdf/extractedPdf.d.ts +3 -2
- package/src/pdf/extractedPdf.js +4 -3
- package/src/pdf/extractedPdfs.d.ts +4 -0
- package/src/{v2/fileOperations/cropFiles.js → pdf/extractedPdfs.js} +1 -1
- package/src/pdf/index.d.ts +2 -0
- package/src/pdf/index.js +2 -0
- package/src/pdf/pdfExtractor.d.ts +2 -2
- package/src/pdf/pdfExtractor.js +1 -1
- package/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.d.ts +3 -3
- package/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.js +4 -4
- package/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.js +1 -1
- package/src/v2/client.d.ts +9 -1
- package/src/v2/client.js +17 -8
- package/src/v2/clientOptions/baseParameters.d.ts +3 -2
- package/src/v2/clientOptions/pollingOptions.d.ts +1 -1
- package/src/v2/clientOptions/pollingOptions.js +2 -2
- package/src/v2/fileOperations/crop.d.ts +4 -4
- package/src/v2/fileOperations/crop.js +5 -6
- package/src/v2/fileOperations/split.d.ts +3 -3
- package/src/v2/fileOperations/split.js +6 -6
- package/src/v2/http/mindeeApiV2.d.ts +23 -10
- package/src/v2/http/mindeeApiV2.js +79 -68
- package/src/v2/parsing/search/index.d.ts +4 -0
- package/src/v2/parsing/search/index.js +4 -0
- package/src/v2/parsing/search/modelWebhook.d.ts +19 -0
- package/src/v2/parsing/search/modelWebhook.js +10 -0
- package/src/v2/parsing/search/paginationMetadata.d.ts +24 -0
- package/src/v2/parsing/search/paginationMetadata.js +19 -0
- package/src/v2/parsing/search/searchModel.d.ts +25 -0
- package/src/v2/parsing/search/searchModel.js +19 -0
- package/src/v2/parsing/search/searchResponse.d.ts +19 -0
- package/src/v2/parsing/search/searchResponse.js +24 -0
- package/src/v2/product/crop/cropItem.d.ts +1 -1
- package/src/v2/product/crop/cropItem.js +3 -3
- package/src/v2/product/crop/cropResponse.d.ts +0 -8
- package/src/v2/product/crop/cropResponse.js +0 -9
- package/src/v2/product/crop/cropResult.d.ts +8 -0
- package/src/v2/product/crop/cropResult.js +9 -0
- package/src/v2/product/split/splitRange.d.ts +2 -1
- package/src/v2/product/split/splitRange.js +2 -2
- package/src/v2/product/split/splitResponse.d.ts +0 -7
- package/src/v2/product/split/splitResponse.js +0 -12
- package/src/v2/product/split/splitResult.d.ts +7 -0
- package/src/v2/product/split/splitResult.js +12 -0
- package/src/v2/fileOperations/cropFiles.d.ts +0 -4
- package/src/v2/fileOperations/splitFiles.d.ts +0 -4
- package/src/v2/fileOperations/splitFiles.js +0 -5
|
@@ -4,6 +4,7 @@ import { BaseParameters } from "../../v2/index.js";
|
|
|
4
4
|
import { JobResponse } from "../../v2/parsing/index.js";
|
|
5
5
|
import { InputSource } from "../../input/index.js";
|
|
6
6
|
import { BaseProduct } from "../../v2/product/baseProduct.js";
|
|
7
|
+
import { SearchResponse } from "../../v2/parsing/search/index.js";
|
|
7
8
|
/**
|
|
8
9
|
* Mindee V2 API handler.
|
|
9
10
|
*/
|
|
@@ -12,21 +13,33 @@ export declare class MindeeApiV2 {
|
|
|
12
13
|
settings: ApiSettings;
|
|
13
14
|
constructor(dispatcher?: Dispatcher, apiKey?: string);
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
16
|
+
* Search for models available to the account.
|
|
17
|
+
* @param name Optional name filter.
|
|
18
|
+
* @param modelType Optional model type filter.
|
|
19
|
+
* @returns a `Promise` containing the search response.
|
|
20
|
+
*/
|
|
21
|
+
reqGetSearchModel(name?: string, modelType?: string): Promise<SearchResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Sends a document to the inference queue.
|
|
24
|
+
* @param product Product to enqueue.
|
|
25
|
+
* @param inputSource Local or remote file as an input.
|
|
18
26
|
* @param params {ExtractionParameters} parameters relating to the enqueueing options.
|
|
19
|
-
* @throws Error if the server's response contains an error.
|
|
20
|
-
* @returns a `Promise` containing a job response.
|
|
21
27
|
*/
|
|
22
|
-
|
|
28
|
+
reqPostProductEnqueue(product: typeof BaseProduct, inputSource: InputSource, params: BaseParameters): Promise<JobResponse>;
|
|
23
29
|
/**
|
|
24
|
-
* Get the specified Job.
|
|
30
|
+
* Get the specified Job by its ID.
|
|
25
31
|
* Throws an error if the server's response contains an error.
|
|
26
32
|
* @param jobId The Job ID as returned by the enqueue request.
|
|
27
33
|
* @returns a `Promise` containing the job response.
|
|
28
34
|
*/
|
|
29
|
-
|
|
35
|
+
reqGetJobById(jobId: string): Promise<JobResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Get the specified Job from a polling URL.
|
|
38
|
+
* Throws an error if the server's response contains an error.
|
|
39
|
+
* @param pollingUrl The polling URL as returned by a Job's pollingUrl property.
|
|
40
|
+
* @returns a `Promise` containing the job response.
|
|
41
|
+
*/
|
|
42
|
+
reqGetJobByUrl(pollingUrl: string): Promise<JobResponse>;
|
|
30
43
|
/**
|
|
31
44
|
* Get the result of a queued document from the API.
|
|
32
45
|
* Throws an error if the server's response contains an error.
|
|
@@ -34,7 +47,7 @@ export declare class MindeeApiV2 {
|
|
|
34
47
|
* @param inferenceId The inference ID for the result.
|
|
35
48
|
* @returns a `Promise` containing the parsed result.
|
|
36
49
|
*/
|
|
37
|
-
|
|
50
|
+
reqGetProductResultById<P extends typeof BaseProduct>(product: P, inferenceId: string): Promise<InstanceType<P["responseClass"]>>;
|
|
38
51
|
/**
|
|
39
52
|
* Get the result of a queued document from the API.
|
|
40
53
|
* Throws an error if the server's response contains an error.
|
|
@@ -42,5 +55,5 @@ export declare class MindeeApiV2 {
|
|
|
42
55
|
* @param url The URL as returned by a Job's resultUrl property.
|
|
43
56
|
* @returns a `Promise` containing the parsed result.
|
|
44
57
|
*/
|
|
45
|
-
|
|
58
|
+
reqGetProductResultByUrl<P extends typeof BaseProduct>(product: P, url: string): Promise<InstanceType<P["responseClass"]>>;
|
|
46
59
|
}
|
|
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
3
|
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");
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _MindeeApiV2_instances, _MindeeApiV2_processResponse
|
|
6
|
+
var _MindeeApiV2_instances, _MindeeApiV2_processResponse;
|
|
7
7
|
import { ApiSettings } from "./apiSettings.js";
|
|
8
8
|
import { ErrorResponse, JobResponse, } from "../../v2/parsing/index.js";
|
|
9
9
|
import { sendRequestAndReadResponse } from "../../http/apiCore.js";
|
|
@@ -11,6 +11,7 @@ import { LocalInputSource } from "../../input/index.js";
|
|
|
11
11
|
import { MindeeDeserializationError, MindeeError } from "../../errors/index.js";
|
|
12
12
|
import { MindeeHttpErrorV2 } from "./errors.js";
|
|
13
13
|
import { logger } from "../../logger.js";
|
|
14
|
+
import { SearchResponse } from "../../v2/parsing/search/index.js";
|
|
14
15
|
/**
|
|
15
16
|
* Mindee V2 API handler.
|
|
16
17
|
*/
|
|
@@ -20,29 +21,82 @@ export class MindeeApiV2 {
|
|
|
20
21
|
this.settings = new ApiSettings({ dispatcher: dispatcher, apiKey: apiKey });
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
24
|
+
* Search for models available to the account.
|
|
25
|
+
* @param name Optional name filter.
|
|
26
|
+
* @param modelType Optional model type filter.
|
|
27
|
+
* @returns a `Promise` containing the search response.
|
|
28
|
+
*/
|
|
29
|
+
async reqGetSearchModel(name, modelType) {
|
|
30
|
+
const queryParams = {};
|
|
31
|
+
if (name)
|
|
32
|
+
queryParams["name"] = name;
|
|
33
|
+
if (modelType)
|
|
34
|
+
queryParams["model_type"] = modelType;
|
|
35
|
+
const options = {
|
|
36
|
+
method: "GET",
|
|
37
|
+
headers: this.settings.baseHeaders,
|
|
38
|
+
hostname: this.settings.hostname,
|
|
39
|
+
path: "/v2/search/models",
|
|
40
|
+
queryParams: queryParams,
|
|
41
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
42
|
+
};
|
|
43
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
44
|
+
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, SearchResponse);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sends a document to the inference queue.
|
|
48
|
+
* @param product Product to enqueue.
|
|
49
|
+
* @param inputSource Local or remote file as an input.
|
|
26
50
|
* @param params {ExtractionParameters} parameters relating to the enqueueing options.
|
|
27
|
-
* @throws Error if the server's response contains an error.
|
|
28
|
-
* @returns a `Promise` containing a job response.
|
|
29
51
|
*/
|
|
30
|
-
async
|
|
31
|
-
|
|
32
|
-
|
|
52
|
+
async reqPostProductEnqueue(product, inputSource, params) {
|
|
53
|
+
const form = params.getFormData();
|
|
54
|
+
if (inputSource instanceof LocalInputSource) {
|
|
55
|
+
form.set("file", new Blob([inputSource.fileObject]), inputSource.filename);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
form.set("url", inputSource.url);
|
|
59
|
+
}
|
|
60
|
+
const path = `/v2/products/${product.slug}/enqueue`;
|
|
61
|
+
const options = {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: this.settings.baseHeaders,
|
|
64
|
+
hostname: this.settings.hostname,
|
|
65
|
+
path: path,
|
|
66
|
+
body: form,
|
|
67
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
68
|
+
};
|
|
69
|
+
const result = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
33
70
|
if (result.data.error !== undefined) {
|
|
34
71
|
throw new MindeeHttpErrorV2(result.data.error);
|
|
35
72
|
}
|
|
36
73
|
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, result, JobResponse);
|
|
37
74
|
}
|
|
38
75
|
/**
|
|
39
|
-
* Get the specified Job.
|
|
76
|
+
* Get the specified Job by its ID.
|
|
40
77
|
* Throws an error if the server's response contains an error.
|
|
41
78
|
* @param jobId The Job ID as returned by the enqueue request.
|
|
42
79
|
* @returns a `Promise` containing the job response.
|
|
43
80
|
*/
|
|
44
|
-
async
|
|
45
|
-
|
|
81
|
+
async reqGetJobById(jobId) {
|
|
82
|
+
return this.reqGetJobByUrl(`https://${this.settings.hostname}/v2/jobs/${jobId}`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the specified Job from a polling URL.
|
|
86
|
+
* Throws an error if the server's response contains an error.
|
|
87
|
+
* @param pollingUrl The polling URL as returned by a Job's pollingUrl property.
|
|
88
|
+
* @returns a `Promise` containing the job response.
|
|
89
|
+
*/
|
|
90
|
+
async reqGetJobByUrl(pollingUrl) {
|
|
91
|
+
if (!pollingUrl.startsWith("https://")) {
|
|
92
|
+
throw new MindeeError(`Invalid URL: ${pollingUrl}`);
|
|
93
|
+
}
|
|
94
|
+
const options = {
|
|
95
|
+
method: "GET",
|
|
96
|
+
headers: this.settings.baseHeaders,
|
|
97
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
98
|
+
};
|
|
99
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options, pollingUrl);
|
|
46
100
|
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, JobResponse);
|
|
47
101
|
}
|
|
48
102
|
/**
|
|
@@ -52,9 +106,8 @@ export class MindeeApiV2 {
|
|
|
52
106
|
* @param inferenceId The inference ID for the result.
|
|
53
107
|
* @returns a `Promise` containing the parsed result.
|
|
54
108
|
*/
|
|
55
|
-
async
|
|
56
|
-
|
|
57
|
-
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, queueResponse, product.responseClass);
|
|
109
|
+
async reqGetProductResultById(product, inferenceId) {
|
|
110
|
+
return this.reqGetProductResultByUrl(product, `https://${this.settings.hostname}/v2/products/${product.slug}/results/${inferenceId}`);
|
|
58
111
|
}
|
|
59
112
|
/**
|
|
60
113
|
* Get the result of a queued document from the API.
|
|
@@ -63,9 +116,17 @@ export class MindeeApiV2 {
|
|
|
63
116
|
* @param url The URL as returned by a Job's resultUrl property.
|
|
64
117
|
* @returns a `Promise` containing the parsed result.
|
|
65
118
|
*/
|
|
66
|
-
async
|
|
67
|
-
const
|
|
68
|
-
|
|
119
|
+
async reqGetProductResultByUrl(product, url) {
|
|
120
|
+
const options = {
|
|
121
|
+
method: "GET",
|
|
122
|
+
headers: this.settings.baseHeaders,
|
|
123
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
124
|
+
};
|
|
125
|
+
if (!url.startsWith("https://")) {
|
|
126
|
+
throw new MindeeError(`Invalid URL: ${url}`);
|
|
127
|
+
}
|
|
128
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options, url);
|
|
129
|
+
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, product.responseClass);
|
|
69
130
|
}
|
|
70
131
|
}
|
|
71
132
|
_MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function _MindeeApiV2_processResponse(result, responseClass) {
|
|
@@ -88,54 +149,4 @@ _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_processResponse = function
|
|
|
88
149
|
logger.error(`Raised '${e}' Couldn't deserialize response object:\n${JSON.stringify(result.data)}`);
|
|
89
150
|
throw new MindeeDeserializationError("Couldn't deserialize response object.");
|
|
90
151
|
}
|
|
91
|
-
}, _MindeeApiV2_reqPostProductEnqueue =
|
|
92
|
-
/**
|
|
93
|
-
* Sends a document to the inference queue.
|
|
94
|
-
* @param product Product to enqueue.
|
|
95
|
-
* @param inputSource Local or remote file as an input.
|
|
96
|
-
* @param params {ExtractionParameters} parameters relating to the enqueueing options.
|
|
97
|
-
*/
|
|
98
|
-
async function _MindeeApiV2_reqPostProductEnqueue(product, inputSource, params) {
|
|
99
|
-
const form = params.getFormData();
|
|
100
|
-
if (inputSource instanceof LocalInputSource) {
|
|
101
|
-
form.set("file", new Blob([inputSource.fileObject]), inputSource.filename);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
form.set("url", inputSource.url);
|
|
105
|
-
}
|
|
106
|
-
const path = `/v2/products/${product.slug}/enqueue`;
|
|
107
|
-
const options = {
|
|
108
|
-
method: "POST",
|
|
109
|
-
headers: this.settings.baseHeaders,
|
|
110
|
-
hostname: this.settings.hostname,
|
|
111
|
-
path: path,
|
|
112
|
-
body: form,
|
|
113
|
-
timeoutSecs: this.settings.timeoutSecs,
|
|
114
|
-
};
|
|
115
|
-
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
116
|
-
}, _MindeeApiV2_reqGetJob = async function _MindeeApiV2_reqGetJob(jobId) {
|
|
117
|
-
const options = {
|
|
118
|
-
method: "GET",
|
|
119
|
-
headers: this.settings.baseHeaders,
|
|
120
|
-
hostname: this.settings.hostname,
|
|
121
|
-
path: `/v2/jobs/${jobId}`,
|
|
122
|
-
timeoutSecs: this.settings.timeoutSecs,
|
|
123
|
-
};
|
|
124
|
-
return await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
125
|
-
}, _MindeeApiV2_reqGetProductResult =
|
|
126
|
-
/**
|
|
127
|
-
* Make a request to GET the status of a document in the queue.
|
|
128
|
-
* @param url URL path to the result.
|
|
129
|
-
* @returns a `Promise` containing the parsed result.
|
|
130
|
-
*/
|
|
131
|
-
async function _MindeeApiV2_reqGetProductResult(url) {
|
|
132
|
-
const options = {
|
|
133
|
-
method: "GET",
|
|
134
|
-
headers: this.settings.baseHeaders,
|
|
135
|
-
timeoutSecs: this.settings.timeoutSecs,
|
|
136
|
-
};
|
|
137
|
-
if (!url.startsWith("https://")) {
|
|
138
|
-
throw new MindeeError(`Invalid URL: ${url}`);
|
|
139
|
-
}
|
|
140
|
-
return await sendRequestAndReadResponse(this.settings.dispatcher, options, url);
|
|
141
152
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Model webhook info.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ModelWebhook {
|
|
6
|
+
/**
|
|
7
|
+
* ID of the webhook.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Name of the webhook.
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* URL of the webhook.
|
|
16
|
+
*/
|
|
17
|
+
url: string;
|
|
18
|
+
constructor(serverResponse: StringDict);
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* PaginationMetadata data associated with model search.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PaginationMetadata {
|
|
6
|
+
/**
|
|
7
|
+
* Number of items per page.
|
|
8
|
+
*/
|
|
9
|
+
perPage: number;
|
|
10
|
+
/**
|
|
11
|
+
* 1-indexed page number.
|
|
12
|
+
*/
|
|
13
|
+
page: number;
|
|
14
|
+
/**
|
|
15
|
+
* Total items.
|
|
16
|
+
*/
|
|
17
|
+
totalItems: number;
|
|
18
|
+
/**
|
|
19
|
+
* Total number of pages.
|
|
20
|
+
*/
|
|
21
|
+
totalPages: number;
|
|
22
|
+
constructor(serverResponse: StringDict);
|
|
23
|
+
toString(): string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PaginationMetadata data associated with model search.
|
|
3
|
+
*/
|
|
4
|
+
export class PaginationMetadata {
|
|
5
|
+
constructor(serverResponse) {
|
|
6
|
+
this.perPage = serverResponse["per_page"];
|
|
7
|
+
this.page = serverResponse["page"];
|
|
8
|
+
this.totalItems = serverResponse["total_items"];
|
|
9
|
+
this.totalPages = serverResponse["total_pages"];
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return [
|
|
13
|
+
`:Per Page: ${this.perPage}`,
|
|
14
|
+
`:Page: ${this.page}`,
|
|
15
|
+
`:Total Items: ${this.totalItems}`,
|
|
16
|
+
`:Total Pages: ${this.totalPages}`,
|
|
17
|
+
].join("\n");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
import { ModelWebhook } from "./modelWebhook.js";
|
|
3
|
+
/**
|
|
4
|
+
* Models search response.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SearchModel {
|
|
7
|
+
/**
|
|
8
|
+
* ID of the model.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the model.
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Type of the model.
|
|
17
|
+
*/
|
|
18
|
+
modelType: string;
|
|
19
|
+
/**
|
|
20
|
+
* Webhooks associated with the model.
|
|
21
|
+
*/
|
|
22
|
+
webhooks: ModelWebhook[];
|
|
23
|
+
constructor(serverResponse: StringDict);
|
|
24
|
+
toString(): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModelWebhook } from "./modelWebhook.js";
|
|
2
|
+
/**
|
|
3
|
+
* Models search response.
|
|
4
|
+
*/
|
|
5
|
+
export class SearchModel {
|
|
6
|
+
constructor(serverResponse) {
|
|
7
|
+
this.id = serverResponse["id"];
|
|
8
|
+
this.name = serverResponse["name"];
|
|
9
|
+
this.modelType = serverResponse["model_type"];
|
|
10
|
+
this.webhooks = (serverResponse["webhooks"] ?? []).map((webhook) => new ModelWebhook(webhook));
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return [
|
|
14
|
+
`:Name: ${this.name}`,
|
|
15
|
+
`:ID: ${this.id}`,
|
|
16
|
+
`:Model Type: ${this.modelType}`,
|
|
17
|
+
].join("\n");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
+
import { BaseResponse } from "../../../v2/parsing/baseResponse.js";
|
|
3
|
+
import { PaginationMetadata } from "./paginationMetadata.js";
|
|
4
|
+
import { SearchModel } from "./searchModel.js";
|
|
5
|
+
/**
|
|
6
|
+
* Models search response.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SearchResponse extends BaseResponse {
|
|
9
|
+
/**
|
|
10
|
+
* List of models returned by the search.
|
|
11
|
+
*/
|
|
12
|
+
models: SearchModel[];
|
|
13
|
+
/**
|
|
14
|
+
* Pagination metadata.
|
|
15
|
+
*/
|
|
16
|
+
pagination: PaginationMetadata;
|
|
17
|
+
constructor(serverResponse: StringDict);
|
|
18
|
+
toString(): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseResponse } from "../../../v2/parsing/baseResponse.js";
|
|
2
|
+
import { PaginationMetadata } from "./paginationMetadata.js";
|
|
3
|
+
import { SearchModel } from "./searchModel.js";
|
|
4
|
+
/**
|
|
5
|
+
* Models search response.
|
|
6
|
+
*/
|
|
7
|
+
export class SearchResponse extends BaseResponse {
|
|
8
|
+
constructor(serverResponse) {
|
|
9
|
+
super(serverResponse);
|
|
10
|
+
this.models = (serverResponse["models"] ?? []).map((model) => new SearchModel(model));
|
|
11
|
+
this.pagination = new PaginationMetadata(serverResponse["pagination"]);
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
const lines = ["Models", "#######"];
|
|
15
|
+
for (const model of this.models) {
|
|
16
|
+
lines.push(`* :Name: ${model.name}`);
|
|
17
|
+
lines.push(` :ID: ${model.id}`);
|
|
18
|
+
lines.push(` :Model Type: ${model.modelType}`);
|
|
19
|
+
}
|
|
20
|
+
lines.push("Pagination", "##########");
|
|
21
|
+
lines.push(this.pagination.toString());
|
|
22
|
+
return lines.join("\n");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -23,5 +23,5 @@ export declare class CropItem {
|
|
|
23
23
|
* @param inputSource The input file to extract from.
|
|
24
24
|
* @param quality Optional quality parameter for image extraction, default is undefined (full quality).
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
extractFromInputSource(inputSource: LocalInputSource, quality?: number): Promise<ExtractedImage>;
|
|
27
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldLocation } from "../../../v2/parsing/inference/field/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractSingleCrop } from "../../../v2/fileOperations/crop.js";
|
|
3
3
|
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
4
4
|
export class CropItem {
|
|
5
5
|
constructor(serverResponse) {
|
|
@@ -17,7 +17,7 @@ export class CropItem {
|
|
|
17
17
|
* @param inputSource The input file to extract from.
|
|
18
18
|
* @param quality Optional quality parameter for image extraction, default is undefined (full quality).
|
|
19
19
|
*/
|
|
20
|
-
async
|
|
21
|
-
return (await
|
|
20
|
+
async extractFromInputSource(inputSource, quality = 1) {
|
|
21
|
+
return (await extractSingleCrop(inputSource, this, quality));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { LocalInputSource } from "../../../input/index.js";
|
|
2
1
|
import { StringDict } from "../../../parsing/stringDict.js";
|
|
3
|
-
import { CropFiles } from "../../../v2/fileOperations/cropFiles.js";
|
|
4
2
|
import { BaseResponse } from "../../../v2/parsing/index.js";
|
|
5
3
|
import { CropInference } from "./cropInference.js";
|
|
6
4
|
export declare class CropResponse extends BaseResponse {
|
|
@@ -12,10 +10,4 @@ export declare class CropResponse extends BaseResponse {
|
|
|
12
10
|
* @param serverResponse JSON response from the server.
|
|
13
11
|
*/
|
|
14
12
|
constructor(serverResponse: StringDict);
|
|
15
|
-
/**
|
|
16
|
-
* Extracts all crops from an input.
|
|
17
|
-
* @param inputSource The input file to extract from.
|
|
18
|
-
* @param quality Optional quality parameter for image extraction, default is undefined (full quality).
|
|
19
|
-
*/
|
|
20
|
-
extractFromFile(inputSource: LocalInputSource, quality?: number): Promise<CropFiles>;
|
|
21
13
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { extractCrops } from "../../../v2/fileOperations/crop.js";
|
|
2
1
|
import { BaseResponse } from "../../../v2/parsing/index.js";
|
|
3
2
|
import { CropInference } from "./cropInference.js";
|
|
4
3
|
export class CropResponse extends BaseResponse {
|
|
@@ -9,12 +8,4 @@ export class CropResponse extends BaseResponse {
|
|
|
9
8
|
super(serverResponse);
|
|
10
9
|
this.inference = new CropInference(serverResponse["inference"]);
|
|
11
10
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Extracts all crops from an input.
|
|
14
|
-
* @param inputSource The input file to extract from.
|
|
15
|
-
* @param quality Optional quality parameter for image extraction, default is undefined (full quality).
|
|
16
|
-
*/
|
|
17
|
-
async extractFromFile(inputSource, quality = 1) {
|
|
18
|
-
return await extractCrops(inputSource, this.inference.result.crops, quality);
|
|
19
|
-
}
|
|
20
11
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/stringDict.js";
|
|
2
2
|
import { CropItem } from "../../../v2/product/crop/cropItem.js";
|
|
3
|
+
import { LocalInputSource } from "../../../input/index.js";
|
|
4
|
+
import { ExtractedImages } from "../../../image/extractedImages.js";
|
|
3
5
|
export declare class CropResult {
|
|
4
6
|
/**
|
|
5
7
|
* Fields contained in the inference.
|
|
@@ -7,4 +9,10 @@ export declare class CropResult {
|
|
|
7
9
|
crops: CropItem[];
|
|
8
10
|
constructor(serverResponse: StringDict);
|
|
9
11
|
toString(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Extracts a single crop from an input.
|
|
14
|
+
* @param inputSource The input file to extract from.
|
|
15
|
+
* @param quality Optional quality parameter for image extraction, default is undefined (full quality).
|
|
16
|
+
*/
|
|
17
|
+
extractFromInputSource(inputSource: LocalInputSource, quality?: number): Promise<ExtractedImages>;
|
|
10
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CropItem } from "../../../v2/product/crop/cropItem.js";
|
|
2
|
+
import { extractMultipleCrops } from "../../../v2/fileOperations/crop.js";
|
|
2
3
|
export class CropResult {
|
|
3
4
|
constructor(serverResponse) {
|
|
4
5
|
/**
|
|
@@ -11,4 +12,12 @@ export class CropResult {
|
|
|
11
12
|
const crops = this.crops.map(item => item.toString()).join("\n");
|
|
12
13
|
return `Crops\n=====\n${crops}`;
|
|
13
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Extracts a single crop from an input.
|
|
17
|
+
* @param inputSource The input file to extract from.
|
|
18
|
+
* @param quality Optional quality parameter for image extraction, default is undefined (full quality).
|
|
19
|
+
*/
|
|
20
|
+
async extractFromInputSource(inputSource, quality = 1) {
|
|
21
|
+
return (await extractMultipleCrops(inputSource, this.crops, quality));
|
|
22
|
+
}
|
|
14
23
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/index.js";
|
|
2
2
|
import { LocalInputSource } from "../../../input/index.js";
|
|
3
3
|
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
4
|
+
import { ExtractedPdf } from "../../../pdf/index.js";
|
|
4
5
|
/**
|
|
5
6
|
* Split inference result.
|
|
6
7
|
*/
|
|
@@ -24,5 +25,5 @@ export declare class SplitRange {
|
|
|
24
25
|
* Extracts a single split from the input file.
|
|
25
26
|
* @param inputSource The input file to extract from.
|
|
26
27
|
*/
|
|
27
|
-
extractFromFile(inputSource: LocalInputSource): Promise<
|
|
28
|
+
extractFromFile(inputSource: LocalInputSource): Promise<ExtractedPdf>;
|
|
28
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expandRange,
|
|
1
|
+
import { expandRange, extractMultipleSplits } from "../../../v2/fileOperations/split.js";
|
|
2
2
|
import { ExtractionResponse } from "../../../v2/product/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Split inference result.
|
|
@@ -21,6 +21,6 @@ export class SplitRange {
|
|
|
21
21
|
*/
|
|
22
22
|
async extractFromFile(inputSource) {
|
|
23
23
|
const pageRange = [expandRange(this.pageRange)];
|
|
24
|
-
return (await
|
|
24
|
+
return (await extractMultipleSplits(inputSource, pageRange))[0];
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/stringDict.js";
|
|
2
2
|
import { SplitInference } from "./splitInference.js";
|
|
3
3
|
import { BaseResponse } from "../../../v2/parsing/index.js";
|
|
4
|
-
import { LocalInputSource } from "../../../input/index.js";
|
|
5
|
-
import { SplitFiles } from "../../../v2/fileOperations/splitFiles.js";
|
|
6
4
|
export declare class SplitResponse extends BaseResponse {
|
|
7
5
|
/**
|
|
8
6
|
* Response for an OCR utility inference.
|
|
@@ -12,9 +10,4 @@ export declare class SplitResponse extends BaseResponse {
|
|
|
12
10
|
* @param serverResponse JSON response from the server.
|
|
13
11
|
*/
|
|
14
12
|
constructor(serverResponse: StringDict);
|
|
15
|
-
/**
|
|
16
|
-
* Extracts all splits from an input PDF.
|
|
17
|
-
* @param inputSource The input file to extract from.
|
|
18
|
-
*/
|
|
19
|
-
extractFromFile(inputSource: LocalInputSource): Promise<SplitFiles>;
|
|
20
13
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SplitInference } from "./splitInference.js";
|
|
2
2
|
import { BaseResponse } from "../../../v2/parsing/index.js";
|
|
3
|
-
import { expandRange, extractSplits } from "../../../v2/fileOperations/split.js";
|
|
4
3
|
export class SplitResponse extends BaseResponse {
|
|
5
4
|
/**
|
|
6
5
|
* @param serverResponse JSON response from the server.
|
|
@@ -9,15 +8,4 @@ export class SplitResponse extends BaseResponse {
|
|
|
9
8
|
super(serverResponse);
|
|
10
9
|
this.inference = new SplitInference(serverResponse["inference"]);
|
|
11
10
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Extracts all splits from an input PDF.
|
|
14
|
-
* @param inputSource The input file to extract from.
|
|
15
|
-
*/
|
|
16
|
-
async extractFromFile(inputSource) {
|
|
17
|
-
const splits = [];
|
|
18
|
-
for (const split of this.inference.result.splits) {
|
|
19
|
-
splits.push(expandRange(split.pageRange));
|
|
20
|
-
}
|
|
21
|
-
return await extractSplits(inputSource, splits);
|
|
22
|
-
}
|
|
23
11
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SplitRange } from "./splitRange.js";
|
|
2
2
|
import { StringDict } from "../../../parsing/index.js";
|
|
3
|
+
import { LocalInputSource } from "../../../input/index.js";
|
|
4
|
+
import { ExtractedPdfs } from "../../../pdf/index.js";
|
|
3
5
|
/**
|
|
4
6
|
* Split result info.
|
|
5
7
|
*/
|
|
@@ -9,5 +11,10 @@ export declare class SplitResult {
|
|
|
9
11
|
*/
|
|
10
12
|
splits: SplitRange[];
|
|
11
13
|
constructor(rawResponse: StringDict);
|
|
14
|
+
/**
|
|
15
|
+
* Extracts all splits from an input PDF.
|
|
16
|
+
* @param inputSource The input file to extract from.
|
|
17
|
+
*/
|
|
18
|
+
extractFromInputSource(inputSource: LocalInputSource): Promise<ExtractedPdfs>;
|
|
12
19
|
toString(): string;
|
|
13
20
|
}
|