mindee 4.29.0-rc1 → 4.29.0-rc2
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 +4 -0
- package/README.md +22 -146
- package/package.json +1 -1
- package/src/client.d.ts +37 -2
- package/src/client.js +64 -3
- package/src/clientV2.d.ts +37 -3
- package/src/clientV2.js +64 -3
- package/src/index.d.ts +1 -1
- package/src/baseClient.d.ts +0 -38
- package/src/baseClient.js +0 -69
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -3,163 +3,39 @@
|
|
|
3
3
|
# Mindee API Helper Library for Node.js
|
|
4
4
|
Quickly and easily connect to Mindee's API services using Node.js.
|
|
5
5
|
|
|
6
|
-
##
|
|
7
|
-
|
|
6
|
+
## Mindee API Versions
|
|
7
|
+
This client library has support for both Mindee platform versions.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Latest - V2
|
|
10
|
+
This is the new platform located here:
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
```shell
|
|
13
|
-
npm install mindee
|
|
14
|
-
```
|
|
12
|
+
https://app.mindee.com
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
It uses **API version 2**.
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
Consult the
|
|
17
|
+
**[Latest Documentation](https://docs.mindee.com/integrations/client-libraries-sdk)**
|
|
19
18
|
|
|
20
|
-
#### Global Documents
|
|
21
|
-
```js
|
|
22
|
-
const mindee = require("mindee");
|
|
23
|
-
// for TS or modules:
|
|
24
|
-
// import * as mindee from "mindee";
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
### Legacy - V1
|
|
21
|
+
This is the legacy platform located here:
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
|
|
23
|
+
https://platform.mindee.com/
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
const apiResponse = mindeeClient.parse(mindee.product.InvoiceV4, inputSource);
|
|
34
|
-
```
|
|
25
|
+
It uses **API version 1**.
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
A base64 encoded string:
|
|
39
|
-
```js
|
|
40
|
-
const inputSource = mindeeClient.docFromBase64(myInputString, "my-file-name.ext")
|
|
41
|
-
```
|
|
27
|
+
Consult the
|
|
28
|
+
**[Legacy Documentation](https://developers.mindee.com/docs/nodejs-getting-started)**
|
|
42
29
|
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const inputSource = mindeeClient.docFromBytes(myInputBytes, "my-file-name.ext")
|
|
46
|
-
```
|
|
30
|
+
## Additional Information
|
|
47
31
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const inputSource = mindeeClient.docFromBuffer(myBuffer, "my-file-name.ext")
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
A URL (`https` only):
|
|
59
|
-
```js
|
|
60
|
-
const inputSource = mindeeClient.docFromUrl("https://my-url");
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
You can also load the document locally before sending it:
|
|
64
|
-
```js
|
|
65
|
-
const inputSource = mindeeClient.docFromUrl("https://my-url");
|
|
66
|
-
await inputSource.init();
|
|
67
|
-
const localInputSource = inputSource.asLocalInputSource();
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**Note:** Files hidden behind redirections are rejected by the server; this solution helps to circumvent that issue.
|
|
71
|
-
|
|
72
|
-
#### Region-Specific Documents
|
|
73
|
-
|
|
74
|
-
Region-Specific Documents use the following syntax:
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
const mindee = require("mindee");
|
|
78
|
-
// for TS or modules:
|
|
79
|
-
// import * as mindee from "mindee";
|
|
80
|
-
|
|
81
|
-
const mindeeClient = new mindee.Client({ apiKey: "my-api-key" });
|
|
82
|
-
|
|
83
|
-
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
|
|
84
|
-
|
|
85
|
-
// The IdCardV1 product belongs to mindee.product.fr, not mindee.product itself
|
|
86
|
-
const apiResponse = mindeeClient.parse(mindee.product.fr.IdCardV1, inputSource);
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
#### Custom Documents (docTI & Custom APIs)
|
|
90
|
-
|
|
91
|
-
Custom documents will require you to provide their endpoint manually.
|
|
92
|
-
|
|
93
|
-
```js
|
|
94
|
-
const mindee = require("mindee");
|
|
95
|
-
// for TS or modules:
|
|
96
|
-
// import * as mindee from "mindee";
|
|
97
|
-
|
|
98
|
-
// Init a new client
|
|
99
|
-
const mindeeClient = new mindee.Client({
|
|
100
|
-
apiKey: "my-api-key"
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Load a file from disk
|
|
104
|
-
const inputSource = mindeeClient.docFromPath("/path/to/the/file.ext");
|
|
105
|
-
|
|
106
|
-
// Create a custom endpoint for your product
|
|
107
|
-
const customEndpoint = mindeeClient.createEndpoint(
|
|
108
|
-
"my-endpoint",
|
|
109
|
-
"my-account",
|
|
110
|
-
"my-version" // will default to 1 if not provided
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
// Parse it
|
|
114
|
-
const apiResponse = await mindeeClient
|
|
115
|
-
.enqueueAndParse(
|
|
116
|
-
mindee.product.GeneratedV1,
|
|
117
|
-
inputSource,
|
|
118
|
-
{
|
|
119
|
-
endpoint: customEndpoint
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Handling the Return
|
|
125
|
-
```js
|
|
126
|
-
// Handle the response Promise
|
|
127
|
-
apiResponse.then((resp) => {
|
|
128
|
-
// print a string summary
|
|
129
|
-
console.log(resp.document.toString());
|
|
130
|
-
|
|
131
|
-
// individual pages (array)
|
|
132
|
-
console.log(res.document.inference.pages);
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Additional Options
|
|
137
|
-
Options to pass when sending a file to be parsed.
|
|
138
|
-
|
|
139
|
-
#### Page Options
|
|
140
|
-
Allows only sending certain pages in a PDF.
|
|
141
|
-
|
|
142
|
-
In this example we only send the first, penultimate, and last pages:
|
|
143
|
-
|
|
144
|
-
```js
|
|
145
|
-
const apiResponse = mindeeClient.parse(
|
|
146
|
-
mindee.product.InvoiceV4,
|
|
147
|
-
inputSource,
|
|
148
|
-
{
|
|
149
|
-
pageOptions: {
|
|
150
|
-
pageIndexes: [0, -2, -1],
|
|
151
|
-
operation: mindee.PageOptionsOperation.KeepOnly,
|
|
152
|
-
onMinPages: 2
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
You can also take a look at the **[Reference Documentation](https://mindee.github.io/mindee-api-nodejs/)**.
|
|
158
|
-
|
|
159
|
-
## License
|
|
32
|
+
**[Source Code](https://github.com/mindee/mindee-api-nodejs)**
|
|
33
|
+
|
|
34
|
+
**[Reference Documentation](https://mindee.github.io/mindee-api-nodejs/)**
|
|
35
|
+
|
|
36
|
+
**[Feedback](https://feedback.mindee.com/)**
|
|
37
|
+
|
|
38
|
+
### License
|
|
160
39
|
Copyright © Mindee
|
|
161
40
|
|
|
162
41
|
Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
163
|
-
|
|
164
|
-
## Questions?
|
|
165
|
-
[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
|
package/package.json
CHANGED
package/src/client.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { Endpoint } from "./http";
|
|
|
3
3
|
import { AsyncPredictResponse, ExecutionPriority, FeedbackResponse, Inference, PredictResponse, StringDict } from "./parsing/common";
|
|
4
4
|
import { GeneratedV1 } from "./product";
|
|
5
5
|
import { WorkflowResponse } from "./parsing/common/workflowResponse";
|
|
6
|
-
import {
|
|
6
|
+
import { Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput } from "./input";
|
|
7
|
+
import { Readable } from "stream";
|
|
7
8
|
/**
|
|
8
9
|
* Common options for workflows & predictions.
|
|
9
10
|
*/
|
|
@@ -103,7 +104,7 @@ export interface ClientOptions {
|
|
|
103
104
|
*
|
|
104
105
|
* @category Client
|
|
105
106
|
*/
|
|
106
|
-
export declare class Client
|
|
107
|
+
export declare class Client {
|
|
107
108
|
#private;
|
|
108
109
|
/** Key of the API. */
|
|
109
110
|
protected apiKey: string;
|
|
@@ -211,5 +212,39 @@ export declare class Client extends BaseClient {
|
|
|
211
212
|
* @returns Endpoint a new product endpoint
|
|
212
213
|
*/
|
|
213
214
|
createEndpoint(endpointName: string, accountName: string, endpointVersion?: string): Endpoint;
|
|
215
|
+
/**
|
|
216
|
+
* Load an input document from a local path.
|
|
217
|
+
* @param inputPath
|
|
218
|
+
*/
|
|
219
|
+
docFromPath(inputPath: string): PathInput;
|
|
220
|
+
/**
|
|
221
|
+
* Load an input document from a base64 encoded string.
|
|
222
|
+
* @param inputString input content, as a string.
|
|
223
|
+
* @param filename file name.
|
|
224
|
+
*/
|
|
225
|
+
docFromBase64(inputString: string, filename: string): Base64Input;
|
|
226
|
+
/**
|
|
227
|
+
* Load an input document from a `stream.Readable` object.
|
|
228
|
+
* @param inputStream input content, as a readable stream.
|
|
229
|
+
* @param filename file name.
|
|
230
|
+
*/
|
|
231
|
+
docFromStream(inputStream: Readable, filename: string): StreamInput;
|
|
232
|
+
/**
|
|
233
|
+
* Load an input document from bytes.
|
|
234
|
+
* @param inputBytes input content, as a Uint8Array or Buffer.
|
|
235
|
+
* @param filename file name.
|
|
236
|
+
*/
|
|
237
|
+
docFromBytes(inputBytes: Uint8Array, filename: string): BytesInput;
|
|
238
|
+
/**
|
|
239
|
+
* Load an input document from a URL.
|
|
240
|
+
* @param url input url. Must be HTTPS.
|
|
241
|
+
*/
|
|
242
|
+
docFromUrl(url: string): UrlInput;
|
|
243
|
+
/**
|
|
244
|
+
* Load an input document from a Buffer.
|
|
245
|
+
* @param buffer input content, as a buffer.
|
|
246
|
+
* @param filename file name.
|
|
247
|
+
*/
|
|
248
|
+
docFromBuffer(buffer: Buffer, filename: string): BufferInput;
|
|
214
249
|
}
|
|
215
250
|
export {};
|
package/src/client.js
CHANGED
|
@@ -17,13 +17,13 @@ const promises_1 = require("node:timers/promises");
|
|
|
17
17
|
const errors_1 = require("./errors");
|
|
18
18
|
const workflowResponse_1 = require("./parsing/common/workflowResponse");
|
|
19
19
|
const workflowEndpoint_1 = require("./http/workflowEndpoint");
|
|
20
|
-
const
|
|
20
|
+
const input_1 = require("./input");
|
|
21
21
|
/**
|
|
22
22
|
* Mindee Client class that centralizes most basic operations.
|
|
23
23
|
*
|
|
24
24
|
* @category Client
|
|
25
25
|
*/
|
|
26
|
-
class Client
|
|
26
|
+
class Client {
|
|
27
27
|
/**
|
|
28
28
|
* @param {ClientOptions} options options for the initialization of a client.
|
|
29
29
|
*/
|
|
@@ -32,7 +32,6 @@ class Client extends baseClient_1.BaseClient {
|
|
|
32
32
|
throwOnError: true,
|
|
33
33
|
debug: false,
|
|
34
34
|
}) {
|
|
35
|
-
super();
|
|
36
35
|
_Client_instances.add(this);
|
|
37
36
|
this.apiKey = apiKey ? apiKey : "";
|
|
38
37
|
handler_1.errorHandler.throwOnError = throwOnError ?? true;
|
|
@@ -271,6 +270,68 @@ Job status: ${pollResults.job.status}.`);
|
|
|
271
270
|
}
|
|
272
271
|
return __classPrivateFieldGet(this, _Client_instances, "m", _Client_buildProductEndpoint).call(this, endpointName, cleanAccountName, cleanEndpointVersion);
|
|
273
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Load an input document from a local path.
|
|
275
|
+
* @param inputPath
|
|
276
|
+
*/
|
|
277
|
+
docFromPath(inputPath) {
|
|
278
|
+
return new input_1.PathInput({
|
|
279
|
+
inputPath: inputPath,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Load an input document from a base64 encoded string.
|
|
284
|
+
* @param inputString input content, as a string.
|
|
285
|
+
* @param filename file name.
|
|
286
|
+
*/
|
|
287
|
+
docFromBase64(inputString, filename) {
|
|
288
|
+
return new input_1.Base64Input({
|
|
289
|
+
inputString: inputString,
|
|
290
|
+
filename: filename,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Load an input document from a `stream.Readable` object.
|
|
295
|
+
* @param inputStream input content, as a readable stream.
|
|
296
|
+
* @param filename file name.
|
|
297
|
+
*/
|
|
298
|
+
docFromStream(inputStream, filename) {
|
|
299
|
+
return new input_1.StreamInput({
|
|
300
|
+
inputStream: inputStream,
|
|
301
|
+
filename: filename,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Load an input document from bytes.
|
|
306
|
+
* @param inputBytes input content, as a Uint8Array or Buffer.
|
|
307
|
+
* @param filename file name.
|
|
308
|
+
*/
|
|
309
|
+
docFromBytes(inputBytes, filename) {
|
|
310
|
+
return new input_1.BytesInput({
|
|
311
|
+
inputBytes: inputBytes,
|
|
312
|
+
filename: filename,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Load an input document from a URL.
|
|
317
|
+
* @param url input url. Must be HTTPS.
|
|
318
|
+
*/
|
|
319
|
+
docFromUrl(url) {
|
|
320
|
+
return new input_1.UrlInput({
|
|
321
|
+
url: url,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Load an input document from a Buffer.
|
|
326
|
+
* @param buffer input content, as a buffer.
|
|
327
|
+
* @param filename file name.
|
|
328
|
+
*/
|
|
329
|
+
docFromBuffer(buffer, filename) {
|
|
330
|
+
return new input_1.BufferInput({
|
|
331
|
+
buffer: buffer,
|
|
332
|
+
filename: filename,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
274
335
|
}
|
|
275
336
|
exports.Client = Client;
|
|
276
337
|
_Client_instances = new WeakSet(), _Client_setAsyncParams = function _Client_setAsyncParams(asyncParams) {
|
package/src/clientV2.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LocalInputSource } from "./input";
|
|
1
|
+
import { Base64Input, BufferInput, BytesInput, LocalInputSource, PathInput, StreamInput, UrlInput } from "./input";
|
|
2
2
|
import { InferenceResponse, JobResponse } from "./parsing/v2";
|
|
3
3
|
import { MindeeApiV2 } from "./http/mindeeApiV2";
|
|
4
|
-
import {
|
|
4
|
+
import { Readable } from "stream";
|
|
5
5
|
/**
|
|
6
6
|
* Parameters for the internal polling loop in {@link ClientV2.enqueueAndGetInference | enqueueAndGetInference()} .
|
|
7
7
|
*
|
|
@@ -104,7 +104,7 @@ export interface ClientOptions {
|
|
|
104
104
|
*
|
|
105
105
|
* @category ClientV2
|
|
106
106
|
*/
|
|
107
|
-
export declare class ClientV2
|
|
107
|
+
export declare class ClientV2 {
|
|
108
108
|
#private;
|
|
109
109
|
/** Key of the API. */
|
|
110
110
|
protected mindeeApi: MindeeApiV2;
|
|
@@ -153,4 +153,38 @@ export declare class ClientV2 extends BaseClient {
|
|
|
153
153
|
* @returns a `Promise` containing parsing results.
|
|
154
154
|
*/
|
|
155
155
|
enqueueAndGetInference(inputDoc: LocalInputSource, params: InferenceParameters): Promise<InferenceResponse>;
|
|
156
|
+
/**
|
|
157
|
+
* Load an input source from a local path.
|
|
158
|
+
* @param inputPath
|
|
159
|
+
*/
|
|
160
|
+
sourceFromPath(inputPath: string): PathInput;
|
|
161
|
+
/**
|
|
162
|
+
* Load an input source from a base64 encoded string.
|
|
163
|
+
* @param inputString input content, as a string.
|
|
164
|
+
* @param filename file name.
|
|
165
|
+
*/
|
|
166
|
+
sourceFromBase64(inputString: string, filename: string): Base64Input;
|
|
167
|
+
/**
|
|
168
|
+
* Load an input source from a `stream.Readable` object.
|
|
169
|
+
* @param inputStream input content, as a readable stream.
|
|
170
|
+
* @param filename file name.
|
|
171
|
+
*/
|
|
172
|
+
sourceFromStream(inputStream: Readable, filename: string): StreamInput;
|
|
173
|
+
/**
|
|
174
|
+
* Load an input source from bytes.
|
|
175
|
+
* @param inputBytes input content, as a Uint8Array or Buffer.
|
|
176
|
+
* @param filename file name.
|
|
177
|
+
*/
|
|
178
|
+
sourceFromBytes(inputBytes: Uint8Array, filename: string): BytesInput;
|
|
179
|
+
/**
|
|
180
|
+
* Load an input source from a Buffer.
|
|
181
|
+
* @param buffer input content, as a buffer.
|
|
182
|
+
* @param filename file name.
|
|
183
|
+
*/
|
|
184
|
+
sourceFromBuffer(buffer: Buffer, filename: string): BufferInput;
|
|
185
|
+
/**
|
|
186
|
+
* Load an input source from a URL.
|
|
187
|
+
* @param url input url. Must be HTTPS.
|
|
188
|
+
*/
|
|
189
|
+
sourceFromUrl(url: string): UrlInput;
|
|
156
190
|
}
|
package/src/clientV2.js
CHANGED
|
@@ -7,18 +7,18 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
7
|
var _ClientV2_instances, _ClientV2_setAsyncParams;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ClientV2 = void 0;
|
|
10
|
+
const input_1 = require("./input");
|
|
10
11
|
const handler_1 = require("./errors/handler");
|
|
11
12
|
const logger_1 = require("./logger");
|
|
12
13
|
const promises_1 = require("node:timers/promises");
|
|
13
14
|
const mindeeApiV2_1 = require("./http/mindeeApiV2");
|
|
14
|
-
const baseClient_1 = require("./baseClient");
|
|
15
15
|
const mindeeError_1 = require("./errors/mindeeError");
|
|
16
16
|
/**
|
|
17
17
|
* Mindee Client V2 class that centralizes most basic operations.
|
|
18
18
|
*
|
|
19
19
|
* @category ClientV2
|
|
20
20
|
*/
|
|
21
|
-
class ClientV2
|
|
21
|
+
class ClientV2 {
|
|
22
22
|
/**
|
|
23
23
|
* @param {ClientOptions} options options for the initialization of a client.
|
|
24
24
|
*/
|
|
@@ -27,7 +27,6 @@ class ClientV2 extends baseClient_1.BaseClient {
|
|
|
27
27
|
throwOnError: true,
|
|
28
28
|
debug: false,
|
|
29
29
|
}) {
|
|
30
|
-
super();
|
|
31
30
|
_ClientV2_instances.add(this);
|
|
32
31
|
this.mindeeApi = new mindeeApiV2_1.MindeeApiV2(apiKey);
|
|
33
32
|
handler_1.errorHandler.throwOnError = throwOnError ?? true;
|
|
@@ -120,6 +119,68 @@ Job status: ${pollResults.job.status}.`);
|
|
|
120
119
|
validatedAsyncParams.delaySec * retryCounter +
|
|
121
120
|
" seconds");
|
|
122
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Load an input source from a local path.
|
|
124
|
+
* @param inputPath
|
|
125
|
+
*/
|
|
126
|
+
sourceFromPath(inputPath) {
|
|
127
|
+
return new input_1.PathInput({
|
|
128
|
+
inputPath: inputPath,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Load an input source from a base64 encoded string.
|
|
133
|
+
* @param inputString input content, as a string.
|
|
134
|
+
* @param filename file name.
|
|
135
|
+
*/
|
|
136
|
+
sourceFromBase64(inputString, filename) {
|
|
137
|
+
return new input_1.Base64Input({
|
|
138
|
+
inputString: inputString,
|
|
139
|
+
filename: filename,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Load an input source from a `stream.Readable` object.
|
|
144
|
+
* @param inputStream input content, as a readable stream.
|
|
145
|
+
* @param filename file name.
|
|
146
|
+
*/
|
|
147
|
+
sourceFromStream(inputStream, filename) {
|
|
148
|
+
return new input_1.StreamInput({
|
|
149
|
+
inputStream: inputStream,
|
|
150
|
+
filename: filename,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Load an input source from bytes.
|
|
155
|
+
* @param inputBytes input content, as a Uint8Array or Buffer.
|
|
156
|
+
* @param filename file name.
|
|
157
|
+
*/
|
|
158
|
+
sourceFromBytes(inputBytes, filename) {
|
|
159
|
+
return new input_1.BytesInput({
|
|
160
|
+
inputBytes: inputBytes,
|
|
161
|
+
filename: filename,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Load an input source from a Buffer.
|
|
166
|
+
* @param buffer input content, as a buffer.
|
|
167
|
+
* @param filename file name.
|
|
168
|
+
*/
|
|
169
|
+
sourceFromBuffer(buffer, filename) {
|
|
170
|
+
return new input_1.BufferInput({
|
|
171
|
+
buffer: buffer,
|
|
172
|
+
filename: filename,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Load an input source from a URL.
|
|
177
|
+
* @param url input url. Must be HTTPS.
|
|
178
|
+
*/
|
|
179
|
+
sourceFromUrl(url) {
|
|
180
|
+
return new input_1.UrlInput({
|
|
181
|
+
url: url,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
123
184
|
}
|
|
124
185
|
exports.ClientV2 = ClientV2;
|
|
125
186
|
_ClientV2_instances = new WeakSet(), _ClientV2_setAsyncParams = function _ClientV2_setAsyncParams(asyncParams = undefined) {
|
package/src/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export * as product from "./product";
|
|
|
2
2
|
export { Client, PredictOptions } from "./client";
|
|
3
3
|
export { ClientV2, InferenceParameters, PollingOptions } from "./clientV2";
|
|
4
4
|
export { AsyncPredictResponse, PredictResponse, Inference, Prediction, Document, Page, } from "./parsing/common";
|
|
5
|
-
export { InputSource, PageOptionsOperation, LocalResponse } from "./input";
|
|
5
|
+
export { InputSource, PageOptions, PageOptionsOperation, LocalResponse } from "./input";
|
|
6
6
|
export * as internal from "./internal";
|
|
7
7
|
export * as imageOperations from "./imageOperations";
|
package/src/baseClient.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput } from "./input";
|
|
2
|
-
import { Readable } from "stream";
|
|
3
|
-
export declare abstract class BaseClient {
|
|
4
|
-
/**
|
|
5
|
-
* Load an input document from a local path.
|
|
6
|
-
* @param inputPath
|
|
7
|
-
*/
|
|
8
|
-
docFromPath(inputPath: string): PathInput;
|
|
9
|
-
/**
|
|
10
|
-
* Load an input document from a base64 encoded string.
|
|
11
|
-
* @param inputString input content, as a string.
|
|
12
|
-
* @param filename file name.
|
|
13
|
-
*/
|
|
14
|
-
docFromBase64(inputString: string, filename: string): Base64Input;
|
|
15
|
-
/**
|
|
16
|
-
* Load an input document from a `stream.Readable` object.
|
|
17
|
-
* @param inputStream input content, as a readable stream.
|
|
18
|
-
* @param filename file name.
|
|
19
|
-
*/
|
|
20
|
-
docFromStream(inputStream: Readable, filename: string): StreamInput;
|
|
21
|
-
/**
|
|
22
|
-
* Load an input document from bytes.
|
|
23
|
-
* @param inputBytes input content, as a Uint8Array or Buffer.
|
|
24
|
-
* @param filename file name.
|
|
25
|
-
*/
|
|
26
|
-
docFromBytes(inputBytes: Uint8Array, filename: string): BytesInput;
|
|
27
|
-
/**
|
|
28
|
-
* Load an input document from a URL.
|
|
29
|
-
* @param url input url. Must be HTTPS.
|
|
30
|
-
*/
|
|
31
|
-
docFromUrl(url: string): UrlInput;
|
|
32
|
-
/**
|
|
33
|
-
* Load an input document from a Buffer.
|
|
34
|
-
* @param buffer input content, as a buffer.
|
|
35
|
-
* @param filename file name.
|
|
36
|
-
*/
|
|
37
|
-
docFromBuffer(buffer: Buffer, filename: string): BufferInput;
|
|
38
|
-
}
|
package/src/baseClient.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseClient = void 0;
|
|
4
|
-
const input_1 = require("./input");
|
|
5
|
-
class BaseClient {
|
|
6
|
-
/**
|
|
7
|
-
* Load an input document from a local path.
|
|
8
|
-
* @param inputPath
|
|
9
|
-
*/
|
|
10
|
-
docFromPath(inputPath) {
|
|
11
|
-
return new input_1.PathInput({
|
|
12
|
-
inputPath: inputPath,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Load an input document from a base64 encoded string.
|
|
17
|
-
* @param inputString input content, as a string.
|
|
18
|
-
* @param filename file name.
|
|
19
|
-
*/
|
|
20
|
-
docFromBase64(inputString, filename) {
|
|
21
|
-
return new input_1.Base64Input({
|
|
22
|
-
inputString: inputString,
|
|
23
|
-
filename: filename,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Load an input document from a `stream.Readable` object.
|
|
28
|
-
* @param inputStream input content, as a readable stream.
|
|
29
|
-
* @param filename file name.
|
|
30
|
-
*/
|
|
31
|
-
docFromStream(inputStream, filename) {
|
|
32
|
-
return new input_1.StreamInput({
|
|
33
|
-
inputStream: inputStream,
|
|
34
|
-
filename: filename,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Load an input document from bytes.
|
|
39
|
-
* @param inputBytes input content, as a Uint8Array or Buffer.
|
|
40
|
-
* @param filename file name.
|
|
41
|
-
*/
|
|
42
|
-
docFromBytes(inputBytes, filename) {
|
|
43
|
-
return new input_1.BytesInput({
|
|
44
|
-
inputBytes: inputBytes,
|
|
45
|
-
filename: filename,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Load an input document from a URL.
|
|
50
|
-
* @param url input url. Must be HTTPS.
|
|
51
|
-
*/
|
|
52
|
-
docFromUrl(url) {
|
|
53
|
-
return new input_1.UrlInput({
|
|
54
|
-
url: url,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Load an input document from a Buffer.
|
|
59
|
-
* @param buffer input content, as a buffer.
|
|
60
|
-
* @param filename file name.
|
|
61
|
-
*/
|
|
62
|
-
docFromBuffer(buffer, filename) {
|
|
63
|
-
return new input_1.BufferInput({
|
|
64
|
-
buffer: buffer,
|
|
65
|
-
filename: filename,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.BaseClient = BaseClient;
|