mindee 4.29.0-rc5 → 4.29.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 +17 -24
- package/package.json +5 -5
- package/src/client.js +4 -3
- package/src/clientV2.d.ts +3 -38
- package/src/clientV2.js +6 -66
- package/src/geometry/boundingBox.d.ts +4 -1
- package/src/geometry/boundingBox.js +9 -1
- package/src/geometry/boundingBoxUtils.js +1 -6
- package/src/geometry/index.js +2 -1
- package/src/geometry/polygon.d.ts +22 -0
- package/src/geometry/polygon.js +36 -0
- package/src/geometry/polygonUtils.d.ts +8 -9
- package/src/index.d.ts +2 -1
- package/src/index.js +6 -1
- package/src/input/localResponse.d.ts +5 -5
- package/src/input/localResponse.js +17 -7
- package/src/input/sources/base64Input.js +1 -0
- package/src/input/sources/bufferInput.js +1 -0
- package/src/input/sources/bytesInput.js +1 -0
- package/src/input/sources/inputSource.d.ts +2 -0
- package/src/input/sources/inputSource.js +4 -0
- package/src/input/sources/localInputSource.d.ts +2 -2
- package/src/input/sources/localInputSource.js +16 -4
- package/src/input/sources/pathInput.js +1 -0
- package/src/input/sources/streamInput.js +1 -0
- package/src/input/sources/urlInput.js +1 -0
- package/src/parsing/custom/listField.d.ts +2 -2
- package/src/parsing/custom/listField.js +1 -6
- package/src/parsing/standard/field.js +1 -1
- package/src/parsing/v2/field/baseField.d.ts +2 -0
- package/src/parsing/v2/field/baseField.js +7 -1
- package/src/parsing/v2/field/fieldConfidence.d.ts +4 -4
- package/src/parsing/v2/field/fieldConfidence.js +5 -4
- package/src/parsing/v2/field/fieldFactory.d.ts +1 -1
- package/src/parsing/v2/field/fieldLocation.js +2 -4
- package/src/parsing/v2/field/inferenceFields.d.ts +3 -0
- package/src/parsing/v2/field/inferenceFields.js +30 -0
- package/src/parsing/v2/field/listField.d.ts +8 -0
- package/src/parsing/v2/field/listField.js +31 -0
- package/src/parsing/v2/field/objectField.d.ts +4 -2
- package/src/parsing/v2/field/objectField.js +14 -2
- package/src/parsing/v2/field/simpleField.d.ts +14 -2
- package/src/parsing/v2/field/simpleField.js +29 -2
- package/src/parsing/v2/index.d.ts +0 -1
- package/src/parsing/v2/index.js +1 -3
- package/src/parsing/v2/inferenceResult.d.ts +4 -4
- package/src/parsing/v2/inferenceResult.js +5 -8
- package/src/parsing/v2/rawText.d.ts +3 -9
- package/src/parsing/v2/rawText.js +2 -5
- package/src/parsing/v2/rawTextPage.d.ts +11 -0
- package/src/parsing/v2/rawTextPage.js +12 -0
- package/src/product/billOfLading/billOfLadingV1Carrier.js +2 -1
- package/src/product/billOfLading/billOfLadingV1CarrierItem.js +2 -1
- package/src/product/billOfLading/billOfLadingV1Consignee.js +2 -1
- package/src/product/billOfLading/billOfLadingV1NotifyParty.js +2 -1
- package/src/product/billOfLading/billOfLadingV1Shipper.js +2 -1
- package/src/product/financialDocument/financialDocumentV1LineItem.js +2 -1
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +2 -1
- package/src/product/fr/energyBill/energyBillV1EnergyConsumer.js +2 -1
- package/src/product/fr/energyBill/energyBillV1EnergySupplier.js +2 -1
- package/src/product/fr/energyBill/energyBillV1EnergyUsage.js +2 -1
- package/src/product/fr/energyBill/energyBillV1MeterDetail.js +2 -1
- package/src/product/fr/energyBill/energyBillV1Subscription.js +2 -1
- package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.js +2 -1
- package/src/product/fr/payslip/payslipV2BankAccountDetail.js +2 -1
- package/src/product/fr/payslip/payslipV2Employee.js +2 -1
- package/src/product/fr/payslip/payslipV2Employer.js +2 -1
- package/src/product/fr/payslip/payslipV2Employment.js +2 -1
- package/src/product/fr/payslip/payslipV2PayDetail.js +2 -1
- package/src/product/fr/payslip/payslipV2PayPeriod.js +2 -1
- package/src/product/fr/payslip/payslipV2Pto.js +2 -1
- package/src/product/fr/payslip/payslipV2SalaryDetail.js +2 -1
- package/src/product/fr/payslip/payslipV3BankAccountDetail.js +2 -1
- package/src/product/fr/payslip/payslipV3Employee.js +2 -1
- package/src/product/fr/payslip/payslipV3Employer.js +2 -1
- package/src/product/fr/payslip/payslipV3Employment.js +2 -1
- package/src/product/fr/payslip/payslipV3PaidTimeOff.js +2 -1
- package/src/product/fr/payslip/payslipV3PayDetail.js +2 -1
- package/src/product/fr/payslip/payslipV3PayPeriod.js +2 -1
- package/src/product/fr/payslip/payslipV3SalaryDetail.js +2 -1
- package/src/product/invoice/invoiceV4LineItem.js +2 -1
- package/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.js +2 -1
- package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.js +2 -1
- package/src/product/receipt/receiptV5LineItem.js +2 -1
- package/src/product/resume/resumeV1Certificate.js +2 -1
- package/src/product/resume/resumeV1Education.js +2 -1
- package/src/product/resume/resumeV1Language.js +2 -1
- package/src/product/resume/resumeV1ProfessionalExperience.js +2 -1
- package/src/product/resume/resumeV1SocialNetworksUrl.js +2 -1
- package/src/product/us/healthcareCard/healthcareCardV1Copay.js +2 -1
- package/src/product/us/usMail/usMailV2RecipientAddress.js +2 -1
- package/src/product/us/usMail/usMailV2SenderAddress.js +2 -1
- package/src/product/us/usMail/usMailV3RecipientAddress.js +2 -1
- package/src/product/us/usMail/usMailV3SenderAddress.js +2 -1
- package/src/parsing/v2/field/dynamicField.d.ts +0 -7
- package/src/parsing/v2/field/dynamicField.js +0 -16
- package/src/parsing/v2/inferenceResultOptions.d.ts +0 -9
- package/src/parsing/v2/inferenceResultOptions.js +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v4.29.0 - 2025-08-29
|
|
4
|
+
### Changes
|
|
5
|
+
* :sparkles: add typed accessors for fields, list, object
|
|
6
|
+
* :sparkles: add typed value accessors
|
|
7
|
+
* :sparkles: add geometry methods to polygon class
|
|
8
|
+
### Fixes
|
|
9
|
+
* :bug: Polygon and BoundingBox should be a real classes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## v4.29.0-rc6 - 2025-08-22
|
|
13
|
+
### Changes
|
|
14
|
+
* :recycle: rework local and input sources
|
|
15
|
+
|
|
16
|
+
|
|
3
17
|
## v4.29.0-rc5 - 2025-07-30
|
|
4
18
|
### Changes
|
|
5
19
|
* :recycle: allow direct import of input sources
|
|
@@ -30,7 +44,6 @@
|
|
|
30
44
|
* :recycle: tweak CI & testing
|
|
31
45
|
* :recycle: deprecate `cutPdf()` in favor of `applyPageOperations()` in `LocalInputSource`
|
|
32
46
|
* :recycle: refactor some internals to account for new changes
|
|
33
|
-
|
|
34
47
|
### Fixes
|
|
35
48
|
* :bug: fix bug where polling parameters could ignore validation checks on V1
|
|
36
49
|
|
|
@@ -173,7 +186,6 @@
|
|
|
173
186
|
* :sparkles: add support for FR Payslips V1
|
|
174
187
|
* :sparkles: add support for Nutrition Facts Label V1
|
|
175
188
|
* :recycle: refactor internals to accommodate for new changes
|
|
176
|
-
|
|
177
189
|
### Fixes
|
|
178
190
|
* :bug: fix float numbers not containing more 3 decimals in some instances
|
|
179
191
|
* :bug: fix boolean field display issues
|
|
@@ -219,7 +231,6 @@
|
|
|
219
231
|
* :sparkles: add support for HMAC validation for webhooks
|
|
220
232
|
* :sparkles: add support for US Mail V2
|
|
221
233
|
* :sparkles: add support for boolean fields
|
|
222
|
-
|
|
223
234
|
### Fixes
|
|
224
235
|
* :recycle: fixed Locale display
|
|
225
236
|
|
|
@@ -237,7 +248,6 @@
|
|
|
237
248
|
# v4.10.0 - 2024-04-12
|
|
238
249
|
### Changes
|
|
239
250
|
* :sparkles: update Invoice to v4.5 (#264)
|
|
240
|
-
|
|
241
251
|
### Fixes
|
|
242
252
|
* :bug: fix error management not following intended flow (#267)
|
|
243
253
|
* :recycle: deprecated old error handler (#266)
|
|
@@ -256,14 +266,12 @@
|
|
|
256
266
|
* :sparkles: add support for resume V1
|
|
257
267
|
* :sparkles: add support for International ID v2
|
|
258
268
|
* :sparkles: add support for EU Driver License V1
|
|
259
|
-
|
|
260
269
|
### Fixes
|
|
261
270
|
:memo: misc doc fixes
|
|
262
271
|
|
|
263
272
|
## v4.8.2 - 2024-02-09
|
|
264
273
|
### Changes
|
|
265
274
|
* :recycle: increased update time for async retries
|
|
266
|
-
|
|
267
275
|
### Fixes
|
|
268
276
|
* :bug: fixed improper float parsing for Generated list objects
|
|
269
277
|
* :bug: typescript should now allow the use of default values for enqueueAndParse() async options
|
|
@@ -287,7 +295,6 @@
|
|
|
287
295
|
* :recycle: add CLI entry for generated APIs
|
|
288
296
|
* :memo: add documentation entry for generated APIs
|
|
289
297
|
* :recycle: expose a bit more of our internals for easier use (#247)
|
|
290
|
-
|
|
291
298
|
### Fixes
|
|
292
299
|
* :memo: fix invoice v4 md doc
|
|
293
300
|
|
|
@@ -334,7 +341,6 @@
|
|
|
334
341
|
## v4.3.2 - 2023-11-07
|
|
335
342
|
### Changes
|
|
336
343
|
* :recycle: update invoice splitter
|
|
337
|
-
|
|
338
344
|
### Fixes
|
|
339
345
|
* :bug: fix display issues when products didn't have pages
|
|
340
346
|
* :memo: fix doc typos
|
|
@@ -364,7 +370,6 @@
|
|
|
364
370
|
* :sparkles: add support for FR Id Card V2
|
|
365
371
|
* :sparkles: add support for OTS Cropper V1
|
|
366
372
|
* :memo: update documentation
|
|
367
|
-
|
|
368
373
|
### Fixes
|
|
369
374
|
* :bug: fix missing position field display issues
|
|
370
375
|
* :bug: fix issues with asynchronous timeouts crashing in some instances
|
|
@@ -373,7 +378,6 @@
|
|
|
373
378
|
## v4.1.1 - 2023-09-04
|
|
374
379
|
### Changes
|
|
375
380
|
* :recycle: tweaked timer management in async
|
|
376
|
-
|
|
377
381
|
### Fixes
|
|
378
382
|
* :bug: fix ocr option not being generated as an Ocr object
|
|
379
383
|
|
|
@@ -390,7 +394,6 @@
|
|
|
390
394
|
* :recycle: remove deprecated examples
|
|
391
395
|
* :recycle: update linting rules
|
|
392
396
|
* :arrow_up: update testing library
|
|
393
|
-
|
|
394
397
|
### Fixes
|
|
395
398
|
* :bug: fix miscellaneous bugs related to http parsing issues
|
|
396
399
|
|
|
@@ -398,7 +401,6 @@
|
|
|
398
401
|
## v4.0.2 - 2023-08-24
|
|
399
402
|
### Changes
|
|
400
403
|
* :recycle: updated technical documentation
|
|
401
|
-
|
|
402
404
|
### Fixes
|
|
403
405
|
* :bug: fix url source document not being sent properly
|
|
404
406
|
|
|
@@ -413,7 +415,6 @@
|
|
|
413
415
|
* :art: :boom: harmonize response types with other libraries
|
|
414
416
|
* :art: :boom: change endpoint management & syntax
|
|
415
417
|
* :art: :boom: move products to `product` module
|
|
416
|
-
|
|
417
418
|
### Changes
|
|
418
419
|
* :sparkles: add full support for page-specific attributes
|
|
419
420
|
* :sparkles: add support for FR Id Card
|
|
@@ -434,7 +435,6 @@
|
|
|
434
435
|
## v3.10.1 - 2023-07-04
|
|
435
436
|
### Changes
|
|
436
437
|
* :arrow_up: update dependencies
|
|
437
|
-
|
|
438
438
|
### Fixes
|
|
439
439
|
* :pencil2: added missing entry in changelog
|
|
440
440
|
|
|
@@ -450,8 +450,6 @@
|
|
|
450
450
|
### Changes
|
|
451
451
|
* :sparkles: support for financial document v1.1
|
|
452
452
|
* :recycle: change http status code handling for async requests
|
|
453
|
-
|
|
454
|
-
|
|
455
453
|
### Fixes
|
|
456
454
|
* :bug: fix typing in PaymentDetails
|
|
457
455
|
* :bug: locale value should always be set
|
|
@@ -467,7 +465,6 @@
|
|
|
467
465
|
## v3.7.4 - 2023-04-20
|
|
468
466
|
### Changes
|
|
469
467
|
* :white_check_mark: minor improvements to tests
|
|
470
|
-
|
|
471
468
|
### Fixes
|
|
472
469
|
* :bug: fix for options not being passed properly in the CLI tool
|
|
473
470
|
|
|
@@ -497,7 +494,6 @@
|
|
|
497
494
|
* :art: harmonize bbox and bounding box terminology
|
|
498
495
|
* :arrow_up: update test files, minor updates to string output
|
|
499
496
|
* :label: classification fields are always strings
|
|
500
|
-
|
|
501
497
|
### Fixes
|
|
502
498
|
* :bug: fix error message for missing API key, document type may be undefined
|
|
503
499
|
|
|
@@ -527,7 +523,6 @@ Usage is otherwise identical.
|
|
|
527
523
|
### Changes
|
|
528
524
|
* :memo: updates to class documentation
|
|
529
525
|
* :sparkles: Add invoice splitter support (beta)
|
|
530
|
-
|
|
531
526
|
### Fixes
|
|
532
527
|
* :bug: fix for CLI command option description
|
|
533
528
|
|
|
@@ -588,7 +583,6 @@ Usage is otherwise identical.
|
|
|
588
583
|
* :sparkles: Document (endpoints) are now versioned, providing better backward-compatible support.
|
|
589
584
|
* :recycle: Pass the document class instead of the response class to the `parse` method.
|
|
590
585
|
* :recycle: Some methods and parameters renamed for better clarity.
|
|
591
|
-
|
|
592
586
|
### Changes
|
|
593
587
|
* :sparkles: New URL input source, `docFromUrl`.
|
|
594
588
|
* :sparkles: Add support for expense receipts V4
|
|
@@ -625,15 +619,14 @@ It's **not** backwards compatible with previous versions.
|
|
|
625
619
|
|
|
626
620
|
|
|
627
621
|
## v1.4.0
|
|
622
|
+
### Changes
|
|
623
|
+
* :sparkles: Add TIFF and HEIC support
|
|
624
|
+
* :white_check_mark: fully test PDF cut function
|
|
628
625
|
### Fixes
|
|
629
626
|
* :bug: cut/merge pages of an encrypted PDF leads to unexpected results
|
|
630
627
|
* :bug: logger not activating in some cases
|
|
631
628
|
* :bug: align PDF cut/merge with other client libs
|
|
632
629
|
|
|
633
|
-
### Changes
|
|
634
|
-
* :sparkles: Add TIFF and HEIC support
|
|
635
|
-
* :white_check_mark: fully test PDF cut function
|
|
636
|
-
|
|
637
630
|
|
|
638
631
|
## v1.3.3
|
|
639
632
|
### Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "4.29.0
|
|
3
|
+
"version": "4.29.0",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": "bin/mindee.js",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://mindee.com/",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/chai": "^4.3.
|
|
43
|
+
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/mocha": "^10.0.10",
|
|
45
|
-
"@types/node": "^18.15.
|
|
45
|
+
"@types/node": "^18.15.13",
|
|
46
46
|
"@types/tmp": "^0.2.6",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
48
|
-
"@typescript-eslint/parser": "^8.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
48
|
+
"@typescript-eslint/parser": "^8.40.0",
|
|
49
49
|
"chai": "^4.3.10",
|
|
50
50
|
"eslint": "^9.15.0",
|
|
51
51
|
"eslint-plugin-jsdoc": "^50.5.0",
|
package/src/client.js
CHANGED
|
@@ -121,10 +121,11 @@ class Client {
|
|
|
121
121
|
* @returns A valid prediction
|
|
122
122
|
*/
|
|
123
123
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const asDict = await localResponse.asDict();
|
|
125
|
+
if (Object.prototype.hasOwnProperty.call(asDict, "job")) {
|
|
126
|
+
return new common_1.AsyncPredictResponse(productClass, asDict);
|
|
126
127
|
}
|
|
127
|
-
return new common_1.PredictResponse(productClass,
|
|
128
|
+
return new common_1.PredictResponse(productClass, asDict);
|
|
128
129
|
}
|
|
129
130
|
catch {
|
|
130
131
|
throw new errors_1.MindeeError("No prediction found in local response.");
|
package/src/clientV2.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputSource } from "./input";
|
|
2
2
|
import { InferenceResponse, JobResponse } from "./parsing/v2";
|
|
3
3
|
import { MindeeApiV2 } from "./http/mindeeApiV2";
|
|
4
|
-
import { Readable } from "stream";
|
|
5
4
|
/**
|
|
6
5
|
* Parameters for the internal polling loop in {@link ClientV2.enqueueAndGetInference | enqueueAndGetInference()} .
|
|
7
6
|
*
|
|
@@ -145,46 +144,12 @@ export declare class ClientV2 {
|
|
|
145
144
|
* Send a document to an endpoint and poll the server until the result is sent or
|
|
146
145
|
* until the maximum number of tries is reached.
|
|
147
146
|
*
|
|
148
|
-
* @param
|
|
147
|
+
* @param inputSource file or URL to parse.
|
|
149
148
|
* @param params parameters relating to prediction options.
|
|
150
149
|
*
|
|
151
150
|
* @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
|
|
152
151
|
* @category Synchronous
|
|
153
152
|
* @returns a `Promise` containing parsing results.
|
|
154
153
|
*/
|
|
155
|
-
enqueueAndGetInference(
|
|
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;
|
|
154
|
+
enqueueAndGetInference(inputSource: InputSource, params: InferenceParameters): Promise<InferenceResponse>;
|
|
190
155
|
}
|
package/src/clientV2.js
CHANGED
|
@@ -7,7 +7,6 @@ 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");
|
|
11
10
|
const handler_1 = require("./errors/handler");
|
|
12
11
|
const logger_1 = require("./logger");
|
|
13
12
|
const promises_1 = require("node:timers/promises");
|
|
@@ -47,6 +46,9 @@ class ClientV2 {
|
|
|
47
46
|
if (inputSource === undefined) {
|
|
48
47
|
throw new Error("The 'enqueue' function requires an input document.");
|
|
49
48
|
}
|
|
49
|
+
if (!inputSource.isInitialized()) {
|
|
50
|
+
await inputSource.init();
|
|
51
|
+
}
|
|
50
52
|
return await this.mindeeApi.reqPostInferenceEnqueue(inputSource, params);
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
@@ -78,16 +80,16 @@ class ClientV2 {
|
|
|
78
80
|
* Send a document to an endpoint and poll the server until the result is sent or
|
|
79
81
|
* until the maximum number of tries is reached.
|
|
80
82
|
*
|
|
81
|
-
* @param
|
|
83
|
+
* @param inputSource file or URL to parse.
|
|
82
84
|
* @param params parameters relating to prediction options.
|
|
83
85
|
*
|
|
84
86
|
* @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
|
|
85
87
|
* @category Synchronous
|
|
86
88
|
* @returns a `Promise` containing parsing results.
|
|
87
89
|
*/
|
|
88
|
-
async enqueueAndGetInference(
|
|
90
|
+
async enqueueAndGetInference(inputSource, params) {
|
|
89
91
|
const validatedAsyncParams = __classPrivateFieldGet(this, _ClientV2_instances, "m", _ClientV2_setAsyncParams).call(this, params.pollingOptions);
|
|
90
|
-
const enqueueResponse = await this.enqueueInference(
|
|
92
|
+
const enqueueResponse = await this.enqueueInference(inputSource, params);
|
|
91
93
|
if (enqueueResponse.job.id === undefined || enqueueResponse.job.id.length === 0) {
|
|
92
94
|
logger_1.logger.error(`Failed enqueueing:\n${enqueueResponse.getRawHttp()}`);
|
|
93
95
|
throw Error("Enqueueing of the document failed.");
|
|
@@ -119,68 +121,6 @@ Job status: ${pollResults.job.status}.`);
|
|
|
119
121
|
validatedAsyncParams.delaySec * retryCounter +
|
|
120
122
|
" seconds");
|
|
121
123
|
}
|
|
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
|
-
}
|
|
184
124
|
}
|
|
185
125
|
exports.ClientV2 = ClientV2;
|
|
186
126
|
_ClientV2_instances = new WeakSet(), _ClientV2_setAsyncParams = function _ClientV2_setAsyncParams(asyncParams = undefined) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Point } from "./point";
|
|
2
|
+
import { Polygon } from "./polygon";
|
|
2
3
|
/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
|
|
3
4
|
export declare class BBox {
|
|
4
5
|
xMin: number;
|
|
@@ -8,4 +9,6 @@ export declare class BBox {
|
|
|
8
9
|
constructor(xMin: number, yMin: number, xMax: number, yMax: number);
|
|
9
10
|
}
|
|
10
11
|
/** A bounding box defined by 4 points. */
|
|
11
|
-
export
|
|
12
|
+
export declare class BoundingBox extends Polygon {
|
|
13
|
+
constructor(topLeft: Point, topRight: Point, bottomRight: Point, bottomLeft: Point);
|
|
14
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BBox = void 0;
|
|
3
|
+
exports.BoundingBox = exports.BBox = void 0;
|
|
4
|
+
const polygon_1 = require("./polygon");
|
|
4
5
|
/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */
|
|
5
6
|
class BBox {
|
|
6
7
|
constructor(xMin, yMin, xMax, yMax) {
|
|
@@ -11,3 +12,10 @@ class BBox {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
exports.BBox = BBox;
|
|
15
|
+
/** A bounding box defined by 4 points. */
|
|
16
|
+
class BoundingBox extends polygon_1.Polygon {
|
|
17
|
+
constructor(topLeft, topRight, bottomRight, bottomLeft) {
|
|
18
|
+
super(topLeft, topRight, bottomRight, bottomLeft);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.BoundingBox = BoundingBox;
|
|
@@ -17,12 +17,7 @@ function getBoundingBox(polygon) {
|
|
|
17
17
|
* Given a BBox, generate the associated bounding box.
|
|
18
18
|
*/
|
|
19
19
|
function getBoundingBoxFromBBox(bbox) {
|
|
20
|
-
return [
|
|
21
|
-
[bbox.xMin, bbox.yMin],
|
|
22
|
-
[bbox.xMax, bbox.yMin],
|
|
23
|
-
[bbox.xMax, bbox.yMax],
|
|
24
|
-
[bbox.xMin, bbox.yMax],
|
|
25
|
-
];
|
|
20
|
+
return new boundingBox_1.BoundingBox([bbox.xMin, bbox.yMin], [bbox.xMax, bbox.yMin], [bbox.xMax, bbox.yMax], [bbox.xMin, bbox.yMax]);
|
|
26
21
|
}
|
|
27
22
|
/**
|
|
28
23
|
* Given 2 bbox, merge them.
|
package/src/geometry/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = exports.getBBoxForPolygons = exports.getBbox = exports.BBox = exports.getMinMaxY = exports.getMinMaxX = exports.relativeY = exports.relativeX = exports.isPointInPolygonY = exports.isPointInPolygonX = exports.getCentroid = exports.compareOnY = exports.compareOnX = exports.Polygon = void 0;
|
|
3
|
+
exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = exports.getBBoxForPolygons = exports.getBbox = exports.BBox = exports.BoundingBox = exports.getMinMaxY = exports.getMinMaxX = exports.relativeY = exports.relativeX = exports.isPointInPolygonY = exports.isPointInPolygonX = exports.getCentroid = exports.compareOnY = exports.compareOnX = exports.Polygon = void 0;
|
|
4
4
|
var polygon_1 = require("./polygon");
|
|
5
5
|
Object.defineProperty(exports, "Polygon", { enumerable: true, get: function () { return polygon_1.Polygon; } });
|
|
6
6
|
var polygonUtils_1 = require("./polygonUtils");
|
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "relativeY", { enumerable: true, get: function ()
|
|
|
14
14
|
Object.defineProperty(exports, "getMinMaxX", { enumerable: true, get: function () { return polygonUtils_1.getMinMaxX; } });
|
|
15
15
|
Object.defineProperty(exports, "getMinMaxY", { enumerable: true, get: function () { return polygonUtils_1.getMinMaxY; } });
|
|
16
16
|
var boundingBox_1 = require("./boundingBox");
|
|
17
|
+
Object.defineProperty(exports, "BoundingBox", { enumerable: true, get: function () { return boundingBox_1.BoundingBox; } });
|
|
17
18
|
Object.defineProperty(exports, "BBox", { enumerable: true, get: function () { return boundingBox_1.BBox; } });
|
|
18
19
|
var boundingBoxUtils_1 = require("./boundingBoxUtils");
|
|
19
20
|
Object.defineProperty(exports, "getBbox", { enumerable: true, get: function () { return boundingBoxUtils_1.getBbox; } });
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { Point } from "./point";
|
|
2
|
+
import { MinMax } from "./minMax";
|
|
2
3
|
/** A polygon, composed of several Points. */
|
|
3
4
|
export declare class Polygon extends Array<Point> {
|
|
5
|
+
constructor(...args: Point[]);
|
|
6
|
+
/**
|
|
7
|
+
* Get the central point (centroid) of the polygon.
|
|
8
|
+
*/
|
|
9
|
+
getCentroid(): Point;
|
|
10
|
+
/**
|
|
11
|
+
* Get the maximum and minimum X coordinates of the polygon.
|
|
12
|
+
*/
|
|
13
|
+
getMinMaxX(): MinMax;
|
|
14
|
+
/**
|
|
15
|
+
* Get the maximum and minimum Y coordinates of the polygon.
|
|
16
|
+
*/
|
|
17
|
+
getMinMaxY(): MinMax;
|
|
18
|
+
/**
|
|
19
|
+
* Determine if a Point is within the Polygon's X axis (same column).
|
|
20
|
+
*/
|
|
21
|
+
isPointInX(point: Point): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Determine if a Point is within the Polygon's Y axis (same line).
|
|
24
|
+
*/
|
|
25
|
+
isPointInY(point: Point): boolean;
|
|
4
26
|
}
|
package/src/geometry/polygon.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Polygon = void 0;
|
|
4
|
+
const polygonUtils_1 = require("./polygonUtils");
|
|
4
5
|
/** A polygon, composed of several Points. */
|
|
5
6
|
class Polygon extends Array {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(...args);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get the central point (centroid) of the polygon.
|
|
12
|
+
*/
|
|
13
|
+
getCentroid() {
|
|
14
|
+
return (0, polygonUtils_1.getCentroid)(this);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the maximum and minimum X coordinates of the polygon.
|
|
18
|
+
*/
|
|
19
|
+
getMinMaxX() {
|
|
20
|
+
return (0, polygonUtils_1.getMinMaxX)(this);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the maximum and minimum Y coordinates of the polygon.
|
|
24
|
+
*/
|
|
25
|
+
getMinMaxY() {
|
|
26
|
+
return (0, polygonUtils_1.getMinMaxY)(this);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Determine if a Point is within the Polygon's X axis (same column).
|
|
30
|
+
*/
|
|
31
|
+
isPointInX(point) {
|
|
32
|
+
const xCoords = this.getMinMaxX();
|
|
33
|
+
return (0, polygonUtils_1.isPointInX)(point, xCoords.min, xCoords.max);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Determine if a Point is within the Polygon's Y axis (same line).
|
|
37
|
+
*/
|
|
38
|
+
isPointInY(point) {
|
|
39
|
+
const yCoords = this.getMinMaxY();
|
|
40
|
+
return (0, polygonUtils_1.isPointInY)(point, yCoords.min, yCoords.max);
|
|
41
|
+
}
|
|
6
42
|
}
|
|
7
43
|
exports.Polygon = Polygon;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MinMax } from "./minMax";
|
|
2
2
|
import { Point } from "./point";
|
|
3
|
-
import { Polygon } from "./polygon";
|
|
4
3
|
/**
|
|
5
4
|
* Get the central point (centroid) given a list of points.
|
|
6
5
|
*/
|
|
@@ -16,13 +15,13 @@ export declare function getMinMaxY(vertices: Array<Point>): MinMax;
|
|
|
16
15
|
/**
|
|
17
16
|
* Determine if a Point is within a Polygon's Y axis.
|
|
18
17
|
*/
|
|
19
|
-
export declare function isPointInPolygonY(centroid: Point, polygon:
|
|
18
|
+
export declare function isPointInPolygonY(centroid: Point, polygon: Array<Point>): boolean;
|
|
20
19
|
/**
|
|
21
20
|
* Calculate the relative Y position of a Polygon.
|
|
22
21
|
*
|
|
23
22
|
* Can be used to order (sort) words in the same column.
|
|
24
23
|
*/
|
|
25
|
-
export declare function relativeY(polygon:
|
|
24
|
+
export declare function relativeY(polygon: Array<Point>): number;
|
|
26
25
|
/**
|
|
27
26
|
* Determine if a Point is within two X coordinates.
|
|
28
27
|
*/
|
|
@@ -34,14 +33,14 @@ export declare function getMinMaxX(vertices: Array<Point>): MinMax;
|
|
|
34
33
|
/**
|
|
35
34
|
* Determine if a Point is within a Polygon's X axis.
|
|
36
35
|
*/
|
|
37
|
-
export declare function isPointInPolygonX(centroid: Point, polygon:
|
|
36
|
+
export declare function isPointInPolygonX(centroid: Point, polygon: Array<Point>): boolean;
|
|
38
37
|
/**
|
|
39
38
|
* Calculate the relative X position of a Polygon.
|
|
40
39
|
*
|
|
41
40
|
* Can be used to order (sort) words in the same line.
|
|
42
41
|
*/
|
|
43
|
-
export declare function relativeX(polygon:
|
|
44
|
-
export declare function getMinYCoordinate(polygon:
|
|
45
|
-
export declare function getMinXCoordinate(polygon:
|
|
46
|
-
export declare function compareOnY(polygon1:
|
|
47
|
-
export declare function compareOnX(polygon1:
|
|
42
|
+
export declare function relativeX(polygon: Array<Point>): number;
|
|
43
|
+
export declare function getMinYCoordinate(polygon: Array<Point>): number;
|
|
44
|
+
export declare function getMinXCoordinate(polygon: Array<Point>): number;
|
|
45
|
+
export declare function compareOnY(polygon1: Array<Point>, polygon2: Array<Point>): number;
|
|
46
|
+
export declare function compareOnX(polygon1: Array<Point>, polygon2: Array<Point>): number;
|
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * as product from "./product";
|
|
2
|
-
export { Client, PredictOptions } from "./client";
|
|
2
|
+
export { Client, PredictOptions, WorkflowOptions } from "./client";
|
|
3
3
|
export { ClientV2, InferenceParameters, PollingOptions } from "./clientV2";
|
|
4
4
|
export { AsyncPredictResponse, PredictResponse, Inference, Prediction, Document, Page, } from "./parsing/common";
|
|
5
|
+
export { InferenceFile, InferenceResponse, JobResponse, RawText, } from "./parsing/v2";
|
|
5
6
|
export { InputSource, Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput, PageOptions, PageOptionsOperation, LocalResponse } from "./input";
|
|
6
7
|
export * as internal from "./internal";
|
|
7
8
|
export * as imageOperations from "./imageOperations";
|
package/src/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.imageOperations = exports.internal = exports.LocalResponse = exports.PageOptionsOperation = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.BufferInput = exports.Base64Input = exports.InputSource = exports.Page = exports.Document = exports.Prediction = exports.Inference = exports.PredictResponse = exports.AsyncPredictResponse = exports.ClientV2 = exports.Client = exports.product = void 0;
|
|
36
|
+
exports.imageOperations = exports.internal = exports.LocalResponse = exports.PageOptionsOperation = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.BufferInput = exports.Base64Input = exports.InputSource = exports.RawText = exports.JobResponse = exports.InferenceResponse = exports.InferenceFile = exports.Page = exports.Document = exports.Prediction = exports.Inference = exports.PredictResponse = exports.AsyncPredictResponse = exports.ClientV2 = exports.Client = exports.product = void 0;
|
|
37
37
|
exports.product = __importStar(require("./product"));
|
|
38
38
|
var client_1 = require("./client");
|
|
39
39
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
@@ -46,6 +46,11 @@ Object.defineProperty(exports, "Inference", { enumerable: true, get: function ()
|
|
|
46
46
|
Object.defineProperty(exports, "Prediction", { enumerable: true, get: function () { return common_1.Prediction; } });
|
|
47
47
|
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return common_1.Document; } });
|
|
48
48
|
Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return common_1.Page; } });
|
|
49
|
+
var v2_1 = require("./parsing/v2");
|
|
50
|
+
Object.defineProperty(exports, "InferenceFile", { enumerable: true, get: function () { return v2_1.InferenceFile; } });
|
|
51
|
+
Object.defineProperty(exports, "InferenceResponse", { enumerable: true, get: function () { return v2_1.InferenceResponse; } });
|
|
52
|
+
Object.defineProperty(exports, "JobResponse", { enumerable: true, get: function () { return v2_1.JobResponse; } });
|
|
53
|
+
Object.defineProperty(exports, "RawText", { enumerable: true, get: function () { return v2_1.RawText; } });
|
|
49
54
|
var input_1 = require("./input");
|
|
50
55
|
Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return input_1.InputSource; } });
|
|
51
56
|
Object.defineProperty(exports, "Base64Input", { enumerable: true, get: function () { return input_1.Base64Input; } });
|
|
@@ -8,6 +8,7 @@ import { CommonResponse } from "../parsing/v2";
|
|
|
8
8
|
export declare class LocalResponse {
|
|
9
9
|
private file;
|
|
10
10
|
private readonly inputHandle;
|
|
11
|
+
protected initialized: boolean;
|
|
11
12
|
/**
|
|
12
13
|
* Creates an instance of LocalResponse.
|
|
13
14
|
*/
|
|
@@ -17,7 +18,7 @@ export declare class LocalResponse {
|
|
|
17
18
|
* Returns the dictionary representation of the file.
|
|
18
19
|
* @returns A JSON-like object.
|
|
19
20
|
*/
|
|
20
|
-
asDict(): StringDict
|
|
21
|
+
asDict(): Promise<StringDict>;
|
|
21
22
|
/**
|
|
22
23
|
* Returns the HMAC signature of the local response, from the secret key provided.
|
|
23
24
|
* @param secretKey - Secret key, either a string or a byte/byte array.
|
|
@@ -32,15 +33,14 @@ export declare class LocalResponse {
|
|
|
32
33
|
*/
|
|
33
34
|
isValidHmacSignature(secretKey: string | Buffer | Uint8Array, signature: string): boolean;
|
|
34
35
|
/**
|
|
35
|
-
* Deserialize the loaded local response into the requested CommonResponse
|
|
36
|
+
* Deserialize the loaded local response into the requested CommonResponse-derived class.
|
|
36
37
|
*
|
|
37
38
|
* Typically used when dealing with V2 webhook callbacks.
|
|
38
39
|
*
|
|
39
40
|
* @typeParam ResponseT - A class that extends `CommonResponse`.
|
|
40
|
-
* @param responseClass - The constructor of the class into which
|
|
41
|
-
* the payload should be deserialized.
|
|
41
|
+
* @param responseClass - The constructor of the class into which the payload should be deserialized.
|
|
42
42
|
* @returns An instance of `responseClass` populated with the file content.
|
|
43
43
|
* @throws MindeeError If the provided class cannot be instantiated.
|
|
44
44
|
*/
|
|
45
|
-
deserializeResponse<ResponseT extends CommonResponse>(responseClass: new (serverResponse: StringDict) => ResponseT): ResponseT
|
|
45
|
+
deserializeResponse<ResponseT extends CommonResponse>(responseClass: new (serverResponse: StringDict) => ResponseT): Promise<ResponseT>;
|
|
46
46
|
}
|