mindee 5.9.0 → 5.10.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 +6 -0
- package/package.json +12 -13
- package/src/geometry/bbox.d.ts +18 -6
- package/src/geometry/bbox.js +6 -2
- package/src/geometry/boundingBox.d.ts +3 -1
- package/src/geometry/boundingBox.js +3 -1
- package/src/geometry/boundingBoxUtils.d.ts +4 -4
- package/src/geometry/boundingBoxUtils.js +7 -7
- package/src/geometry/minMax.d.ts +9 -3
- package/src/geometry/point.d.ts +3 -1
- package/src/geometry/polygon.d.ts +3 -1
- package/src/geometry/polygon.js +3 -1
- package/src/http/apiCore.js +1 -1
- package/src/http/baseSettings.d.ts +15 -5
- package/src/http/baseSettings.js +4 -2
- package/src/http/dispatcher.js +4 -2
- package/src/image/extractedImage.d.ts +13 -5
- package/src/image/extractedImage.js +3 -3
- package/src/image/extractedImages.d.ts +3 -1
- package/src/image/extractedImages.js +3 -1
- package/src/image/imageCompressor.d.ts +1 -0
- package/src/image/imageCompressor.js +2 -2
- package/src/image/imageExtractor.d.ts +1 -1
- package/src/image/imageExtractor.js +12 -12
- package/src/input/base64Input.d.ts +9 -3
- package/src/input/base64Input.js +9 -3
- package/src/input/bufferInput.d.ts +7 -2
- package/src/input/bufferInput.js +6 -2
- package/src/input/bytesInput.d.ts +10 -3
- package/src/input/bytesInput.js +10 -3
- package/src/input/inputSource.d.ts +4 -2
- package/src/input/inputSource.js +3 -2
- package/src/input/localInputSource.d.ts +19 -6
- package/src/input/localInputSource.js +12 -5
- package/src/input/pageOptions.d.ts +9 -3
- package/src/input/pageOptions.js +6 -2
- package/src/input/pathInput.d.ts +12 -4
- package/src/input/pathInput.js +11 -5
- package/src/input/streamInput.d.ts +14 -5
- package/src/input/streamInput.js +13 -4
- package/src/input/urlInput.d.ts +19 -7
- package/src/input/urlInput.js +20 -12
- package/src/parsing/baseLocalResponse.d.ts +7 -3
- package/src/parsing/baseLocalResponse.js +15 -11
- package/src/parsing/stringDict.d.ts +3 -1
- package/src/pdf/extractedPdf.d.ts +16 -6
- package/src/pdf/extractedPdf.js +5 -3
- package/src/pdf/extractedPdfs.d.ts +3 -1
- package/src/pdf/extractedPdfs.js +3 -1
- package/src/pdf/pdfCompressor.js +14 -14
- package/src/pdf/pdfExtractor.js +1 -1
- package/src/pdf/pdfOperation.d.ts +9 -3
- package/src/pdf/pdfOperation.js +14 -14
- package/src/pdf/pdfUtils.js +1 -1
- package/src/v1/cli.js +1 -1
- package/src/v1/client.d.ts +42 -14
- package/src/v1/client.js +8 -8
- package/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.d.ts +6 -2
- package/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.js +4 -4
- package/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.d.ts +6 -2
- package/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.js +2 -2
- package/src/v1/http/apiSettingsV1.d.ts +15 -5
- package/src/v1/http/apiSettingsV1.js +12 -4
- package/src/v1/http/baseEndpoint.d.ts +6 -2
- package/src/v1/http/endpoint.d.ts +9 -3
- package/src/v1/http/endpoint.js +1 -1
- package/src/v1/http/errors.d.ts +9 -3
- package/src/v1/http/errors.js +6 -2
- package/src/v1/http/httpParams.d.ts +36 -12
- package/src/v1/http/workflowEndpoint.js +1 -1
- package/src/v1/parsing/common/apiRequest.d.ts +15 -5
- package/src/v1/parsing/common/apiResponse.d.ts +6 -2
- package/src/v1/parsing/common/asyncPredictResponse.d.ts +21 -7
- package/src/v1/parsing/common/document.d.ts +18 -6
- package/src/v1/parsing/common/document.js +2 -2
- package/src/v1/parsing/common/execution.d.ts +39 -13
- package/src/v1/parsing/common/executionFile.d.ts +6 -2
- package/src/v1/parsing/common/executionPriority.d.ts +12 -4
- package/src/v1/parsing/common/executionPriority.js +12 -4
- package/src/v1/parsing/common/extras/cropperExtra.d.ts +7 -3
- package/src/v1/parsing/common/extras/cropperExtra.js +6 -3
- package/src/v1/parsing/common/extras/extras.d.ts +9 -3
- package/src/v1/parsing/common/extras/extras.js +6 -2
- package/src/v1/parsing/common/extras/fullTextOcrExtra.d.ts +9 -3
- package/src/v1/parsing/common/extras/fullTextOcrExtra.js +3 -1
- package/src/v1/parsing/common/extras/ragExtra.d.ts +3 -1
- package/src/v1/parsing/common/extras/ragExtra.js +3 -1
- package/src/v1/parsing/common/feedback/feedbackResponse.d.ts +3 -1
- package/src/v1/parsing/common/feedback/feedbackResponse.js +0 -1
- package/src/v1/parsing/common/inference.d.ts +24 -8
- package/src/v1/parsing/common/inference.js +6 -2
- package/src/v1/parsing/common/mvisionV1.d.ts +3 -1
- package/src/v1/parsing/common/mvisionV1.js +3 -1
- package/src/v1/parsing/common/ocr.d.ts +3 -1
- package/src/v1/parsing/common/ocrPage.d.ts +6 -2
- package/src/v1/parsing/common/ocrPage.js +6 -2
- package/src/v1/parsing/common/orientation.d.ts +6 -2
- package/src/v1/parsing/common/page.d.ts +12 -4
- package/src/v1/parsing/common/predictResponse.d.ts +3 -1
- package/src/v1/parsing/common/prediction.d.ts +3 -1
- package/src/v1/parsing/common/prediction.js +3 -1
- package/src/v1/parsing/generated/generatedList.d.ts +6 -2
- package/src/v1/parsing/generated/generatedObject.d.ts +25 -9
- package/src/v1/parsing/generated/generatedObject.js +13 -7
- package/src/v1/parsing/localResponse.d.ts +3 -1
- package/src/v1/parsing/localResponse.js +3 -1
- package/src/v1/parsing/standard/addressField.d.ts +24 -8
- package/src/v1/parsing/standard/amount.d.ts +3 -1
- package/src/v1/parsing/standard/amount.js +3 -1
- package/src/v1/parsing/standard/base.d.ts +27 -9
- package/src/v1/parsing/standard/base.js +6 -2
- package/src/v1/parsing/standard/boolean.d.ts +3 -1
- package/src/v1/parsing/standard/classification.d.ts +6 -2
- package/src/v1/parsing/standard/companyRegistration.d.ts +9 -3
- package/src/v1/parsing/standard/companyRegistration.js +3 -1
- package/src/v1/parsing/standard/date.d.ts +12 -4
- package/src/v1/parsing/standard/date.js +3 -1
- package/src/v1/parsing/standard/field.d.ts +7 -5
- package/src/v1/parsing/standard/field.js +4 -4
- package/src/v1/parsing/standard/locale.d.ts +15 -5
- package/src/v1/parsing/standard/paymentDetails.d.ts +15 -5
- package/src/v1/parsing/standard/position.d.ts +15 -5
- package/src/v1/parsing/standard/tax.d.ts +18 -6
- package/src/v1/parsing/standard/tax.js +15 -5
- package/src/v1/parsing/standard/text.d.ts +6 -2
- package/src/v1/parsing/standard/word.d.ts +9 -3
- package/src/v1/parsing/standard/word.js +3 -1
- package/src/v1/product/barcodeReader/barcodeReaderV1.d.ts +12 -4
- package/src/v1/product/barcodeReader/barcodeReaderV1.js +9 -3
- package/src/v1/product/barcodeReader/barcodeReaderV1Document.d.ts +6 -2
- package/src/v1/product/barcodeReader/barcodeReaderV1Document.js +6 -2
- package/src/v1/product/cropper/cropperV1.d.ts +12 -4
- package/src/v1/product/cropper/cropperV1.js +9 -3
- package/src/v1/product/cropper/cropperV1Page.d.ts +3 -1
- package/src/v1/product/cropper/cropperV1Page.js +3 -1
- package/src/v1/product/driverLicense/driverLicenseV1.d.ts +12 -4
- package/src/v1/product/driverLicense/driverLicenseV1.js +9 -3
- package/src/v1/product/driverLicense/driverLicenseV1Document.d.ts +39 -13
- package/src/v1/product/financialDocument/financialDocumentV1.d.ts +12 -4
- package/src/v1/product/financialDocument/financialDocumentV1.js +9 -3
- package/src/v1/product/financialDocument/financialDocumentV1Document.d.ts +96 -32
- package/src/v1/product/financialDocument/financialDocumentV1Document.js +15 -5
- package/src/v1/product/financialDocument/financialDocumentV1LineItem.d.ts +30 -10
- package/src/v1/product/financialDocument/financialDocumentV1LineItem.js +3 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +12 -4
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.js +9 -3
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +9 -3
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +12 -4
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.js +9 -3
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +18 -6
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +3 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts +12 -4
- package/src/v1/product/fr/carteGrise/carteGriseV1.d.ts +12 -4
- package/src/v1/product/fr/carteGrise/carteGriseV1.js +9 -3
- package/src/v1/product/fr/carteGrise/carteGriseV1Document.d.ts +123 -41
- package/src/v1/product/fr/idCard/idCardV2.d.ts +12 -4
- package/src/v1/product/fr/idCard/idCardV2.js +9 -3
- package/src/v1/product/fr/idCard/idCardV2Document.d.ts +45 -15
- package/src/v1/product/fr/idCard/idCardV2Document.js +3 -1
- package/src/v1/product/fr/idCard/idCardV2Page.d.ts +6 -2
- package/src/v1/product/generated/generatedV1.d.ts +12 -4
- package/src/v1/product/generated/generatedV1.js +9 -3
- package/src/v1/product/generated/generatedV1Prediction.d.ts +6 -2
- package/src/v1/product/generated/generatedV1Prediction.js +3 -1
- package/src/v1/product/internationalId/internationalIdV2.d.ts +12 -4
- package/src/v1/product/internationalId/internationalIdV2.js +9 -3
- package/src/v1/product/internationalId/internationalIdV2Document.d.ts +51 -17
- package/src/v1/product/internationalId/internationalIdV2Document.js +6 -2
- package/src/v1/product/invoice/invoiceV4.d.ts +12 -4
- package/src/v1/product/invoice/invoiceV4.js +9 -3
- package/src/v1/product/invoice/invoiceV4Document.d.ts +87 -29
- package/src/v1/product/invoice/invoiceV4Document.js +15 -5
- package/src/v1/product/invoice/invoiceV4LineItem.d.ts +30 -10
- package/src/v1/product/invoice/invoiceV4LineItem.js +3 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1.d.ts +12 -4
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1.js +9 -3
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +3 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.js +3 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.d.ts +9 -3
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.js +3 -1
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.d.ts +12 -4
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.js +9 -3
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.d.ts +3 -1
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.js +3 -1
- package/src/v1/product/passport/passportV1.d.ts +12 -4
- package/src/v1/product/passport/passportV1.js +9 -3
- package/src/v1/product/passport/passportV1Document.d.ts +33 -11
- package/src/v1/product/passport/passportV1Document.js +3 -1
- package/src/v1/product/receipt/receiptV5.d.ts +12 -4
- package/src/v1/product/receipt/receiptV5.js +9 -3
- package/src/v1/product/receipt/receiptV5Document.d.ts +51 -17
- package/src/v1/product/receipt/receiptV5Document.js +6 -2
- package/src/v1/product/receipt/receiptV5LineItem.d.ts +18 -6
- package/src/v1/product/receipt/receiptV5LineItem.js +3 -1
- package/src/v1/product/resume/resumeV1.d.ts +12 -4
- package/src/v1/product/resume/resumeV1.js +9 -3
- package/src/v1/product/resume/resumeV1Certificate.d.ts +18 -6
- package/src/v1/product/resume/resumeV1Certificate.js +3 -1
- package/src/v1/product/resume/resumeV1Document.d.ts +51 -17
- package/src/v1/product/resume/resumeV1Document.js +27 -9
- package/src/v1/product/resume/resumeV1Education.d.ts +27 -9
- package/src/v1/product/resume/resumeV1Education.js +3 -1
- package/src/v1/product/resume/resumeV1Language.d.ts +12 -4
- package/src/v1/product/resume/resumeV1Language.js +3 -1
- package/src/v1/product/resume/resumeV1ProfessionalExperience.d.ts +33 -11
- package/src/v1/product/resume/resumeV1ProfessionalExperience.js +3 -1
- package/src/v1/product/resume/resumeV1SocialNetworksUrl.d.ts +12 -4
- package/src/v1/product/resume/resumeV1SocialNetworksUrl.js +3 -1
- package/src/v1/product/us/bankCheck/bankCheckV1.d.ts +12 -4
- package/src/v1/product/us/bankCheck/bankCheckV1.js +9 -3
- package/src/v1/product/us/bankCheck/bankCheckV1Document.d.ts +18 -6
- package/src/v1/product/us/bankCheck/bankCheckV1Document.js +3 -1
- package/src/v1/product/us/bankCheck/bankCheckV1Page.d.ts +6 -2
- package/src/v1/product/us/bankCheck/bankCheckV1Page.js +3 -1
- package/src/v2/cli.js +1 -1
- package/src/v2/client.d.ts +9 -3
- package/src/v2/clientOptions/pollingOptions.d.ts +30 -10
- package/src/v2/clientOptions/pollingOptions.js +6 -2
- package/src/v2/http/mindeeApiV2.d.ts +1 -1
- package/src/v2/http/mindeeApiV2.js +1 -1
- package/src/v2/parsing/error/errorDetails.d.ts +3 -1
- package/src/v2/parsing/inference/baseInference.d.ts +6 -2
- package/src/v2/parsing/inference/baseInference.js +6 -2
- package/src/v2/parsing/inference/field/baseField.d.ts +9 -3
- package/src/v2/parsing/inference/field/fieldConfidence.d.ts +12 -4
- package/src/v2/parsing/inference/field/fieldConfidence.js +12 -4
- package/src/v2/parsing/inference/field/fieldLocation.d.ts +9 -3
- package/src/v2/parsing/inference/field/fieldLocation.js +3 -1
- package/src/v2/parsing/inference/field/inferenceFields.d.ts +6 -2
- package/src/v2/parsing/inference/field/inferenceFields.js +3 -1
- package/src/v2/parsing/inference/field/listField.d.ts +6 -2
- package/src/v2/parsing/inference/field/listField.js +6 -2
- package/src/v2/parsing/inference/field/objectField.d.ts +6 -2
- package/src/v2/parsing/inference/field/objectField.js +3 -1
- package/src/v2/parsing/inference/field/ragMetadata.d.ts +3 -1
- package/src/v2/parsing/inference/field/ragMetadata.js +3 -1
- package/src/v2/parsing/inference/field/rawText.d.ts +6 -2
- package/src/v2/parsing/inference/field/rawText.js +6 -2
- package/src/v2/parsing/inference/field/simpleField.d.ts +6 -2
- package/src/v2/parsing/inference/field/simpleField.js +8 -4
- package/src/v2/parsing/inference/inferenceFile.d.ts +6 -2
- package/src/v2/parsing/inference/inferenceFile.js +6 -2
- package/src/v2/parsing/inference/inferenceModel.d.ts +6 -2
- package/src/v2/parsing/inference/inferenceModel.js +6 -2
- package/src/v2/product/classification/classification.d.ts +9 -3
- package/src/v2/product/classification/classification.js +9 -3
- package/src/v2/product/classification/classificationClassifier.d.ts +6 -2
- package/src/v2/product/classification/classificationClassifier.js +6 -2
- package/src/v2/product/classification/classificationInference.d.ts +6 -2
- package/src/v2/product/classification/classificationInference.js +6 -2
- package/src/v2/product/classification/classificationResponse.d.ts +3 -1
- package/src/v2/product/classification/classificationResponse.js +3 -1
- package/src/v2/product/classification/classificationResult.d.ts +6 -2
- package/src/v2/product/classification/classificationResult.js +6 -2
- package/src/v2/product/crop/crop.d.ts +9 -3
- package/src/v2/product/crop/crop.js +9 -3
- package/src/v2/product/crop/cropInference.d.ts +6 -2
- package/src/v2/product/crop/cropInference.js +6 -2
- package/src/v2/product/crop/cropItem.d.ts +6 -2
- package/src/v2/product/crop/cropItem.js +6 -2
- package/src/v2/product/crop/cropResponse.d.ts +3 -1
- package/src/v2/product/crop/cropResponse.js +3 -1
- package/src/v2/product/crop/cropResult.d.ts +6 -2
- package/src/v2/product/crop/cropResult.js +6 -2
- package/src/v2/product/extraction/dataSchemaActiveOption.d.ts +3 -1
- package/src/v2/product/extraction/dataSchemaActiveOption.js +3 -1
- package/src/v2/product/extraction/extraction.d.ts +18 -6
- package/src/v2/product/extraction/extraction.js +18 -6
- package/src/v2/product/extraction/extractionActiveOptions.d.ts +6 -2
- package/src/v2/product/extraction/extractionActiveOptions.js +6 -2
- package/src/v2/product/extraction/extractionInference.d.ts +6 -2
- package/src/v2/product/extraction/extractionInference.js +6 -2
- package/src/v2/product/extraction/extractionResponse.d.ts +3 -1
- package/src/v2/product/extraction/extractionResponse.js +3 -1
- package/src/v2/product/extraction/extractionResult.d.ts +6 -2
- package/src/v2/product/extraction/extractionResult.js +6 -2
- package/src/v2/product/extraction/params/dataSchema.d.ts +12 -4
- package/src/v2/product/extraction/params/dataSchema.js +6 -2
- package/src/v2/product/extraction/params/dataSchemaField.d.ts +39 -13
- package/src/v2/product/extraction/params/dataSchemaField.js +9 -3
- package/src/v2/product/extraction/params/dataSchemaReplace.d.ts +12 -4
- package/src/v2/product/extraction/params/dataSchemaReplace.js +6 -2
- package/src/v2/product/extraction/params/extractionParameters.js +3 -3
- package/src/v2/product/extraction/ragDocuments/annotatedListField.d.ts +3 -1
- package/src/v2/product/extraction/ragDocuments/annotatedListField.js +3 -1
- package/src/v2/product/extraction/ragDocuments/params/ragDocumentAnnotationParameters.js +1 -1
- package/src/v2/product/ocr/ocr.d.ts +9 -3
- package/src/v2/product/ocr/ocr.js +9 -3
- package/src/v2/product/ocr/ocrInference.d.ts +6 -2
- package/src/v2/product/ocr/ocrInference.js +6 -2
- package/src/v2/product/ocr/ocrPage.d.ts +6 -2
- package/src/v2/product/ocr/ocrPage.js +6 -2
- package/src/v2/product/ocr/ocrResponse.d.ts +3 -1
- package/src/v2/product/ocr/ocrResponse.js +3 -1
- package/src/v2/product/ocr/ocrResult.d.ts +3 -1
- package/src/v2/product/ocr/ocrResult.js +3 -1
- package/src/v2/product/ocr/ocrWord.d.ts +6 -2
- package/src/v2/product/ocr/ocrWord.js +6 -2
- package/src/v2/product/split/split.d.ts +9 -3
- package/src/v2/product/split/split.js +9 -3
- package/src/v2/product/split/splitInference.d.ts +6 -2
- package/src/v2/product/split/splitInference.js +6 -2
- package/src/v2/product/split/splitRange.d.ts +3 -1
- package/src/v2/product/split/splitRange.js +3 -1
- package/src/v2/product/split/splitResponse.d.ts +3 -1
- package/src/v2/product/split/splitResponse.js +3 -1
- package/src/v2/product/split/splitResult.d.ts +3 -1
- package/src/v2/product/split/splitResult.js +3 -1
- package/src/v2/search/baseSearch.d.ts +9 -3
- package/src/v2/search/baseSearch.js +9 -3
- package/src/v2/search/models/modelSearch.d.ts +9 -3
- package/src/v2/search/models/modelSearch.js +9 -3
- package/src/v2/search/models/modelSearchParameters.d.ts +3 -1
- package/src/v2/search/models/modelSearchParameters.js +3 -1
- package/src/v2/search/ragDocuments/ragDocumentSearch.d.ts +9 -3
- package/src/v2/search/ragDocuments/ragDocumentSearch.js +9 -3
- package/src/v2/search/ragDocuments/ragDocumentSearchParameters.d.ts +3 -1
- package/src/v2/search/ragDocuments/ragDocumentSearchParameters.js +3 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "Mindee Client Library for Node.js",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mindee",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"test:light": "node tests/runner.mjs spec",
|
|
40
40
|
"test:integration": "node tests/runner.mjs integration",
|
|
41
41
|
"test:integration:light": "node tests/runner.mjs integration",
|
|
42
|
-
"test:v2": "tsc
|
|
43
|
-
"lint": "tsc
|
|
44
|
-
"lint:fix": "tsc
|
|
42
|
+
"test:v2": "tsc -p tsconfig.test.json && node tests/runner.mjs spec v2",
|
|
43
|
+
"lint": "tsc -p tsconfig.test.json && eslint --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
|
|
44
|
+
"lint:fix": "tsc -p tsconfig.test.json && eslint --fix --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'",
|
|
45
45
|
"lint:package": "npm run build:dist && publint ./dist && attw --pack ./dist --profile esm-only",
|
|
46
46
|
"lint:secrets": "secretlint '**/*'",
|
|
47
|
-
"license:check": "license-checker-rseidelsohn --onlyAllow \"MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;LGPL-3.0-or-later;Python-2.0;BlueOak-1.0.0;CC-BY-3.0;CC0-1.0;0BSD;
|
|
47
|
+
"license:check": "license-checker-rseidelsohn --onlyAllow \"MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;LGPL-3.0-or-later;LGPL-3.0-only;Python-2.0;BlueOak-1.0.0;CC-BY-3.0;CC-BY-4.0;CC0-1.0;0BSD;WTFPL;Artistic-2.0;Unlicense\"",
|
|
48
48
|
"docs": "typedoc --out docs/_build ./src/index.ts",
|
|
49
49
|
"docs:dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/",
|
|
50
50
|
"prepare": "husky"
|
|
@@ -73,17 +73,15 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
76
|
-
"eslint": "^10.8.1",
|
|
77
|
-
"@eslint/eslintrc": "^3.3.5",
|
|
78
76
|
"@eslint/js": "^10.0.1",
|
|
79
|
-
"eslint-plugin-jsdoc": "^62.7.1",
|
|
80
|
-
"eslint-plugin-security": "^4.0.1",
|
|
81
|
-
"eslint-plugin-sonarjs": "^4.2.0",
|
|
82
77
|
"@secretlint/secretlint-rule-preset-recommend": "^13.0.4",
|
|
83
78
|
"@types/node": "^20.19.37",
|
|
84
79
|
"@types/tmp": "^0.2.6",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
80
|
+
"eslint": "^10.8.1",
|
|
81
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
82
|
+
"eslint-plugin-security": "^4.0.1",
|
|
83
|
+
"eslint-plugin-sonarjs": "^4.2.0",
|
|
84
|
+
"eslint-plugin-unicorn": "^75.0.0",
|
|
87
85
|
"globals": "^17.4.0",
|
|
88
86
|
"husky": "^9.1.7",
|
|
89
87
|
"license-checker-rseidelsohn": "^4.4.2",
|
|
@@ -93,7 +91,8 @@
|
|
|
93
91
|
"tslib": "^2.8.1",
|
|
94
92
|
"tsx": "^4.21.0",
|
|
95
93
|
"typedoc": "^0.28.18",
|
|
96
|
-
"typescript": "^
|
|
94
|
+
"typescript": "^6.0.3",
|
|
95
|
+
"typescript-eslint": "^8.70.0"
|
|
97
96
|
},
|
|
98
97
|
"keywords": [
|
|
99
98
|
"typescript",
|
package/src/geometry/bbox.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax
|
|
3
|
+
*/
|
|
2
4
|
export declare class BBox {
|
|
3
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Minimum X coordinate.
|
|
7
|
+
*/
|
|
4
8
|
xMin: number;
|
|
5
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Minimum Y coordinate.
|
|
11
|
+
*/
|
|
6
12
|
yMin: number;
|
|
7
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Maximum X coordinate.
|
|
15
|
+
*/
|
|
8
16
|
xMax: number;
|
|
9
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Maximum Y coordinate.
|
|
19
|
+
*/
|
|
10
20
|
yMax: number;
|
|
11
21
|
constructor(xMin: number, yMin: number, xMax: number, yMax: number);
|
|
12
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Returns a bounding box that contains this box and another one.
|
|
24
|
+
*/
|
|
13
25
|
mergeBbox(bbox: BBox): BBox;
|
|
14
26
|
}
|
package/src/geometry/bbox.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { mergeBbox } from "./boundingBoxUtils.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax
|
|
4
|
+
*/
|
|
3
5
|
export class BBox {
|
|
4
6
|
constructor(xMin, yMin, xMax, yMax) {
|
|
5
7
|
this.xMin = xMin;
|
|
@@ -7,7 +9,9 @@ export class BBox {
|
|
|
7
9
|
this.xMax = xMax;
|
|
8
10
|
this.yMax = yMax;
|
|
9
11
|
}
|
|
10
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Returns a bounding box that contains this box and another one.
|
|
14
|
+
*/
|
|
11
15
|
mergeBbox(bbox) {
|
|
12
16
|
return mergeBbox(this, bbox);
|
|
13
17
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Point } from "./point.js";
|
|
2
2
|
import { Polygon } from "./polygon.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A bounding box defined by 4 points.
|
|
5
|
+
*/
|
|
4
6
|
export declare class BoundingBox extends Polygon {
|
|
5
7
|
constructor(topLeft: Point, topRight: Point, bottomRight: Point, bottomLeft: Point);
|
|
6
8
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Polygon } from "./polygon.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A bounding box defined by 4 points.
|
|
4
|
+
*/
|
|
3
5
|
export class BoundingBox extends Polygon {
|
|
4
6
|
constructor(topLeft, topRight, bottomRight, bottomLeft) {
|
|
5
7
|
super(topLeft, topRight, bottomRight, bottomLeft);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { BoundingBox } from "./boundingBox.js";
|
|
2
2
|
import { BBox } from "./bbox.js";
|
|
3
3
|
import { Polygon } from "./polygon.js";
|
|
4
|
-
/**
|
|
5
|
-
* Given a Polygon, calculate a polygon that encompasses all points.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getBoundingBox(polygon: Polygon): BoundingBox;
|
|
8
4
|
/**
|
|
9
5
|
* Given a BBox, generate the associated bounding box.
|
|
10
6
|
*/
|
|
@@ -21,3 +17,7 @@ export declare function getBbox(polygon: Polygon): BBox;
|
|
|
21
17
|
* Given polygons, calculate a BBox that encompasses all points.
|
|
22
18
|
*/
|
|
23
19
|
export declare function getBBoxForPolygons(polygons: Polygon[]): BBox;
|
|
20
|
+
/**
|
|
21
|
+
* Given a Polygon, calculate a polygon that encompasses all points.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getBoundingBox(polygon: Polygon): BoundingBox;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { BoundingBox } from "./boundingBox.js";
|
|
2
2
|
import { BBox } from "./bbox.js";
|
|
3
|
-
/**
|
|
4
|
-
* Given a Polygon, calculate a polygon that encompasses all points.
|
|
5
|
-
*/
|
|
6
|
-
export function getBoundingBox(polygon) {
|
|
7
|
-
const bbox = getBbox(polygon);
|
|
8
|
-
return getBoundingBoxFromBBox(bbox);
|
|
9
|
-
}
|
|
10
3
|
/**
|
|
11
4
|
* Given a BBox, generate the associated bounding box.
|
|
12
5
|
*/
|
|
@@ -35,3 +28,10 @@ export function getBBoxForPolygons(polygons) {
|
|
|
35
28
|
const allX = polygons.flatMap((polygon) => polygon.map((point) => point[0]));
|
|
36
29
|
return new BBox(Math.min(...allX), Math.min(...allY), Math.max(...allX), Math.max(...allY));
|
|
37
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Given a Polygon, calculate a polygon that encompasses all points.
|
|
33
|
+
*/
|
|
34
|
+
export function getBoundingBox(polygon) {
|
|
35
|
+
const bbox = getBbox(polygon);
|
|
36
|
+
return getBoundingBoxFromBBox(bbox);
|
|
37
|
+
}
|
package/src/geometry/minMax.d.ts
CHANGED
package/src/geometry/point.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Point } from "./point.js";
|
|
2
2
|
import { MinMax } from "./minMax.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* A polygon, composed of several Points.
|
|
5
|
+
*/
|
|
4
6
|
export declare class Polygon extends Array<Point> {
|
|
5
7
|
constructor(...args: Point[]);
|
|
6
8
|
/**
|
package/src/geometry/polygon.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getCentroid, getMinMaxX, getMinMaxY, isPointInX, isPointInY } from "./polygonUtils.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A polygon, composed of several Points.
|
|
4
|
+
*/
|
|
3
5
|
export class Polygon extends Array {
|
|
4
6
|
constructor(...args) {
|
|
5
7
|
super(...args);
|
package/src/http/apiCore.js
CHANGED
|
@@ -4,16 +4,26 @@ export interface MindeeApiConstructorProps {
|
|
|
4
4
|
dispatcher?: Dispatcher;
|
|
5
5
|
}
|
|
6
6
|
export declare abstract class BaseSettings {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* API key used for authenticated requests.
|
|
9
|
+
*/
|
|
8
10
|
apiKey: string;
|
|
9
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* API hostname used for requests.
|
|
13
|
+
*/
|
|
10
14
|
hostname: string;
|
|
11
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Request timeout in seconds.
|
|
17
|
+
*/
|
|
12
18
|
timeoutSecs: number;
|
|
13
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* HTTP dispatcher used by undici.
|
|
21
|
+
*/
|
|
14
22
|
dispatcher: Dispatcher;
|
|
15
23
|
protected constructor(apiKey?: string, dispatcher?: Dispatcher);
|
|
16
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Builds a default user-agent string for outgoing requests.
|
|
26
|
+
*/
|
|
17
27
|
protected getUserAgent(): string;
|
|
18
28
|
protected abstract apiKeyFromEnv(): string;
|
|
19
29
|
protected abstract hostnameFromEnv(): string;
|
package/src/http/baseSettings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as os from "node:os";
|
|
1
2
|
// eslint-disable-next-line no-restricted-imports
|
|
2
3
|
import packageJson from "../../package.json" with { type: "json" };
|
|
3
|
-
import * as os from "os";
|
|
4
4
|
import { TIMEOUT_SECS_DEFAULT } from "./apiCore.js";
|
|
5
5
|
import { resolveDefaultDispatcher } from "./dispatcher.js";
|
|
6
6
|
export class BaseSettings {
|
|
@@ -17,7 +17,9 @@ export class BaseSettings {
|
|
|
17
17
|
? parseInt(process.env.MINDEE_REQUEST_TIMEOUT)
|
|
18
18
|
: TIMEOUT_SECS_DEFAULT;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Builds a default user-agent string for outgoing requests.
|
|
22
|
+
*/
|
|
21
23
|
getUserAgent() {
|
|
22
24
|
let platform = os.type().toLowerCase();
|
|
23
25
|
if (platform.includes("darwin")) {
|
package/src/http/dispatcher.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Agent, Dispatcher, getGlobalDispatcher } from "undici";
|
|
2
2
|
import { logger } from "../logger.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Library-owned fallback dispatcher, shared across all components.
|
|
5
|
+
*/
|
|
4
6
|
let fallbackDispatcher;
|
|
5
7
|
/**
|
|
6
8
|
* Returns the global undici dispatcher, provided it was created by the same
|
|
@@ -12,6 +14,6 @@ export function resolveDefaultDispatcher() {
|
|
|
12
14
|
return globalDispatcher;
|
|
13
15
|
}
|
|
14
16
|
logger.debug("Global dispatcher belongs to a different undici instance, using a library-owned Agent instead.");
|
|
15
|
-
fallbackDispatcher
|
|
17
|
+
fallbackDispatcher ??= new Agent();
|
|
16
18
|
return fallbackDispatcher;
|
|
17
19
|
}
|
|
@@ -4,13 +4,21 @@ import { BufferInput } from "../input/index.js";
|
|
|
4
4
|
* Generic class for image extraction.
|
|
5
5
|
*/
|
|
6
6
|
export declare class ExtractedImage {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Raw file bytes for the extracted image artifact.
|
|
9
|
+
*/
|
|
8
10
|
buffer: Buffer;
|
|
9
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Filename used when exporting the extracted image.
|
|
13
|
+
*/
|
|
10
14
|
filename: string;
|
|
11
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* 1-based source page identifier.
|
|
17
|
+
*/
|
|
12
18
|
readonly pageId: number;
|
|
13
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Identifier of the extracted element on the page.
|
|
21
|
+
*/
|
|
14
22
|
readonly elementId: number;
|
|
15
23
|
constructor(buffer: Uint8Array, fileName: string, pageId: number, elementId: number);
|
|
16
24
|
/**
|
|
@@ -20,7 +28,7 @@ export declare class ExtractedImage {
|
|
|
20
28
|
*/
|
|
21
29
|
saveToFileAsync(outputPath: string): Promise<void>;
|
|
22
30
|
/**
|
|
23
|
-
* Attempts to
|
|
31
|
+
* Attempts to save the document to a file synchronously.
|
|
24
32
|
* Throws an error if the file extension is not supported or if the file could not be saved to disk for some reason.
|
|
25
33
|
*
|
|
26
34
|
* @param outputPath Path to save the file to.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
|
-
import { MindeeError } from "../errors/index.js";
|
|
3
2
|
import { writeFileSync } from "node:fs";
|
|
4
|
-
import { writeFile } from "fs/promises";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
5
4
|
import path from "node:path";
|
|
5
|
+
import { MindeeError } from "../errors/index.js";
|
|
6
6
|
import { BufferInput, MIMETYPES } from "../input/index.js";
|
|
7
7
|
import { logger } from "../logger.js";
|
|
8
8
|
import { loadOptionalDependency } from "../dependency/index.js";
|
|
@@ -62,7 +62,7 @@ export class ExtractedImage {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Attempts to
|
|
65
|
+
* Attempts to save the document to a file synchronously.
|
|
66
66
|
* Throws an error if the file extension is not supported or if the file could not be saved to disk for some reason.
|
|
67
67
|
*
|
|
68
68
|
* @param outputPath Path to save the file to.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ExtractedImage } from "./index.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Collection of extracted image artifacts.
|
|
4
|
+
*/
|
|
3
5
|
export declare class ExtractedImages extends Array<ExtractedImage> {
|
|
4
6
|
constructor(...items: ExtractedImage[]);
|
|
5
7
|
}
|
|
@@ -16,8 +16,8 @@ export async function compressImage(imageBuffer, quality = 85, maxWidth = null,
|
|
|
16
16
|
if (metadata.width === undefined || metadata.height === undefined) {
|
|
17
17
|
throw new MindeeImageError("Source image has invalid dimensions.");
|
|
18
18
|
}
|
|
19
|
-
maxWidth
|
|
20
|
-
maxHeight
|
|
19
|
+
maxWidth ??= metadata.width;
|
|
20
|
+
maxHeight ??= metadata.height;
|
|
21
21
|
if (maxWidth || maxHeight) {
|
|
22
22
|
sharpImage = sharpImage.resize({
|
|
23
23
|
width: maxWidth,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type * as pdfLibTypes from "@cantoo/pdf-lib";
|
|
1
2
|
import { Polygon } from "../geometry/index.js";
|
|
2
3
|
import { ExtractedImages } from "./extractedImages.js";
|
|
3
4
|
import { LocalInputSource } from "../input/index.js";
|
|
4
|
-
import type * as pdfLibTypes from "@cantoo/pdf-lib";
|
|
5
5
|
/**
|
|
6
6
|
* Extracts elements from a PDF document based on a list of bounding boxes.
|
|
7
7
|
* @param inputSource The input source to extract from.
|
|
@@ -39,7 +39,7 @@ export async function extractImagesFromPolygon(inputSource, polygonsPerPage, qua
|
|
|
39
39
|
/**
|
|
40
40
|
* Helper function to handle the drawing math and orientation.
|
|
41
41
|
*/
|
|
42
|
-
function drawOrientedPage(
|
|
42
|
+
function drawOrientedPage(currentPdfLib, samplePage, cropped, orientation, finalWidth, finalHeight, scaledWidth, scaledHeight) {
|
|
43
43
|
if (orientation === 0) {
|
|
44
44
|
samplePage.drawPage(cropped, {
|
|
45
45
|
width: scaledWidth,
|
|
@@ -52,7 +52,7 @@ function drawOrientedPage(pdfLib, samplePage, cropped, orientation, finalWidth,
|
|
|
52
52
|
y: finalHeight,
|
|
53
53
|
width: scaledWidth,
|
|
54
54
|
height: scaledHeight,
|
|
55
|
-
rotate:
|
|
55
|
+
rotate: currentPdfLib.degrees(270),
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
else if (orientation === 180) {
|
|
@@ -61,7 +61,7 @@ function drawOrientedPage(pdfLib, samplePage, cropped, orientation, finalWidth,
|
|
|
61
61
|
y: finalHeight,
|
|
62
62
|
width: scaledWidth,
|
|
63
63
|
height: scaledHeight,
|
|
64
|
-
rotate:
|
|
64
|
+
rotate: currentPdfLib.degrees(180),
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
else if (orientation === 270) {
|
|
@@ -70,7 +70,7 @@ function drawOrientedPage(pdfLib, samplePage, cropped, orientation, finalWidth,
|
|
|
70
70
|
y: 0,
|
|
71
71
|
width: scaledWidth,
|
|
72
72
|
height: scaledHeight,
|
|
73
|
-
rotate:
|
|
73
|
+
rotate: currentPdfLib.degrees(90),
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -82,7 +82,7 @@ function drawOrientedPage(pdfLib, samplePage, cropped, orientation, finalWidth,
|
|
|
82
82
|
* @param quality The quality of the extracted images.
|
|
83
83
|
*/
|
|
84
84
|
export async function extractFromPage(pdfPage, polygons, asImage = false, quality) {
|
|
85
|
-
const
|
|
85
|
+
const currentPdfLib = await getPdfLib();
|
|
86
86
|
const { width, height } = pdfPage.getSize();
|
|
87
87
|
const extractedElements = [];
|
|
88
88
|
if (quality !== undefined) {
|
|
@@ -100,15 +100,15 @@ export async function extractFromPage(pdfPage, polygons, asImage = false, qualit
|
|
|
100
100
|
const pageIndex = sourceDoc.getPages().indexOf(pdfPage);
|
|
101
101
|
for (const origPolygon of polygons) {
|
|
102
102
|
logger.debug(`Extracting image with polygon: ${origPolygon.toString()}`);
|
|
103
|
-
const tempPdf = await
|
|
103
|
+
const tempPdf = await currentPdfLib.PDFDocument.create();
|
|
104
104
|
const [copiedPage] = await tempPdf.copyPages(sourceDoc, [pageIndex]);
|
|
105
105
|
const polygon = adjustForRotation(origPolygon, orientation);
|
|
106
106
|
const minX = getMinMaxX(polygon).min;
|
|
107
107
|
const maxX = getMinMaxX(polygon).max;
|
|
108
108
|
const minY = getMinMaxY(polygon).min;
|
|
109
109
|
const maxY = getMinMaxY(polygon).max;
|
|
110
|
-
const
|
|
111
|
-
const
|
|
110
|
+
const imgWidth = width * (maxX - minX);
|
|
111
|
+
const imgHeight = height * (maxY - minY);
|
|
112
112
|
const cropped = await tempPdf.embedPage(copiedPage, {
|
|
113
113
|
left: minX * width,
|
|
114
114
|
right: maxX * width,
|
|
@@ -116,13 +116,13 @@ export async function extractFromPage(pdfPage, polygons, asImage = false, qualit
|
|
|
116
116
|
bottom: height - (maxY * height),
|
|
117
117
|
});
|
|
118
118
|
const isVertical = orientation === 90 || orientation === 270;
|
|
119
|
-
const finalWidth = (isVertical ?
|
|
120
|
-
const finalHeight = (isVertical ?
|
|
119
|
+
const finalWidth = (isVertical ? imgHeight : imgWidth) * qualityScale;
|
|
120
|
+
const finalHeight = (isVertical ? imgWidth : imgHeight) * qualityScale;
|
|
121
121
|
const samplePage = tempPdf.addPage([finalWidth, finalHeight]);
|
|
122
122
|
samplePage.drawRectangle({
|
|
123
|
-
x: 0, y: 0, width: finalWidth, height: finalHeight, color:
|
|
123
|
+
x: 0, y: 0, width: finalWidth, height: finalHeight, color: currentPdfLib.rgb(1, 1, 1),
|
|
124
124
|
});
|
|
125
|
-
drawOrientedPage(
|
|
125
|
+
drawOrientedPage(currentPdfLib, samplePage, cropped, orientation, finalWidth, finalHeight, imgWidth * qualityScale, imgHeight * qualityScale);
|
|
126
126
|
const pdfBuffer = Buffer.from(await tempPdf.save());
|
|
127
127
|
extractedElements.push(asImage ? await rasterizePage(pdfBuffer, 0, 100) : pdfBuffer);
|
|
128
128
|
}
|
|
@@ -3,13 +3,19 @@ interface Base64InputProps {
|
|
|
3
3
|
inputString: string;
|
|
4
4
|
filename: string;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Local input source backed by a base64-encoded payload.
|
|
8
|
+
*/
|
|
7
9
|
export declare class Base64Input extends LocalInputSource {
|
|
8
10
|
private inputString;
|
|
9
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Decoded binary payload built from the base64 input.
|
|
13
|
+
*/
|
|
10
14
|
fileObject: Buffer;
|
|
11
15
|
constructor({ inputString, filename }: Base64InputProps);
|
|
12
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Decodes and validates the provided base64 content.
|
|
18
|
+
*/
|
|
13
19
|
init(): Promise<void>;
|
|
14
20
|
}
|
|
15
21
|
export {};
|
package/src/input/base64Input.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { LocalInputSource } from "./localInputSource.js";
|
|
2
2
|
import { INPUT_TYPE_BASE64 } from "./inputSource.js";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Local input source backed by a base64-encoded payload.
|
|
6
|
+
*/
|
|
5
7
|
export class Base64Input extends LocalInputSource {
|
|
6
8
|
constructor({ inputString, filename }) {
|
|
7
9
|
super({
|
|
8
10
|
inputType: INPUT_TYPE_BASE64,
|
|
9
11
|
});
|
|
10
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Decoded binary payload built from the base64 input.
|
|
14
|
+
*/
|
|
11
15
|
this.fileObject = Buffer.alloc(0);
|
|
12
16
|
this.filename = filename;
|
|
13
17
|
this.inputString = inputString;
|
|
14
18
|
}
|
|
15
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Decodes and validates the provided base64 content.
|
|
21
|
+
*/
|
|
16
22
|
async init() {
|
|
17
23
|
if (this.initialized) {
|
|
18
24
|
return;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { LocalInputSource } from "./localInputSource.js";
|
|
2
3
|
interface BufferInputProps {
|
|
3
4
|
buffer: Buffer;
|
|
4
5
|
filename: string;
|
|
5
6
|
}
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Local input source backed by an in-memory `Buffer`.
|
|
9
|
+
*/
|
|
7
10
|
export declare class BufferInput extends LocalInputSource {
|
|
8
11
|
constructor({ buffer, filename }: BufferInputProps);
|
|
9
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Validates and initializes the in-memory buffer input.
|
|
14
|
+
*/
|
|
10
15
|
init(): Promise<void>;
|
|
11
16
|
}
|
|
12
17
|
export {};
|
package/src/input/bufferInput.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { LocalInputSource } from "./localInputSource.js";
|
|
2
2
|
import { INPUT_TYPE_BUFFER } from "./inputSource.js";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Local input source backed by an in-memory `Buffer`.
|
|
6
|
+
*/
|
|
5
7
|
export class BufferInput extends LocalInputSource {
|
|
6
8
|
constructor({ buffer, filename }) {
|
|
7
9
|
super({
|
|
@@ -10,7 +12,9 @@ export class BufferInput extends LocalInputSource {
|
|
|
10
12
|
this.fileObject = buffer;
|
|
11
13
|
this.filename = filename;
|
|
12
14
|
}
|
|
13
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Validates and initializes the in-memory buffer input.
|
|
17
|
+
*/
|
|
14
18
|
async init() {
|
|
15
19
|
if (this.initialized) {
|
|
16
20
|
return;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { LocalInputSource } from "./localInputSource.js";
|
|
2
3
|
interface BytesInputProps {
|
|
3
4
|
inputBytes: Uint8Array;
|
|
4
5
|
filename: string;
|
|
5
6
|
}
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Local input source backed by a `Uint8Array`.
|
|
9
|
+
*/
|
|
7
10
|
export declare class BytesInput extends LocalInputSource {
|
|
8
11
|
private inputBytes;
|
|
9
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Binary payload built from the byte array.
|
|
14
|
+
*/
|
|
10
15
|
fileObject: Buffer;
|
|
11
16
|
constructor({ inputBytes, filename }: BytesInputProps);
|
|
12
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Converts bytes to a buffer and validates MIME type.
|
|
19
|
+
*/
|
|
13
20
|
init(): Promise<void>;
|
|
14
21
|
}
|
|
15
22
|
export {};
|
package/src/input/bytesInput.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { INPUT_TYPE_BYTES } from "./inputSource.js";
|
|
2
3
|
import { LocalInputSource } from "./localInputSource.js";
|
|
3
4
|
import { logger } from "../logger.js";
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Local input source backed by a `Uint8Array`.
|
|
7
|
+
*/
|
|
5
8
|
export class BytesInput extends LocalInputSource {
|
|
6
9
|
constructor({ inputBytes, filename }) {
|
|
7
10
|
super({
|
|
8
11
|
inputType: INPUT_TYPE_BYTES,
|
|
9
12
|
});
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Binary payload built from the byte array.
|
|
15
|
+
*/
|
|
11
16
|
this.fileObject = Buffer.alloc(0);
|
|
12
17
|
this.filename = filename;
|
|
13
18
|
this.inputBytes = inputBytes;
|
|
14
19
|
}
|
|
15
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Converts bytes to a buffer and validates MIME type.
|
|
22
|
+
*/
|
|
16
23
|
async init() {
|
|
17
24
|
if (this.initialized) {
|
|
18
25
|
return;
|