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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
/**
|
|
2
3
|
* @param {string} inputType - the type of input used in file ("base64", "path", "dummy").
|
|
3
4
|
* NB: dummy is only used for tests purposes
|
|
@@ -22,9 +23,10 @@ export declare abstract class InputSource {
|
|
|
22
23
|
* Whether the input source has been initialized.
|
|
23
24
|
* @protected
|
|
24
25
|
*/
|
|
25
|
-
/** Whether the source has already been initialized. */
|
|
26
26
|
protected initialized: boolean;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Initializes the input source and populates its file object.
|
|
29
|
+
*/
|
|
28
30
|
init(): Promise<void>;
|
|
29
31
|
/**
|
|
30
32
|
* Returns whether the input source has been initialized.
|
package/src/input/inputSource.js
CHANGED
|
@@ -17,10 +17,11 @@ export class InputSource {
|
|
|
17
17
|
* Whether the input source has been initialized.
|
|
18
18
|
* @protected
|
|
19
19
|
*/
|
|
20
|
-
/** Whether the source has already been initialized. */
|
|
21
20
|
this.initialized = false;
|
|
22
21
|
}
|
|
23
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Initializes the input source and populates its file object.
|
|
24
|
+
*/
|
|
24
25
|
async init() {
|
|
25
26
|
throw new MindeeInputSourceError("not Implemented");
|
|
26
27
|
}
|
|
@@ -1,22 +1,35 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { PageOptions } from "./pageOptions.js";
|
|
2
3
|
import { InputSource, InputConstructor } from "./inputSource.js";
|
|
3
4
|
export declare const MIMETYPES: Map<string, string>;
|
|
4
5
|
export declare abstract class LocalInputSource extends InputSource {
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Type of local input source (path, stream, bytes, ...).
|
|
8
|
+
*/
|
|
6
9
|
inputType: string;
|
|
7
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Original filename associated with the input.
|
|
12
|
+
*/
|
|
8
13
|
filename: string;
|
|
9
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Original filepath when available.
|
|
16
|
+
*/
|
|
10
17
|
filepath?: string;
|
|
11
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* MIME type detected for the source content.
|
|
20
|
+
*/
|
|
12
21
|
mimeType: string;
|
|
13
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Binary payload for local sources.
|
|
24
|
+
*/
|
|
14
25
|
fileObject: Buffer | string;
|
|
15
26
|
/**
|
|
16
27
|
* @param {InputConstructor} constructor Constructor parameters.
|
|
17
28
|
*/
|
|
18
29
|
protected constructor({ inputType }: InputConstructor);
|
|
19
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Detects and validates the MIME type from the current file object.
|
|
32
|
+
*/
|
|
20
33
|
protected checkMimetype(): Promise<string>;
|
|
21
34
|
/**
|
|
22
35
|
* Returns the file object as a Buffer.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
2
4
|
import { MindeeInputSourceError } from "../errors/index.js";
|
|
3
5
|
import { errorHandler } from "../errors/handler.js";
|
|
4
6
|
import { logger } from "../logger.js";
|
|
5
7
|
import { compressImage } from "../image/index.js";
|
|
6
8
|
import { compressPdf, countPages, extractPages, hasSourceText } from "../pdf/index.js";
|
|
7
|
-
import { fileTypeFromBuffer } from "file-type";
|
|
8
9
|
import { InputSource, INPUT_TYPE_STREAM, INPUT_TYPE_BASE64, INPUT_TYPE_BYTES, INPUT_TYPE_PATH, INPUT_TYPE_BUFFER } from "./inputSource.js";
|
|
9
10
|
export const MIMETYPES = new Map([
|
|
10
11
|
[".pdf", "application/pdf"],
|
|
@@ -29,9 +30,13 @@ export class LocalInputSource extends InputSource {
|
|
|
29
30
|
*/
|
|
30
31
|
constructor({ inputType }) {
|
|
31
32
|
super();
|
|
32
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Original filename associated with the input.
|
|
35
|
+
*/
|
|
33
36
|
this.filename = "";
|
|
34
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* MIME type detected for the source content.
|
|
39
|
+
*/
|
|
35
40
|
this.mimeType = "";
|
|
36
41
|
// Check if inputType is valid
|
|
37
42
|
if (!ALLOWED_INPUT_TYPES.includes(inputType)) {
|
|
@@ -41,7 +46,9 @@ export class LocalInputSource extends InputSource {
|
|
|
41
46
|
this.inputType = inputType;
|
|
42
47
|
logger.debug(`Initialized local input source of type: ${inputType}`);
|
|
43
48
|
}
|
|
44
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Detects and validates the MIME type from the current file object.
|
|
51
|
+
*/
|
|
45
52
|
async checkMimetype() {
|
|
46
53
|
if (!(this.fileObject instanceof Buffer)) {
|
|
47
54
|
throw new MindeeInputSourceError(`MIME type cannot be verified on input source of type ${this.inputType}.`);
|
|
@@ -10,7 +10,9 @@ export interface PageOptions {
|
|
|
10
10
|
* [0, -1] represents the first and last pages of the document.
|
|
11
11
|
*/
|
|
12
12
|
pageIndexes: number[];
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Operation to apply on the document, given the `pageIndexes` specified.
|
|
15
|
+
*/
|
|
14
16
|
operation: PageOptionsOperation;
|
|
15
17
|
/**
|
|
16
18
|
* Apply the operation only if the document has at least this many pages.
|
|
@@ -21,8 +23,12 @@ export interface PageOptions {
|
|
|
21
23
|
* Operation to apply on the document, given the page indexes specified.
|
|
22
24
|
*/
|
|
23
25
|
export declare enum PageOptionsOperation {
|
|
24
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Only keep pages matching the provided indexes.
|
|
28
|
+
*/
|
|
25
29
|
KeepOnly = "KEEP_ONLY",
|
|
26
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Remove pages matching the provided indexes.
|
|
32
|
+
*/
|
|
27
33
|
Remove = "REMOVE"
|
|
28
34
|
}
|
package/src/input/pageOptions.js
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
5
|
export var PageOptionsOperation;
|
|
6
6
|
(function (PageOptionsOperation) {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Only keep pages matching the provided indexes.
|
|
9
|
+
*/
|
|
8
10
|
PageOptionsOperation["KeepOnly"] = "KEEP_ONLY";
|
|
9
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Remove pages matching the provided indexes.
|
|
13
|
+
*/
|
|
10
14
|
PageOptionsOperation["Remove"] = "REMOVE";
|
|
11
15
|
})(PageOptionsOperation || (PageOptionsOperation = {}));
|
package/src/input/pathInput.d.ts
CHANGED
|
@@ -2,14 +2,22 @@ import { LocalInputSource } from "./localInputSource.js";
|
|
|
2
2
|
interface PathInputProps {
|
|
3
3
|
inputPath: string;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Local input source that reads a file from disk by path.
|
|
7
|
+
*/
|
|
6
8
|
export declare class PathInput extends LocalInputSource {
|
|
7
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Path used to read the local file.
|
|
11
|
+
*/
|
|
8
12
|
readonly inputPath: string;
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* File content loaded from disk.
|
|
15
|
+
*/
|
|
10
16
|
fileObject: Buffer;
|
|
11
17
|
constructor({ inputPath }: PathInputProps);
|
|
12
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Reads the file from disk and validates MIME type.
|
|
20
|
+
*/
|
|
13
21
|
init(): Promise<void>;
|
|
14
22
|
}
|
|
15
23
|
export {};
|
package/src/input/pathInput.js
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
1
3
|
import { INPUT_TYPE_PATH } from "./inputSource.js";
|
|
2
4
|
import { LocalInputSource } from "./localInputSource.js";
|
|
3
|
-
import path from "path";
|
|
4
5
|
import { logger } from "../logger.js";
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Local input source that reads a file from disk by path.
|
|
8
|
+
*/
|
|
7
9
|
export class PathInput extends LocalInputSource {
|
|
8
10
|
constructor({ inputPath }) {
|
|
9
11
|
super({
|
|
10
12
|
inputType: INPUT_TYPE_PATH,
|
|
11
13
|
});
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* File content loaded from disk.
|
|
16
|
+
*/
|
|
13
17
|
this.fileObject = Buffer.alloc(0);
|
|
14
18
|
this.inputPath = inputPath;
|
|
15
19
|
this.filename = path.basename(this.inputPath);
|
|
16
20
|
}
|
|
17
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Reads the file from disk and validates MIME type.
|
|
23
|
+
*/
|
|
18
24
|
async init() {
|
|
19
25
|
if (this.initialized) {
|
|
20
26
|
return;
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { Readable } from "node:stream";
|
|
2
3
|
import { LocalInputSource } from "./localInputSource.js";
|
|
3
4
|
interface StreamInputProps {
|
|
4
5
|
inputStream: Readable;
|
|
5
6
|
filename: string;
|
|
6
7
|
}
|
|
7
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Local input source backed by a readable stream.
|
|
10
|
+
*/
|
|
8
11
|
export declare class StreamInput extends LocalInputSource {
|
|
9
12
|
private readonly inputStream;
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Buffered payload created from the stream.
|
|
15
|
+
*/
|
|
11
16
|
fileObject: Buffer;
|
|
12
17
|
constructor({ inputStream, filename }: StreamInputProps);
|
|
13
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Reads the stream to completion and validates MIME type.
|
|
20
|
+
*/
|
|
14
21
|
init(): Promise<void>;
|
|
15
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Converts a readable stream into a single buffer.
|
|
24
|
+
*/
|
|
16
25
|
stream2buffer(stream: Readable, signal?: AbortSignal): Promise<Buffer>;
|
|
17
26
|
}
|
|
18
27
|
export {};
|
package/src/input/streamInput.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { LocalInputSource } from "./localInputSource.js";
|
|
2
3
|
import { INPUT_TYPE_STREAM } from "./inputSource.js";
|
|
3
4
|
import { logger } from "../logger.js";
|
|
4
5
|
import { MindeeInputSourceError } from "../errors/index.js";
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Local input source backed by a readable stream.
|
|
8
|
+
*/
|
|
6
9
|
export class StreamInput extends LocalInputSource {
|
|
7
10
|
constructor({ inputStream, filename }) {
|
|
8
11
|
super({
|
|
9
12
|
inputType: INPUT_TYPE_STREAM,
|
|
10
13
|
});
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Buffered payload created from the stream.
|
|
16
|
+
*/
|
|
12
17
|
this.fileObject = Buffer.alloc(0);
|
|
13
18
|
this.filename = filename;
|
|
14
19
|
this.inputStream = inputStream;
|
|
15
20
|
}
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Reads the stream to completion and validates MIME type.
|
|
23
|
+
*/
|
|
17
24
|
async init() {
|
|
18
25
|
if (this.initialized) {
|
|
19
26
|
return;
|
|
@@ -23,7 +30,9 @@ export class StreamInput extends LocalInputSource {
|
|
|
23
30
|
this.mimeType = await this.checkMimetype();
|
|
24
31
|
this.initialized = true;
|
|
25
32
|
}
|
|
26
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Converts a readable stream into a single buffer.
|
|
35
|
+
*/
|
|
27
36
|
async stream2buffer(stream, signal) {
|
|
28
37
|
return new Promise((resolve, reject) => {
|
|
29
38
|
if (stream.closed || stream.destroyed) {
|
package/src/input/urlInput.d.ts
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { InputSource } from "./inputSource.js";
|
|
2
1
|
import { Dispatcher } from "undici";
|
|
2
|
+
import { InputSource } from "./inputSource.js";
|
|
3
3
|
import { BytesInput } from "./bytesInput.js";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Remote input source represented by a validated HTTPS URL.
|
|
6
|
+
*/
|
|
5
7
|
export declare class UrlInput extends InputSource {
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* HTTPS URL of the remote input file.
|
|
10
|
+
*/
|
|
7
11
|
readonly url: string;
|
|
8
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Dispatcher used for HTTP requests.
|
|
14
|
+
*/
|
|
9
15
|
readonly dispatcher: Dispatcher;
|
|
10
16
|
constructor({ url, dispatcher }: {
|
|
11
17
|
url: string;
|
|
12
18
|
dispatcher?: Dispatcher;
|
|
13
19
|
});
|
|
14
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Initializes this source by validating and storing the URL.
|
|
22
|
+
*/
|
|
15
23
|
init(): Promise<void>;
|
|
16
24
|
/**
|
|
17
25
|
* Validates that a URL is safe to fetch: scheme must be https.
|
|
18
26
|
*/
|
|
19
27
|
static validateUrl(url: string): void;
|
|
20
28
|
private fetchFileContent;
|
|
21
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Downloads the URL content and writes it to disk.
|
|
31
|
+
*/
|
|
22
32
|
saveToFile(options: {
|
|
23
33
|
filepath: string;
|
|
24
34
|
filename?: string;
|
|
@@ -28,7 +38,9 @@ export declare class UrlInput extends InputSource {
|
|
|
28
38
|
headers?: Record<string, string>;
|
|
29
39
|
maxRedirects?: number;
|
|
30
40
|
}): Promise<string>;
|
|
31
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Downloads the URL content and returns it as a local bytes source.
|
|
43
|
+
*/
|
|
32
44
|
asLocalInputSource(options?: {
|
|
33
45
|
filename?: string;
|
|
34
46
|
username?: string;
|
package/src/input/urlInput.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { randomBytes } from "crypto";
|
|
5
|
-
import { writeFile } from "fs/promises";
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
6
4
|
import { request } from "undici";
|
|
5
|
+
import { URL } from "node:url";
|
|
6
|
+
import { InputSource } from "./inputSource.js";
|
|
7
7
|
import { logger } from "../logger.js";
|
|
8
8
|
import { MindeeInputSourceError } from "../errors/index.js";
|
|
9
9
|
import { resolveDefaultDispatcher } from "../http/dispatcher.js";
|
|
10
10
|
import { BytesInput } from "./bytesInput.js";
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Remote input source represented by a validated HTTPS URL.
|
|
13
|
+
*/
|
|
12
14
|
export class UrlInput extends InputSource {
|
|
13
15
|
constructor({ url, dispatcher }) {
|
|
14
16
|
super();
|
|
@@ -16,7 +18,9 @@ export class UrlInput extends InputSource {
|
|
|
16
18
|
this.dispatcher = dispatcher ?? resolveDefaultDispatcher();
|
|
17
19
|
logger.debug("Initialized URL input source.");
|
|
18
20
|
}
|
|
19
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Initializes this source by validating and storing the URL.
|
|
23
|
+
*/
|
|
20
24
|
async init() {
|
|
21
25
|
if (this.initialized) {
|
|
22
26
|
return;
|
|
@@ -52,7 +56,9 @@ export class UrlInput extends InputSource {
|
|
|
52
56
|
}
|
|
53
57
|
return await this.makeRequest(this.url, headers, 0, maxRedirects);
|
|
54
58
|
}
|
|
55
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Downloads the URL content and writes it to disk.
|
|
61
|
+
*/
|
|
56
62
|
async saveToFile(options) {
|
|
57
63
|
const { filepath, filename, ...fetchOptions } = options;
|
|
58
64
|
const { content, finalUrl } = await this.fetchFileContent(fetchOptions);
|
|
@@ -61,7 +67,9 @@ export class UrlInput extends InputSource {
|
|
|
61
67
|
await writeFile(fullPath, content);
|
|
62
68
|
return fullPath;
|
|
63
69
|
}
|
|
64
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Downloads the URL content and returns it as a local bytes source.
|
|
72
|
+
*/
|
|
65
73
|
async asLocalInputSource(options = {}) {
|
|
66
74
|
const { filename, ...fetchOptions } = options;
|
|
67
75
|
const { content, finalUrl } = await this.fetchFileContent(fetchOptions);
|
|
@@ -69,7 +77,7 @@ export class UrlInput extends InputSource {
|
|
|
69
77
|
return new BytesInput({ inputBytes: content, filename: finalFilename });
|
|
70
78
|
}
|
|
71
79
|
static extractFilenameFromUrl(uri) {
|
|
72
|
-
return basename(new URL(uri).pathname || "");
|
|
80
|
+
return path.basename(new URL(uri).pathname || "");
|
|
73
81
|
}
|
|
74
82
|
static generateFileName(extension = ".tmp") {
|
|
75
83
|
const randomString = randomBytes(4).toString("hex");
|
|
@@ -77,14 +85,14 @@ export class UrlInput extends InputSource {
|
|
|
77
85
|
return `mindee_temp_${timestamp}_${randomString}${extension}`;
|
|
78
86
|
}
|
|
79
87
|
static getFileExtension(filename) {
|
|
80
|
-
const ext = extname(filename);
|
|
88
|
+
const ext = path.extname(filename);
|
|
81
89
|
return ext ? ext.toLowerCase() : null;
|
|
82
90
|
}
|
|
83
91
|
fillFilename(filename, finalUrl) {
|
|
84
92
|
if (!filename) {
|
|
85
93
|
filename = finalUrl ? UrlInput.extractFilenameFromUrl(finalUrl) : UrlInput.extractFilenameFromUrl(this.url);
|
|
86
94
|
}
|
|
87
|
-
if (!filename || !extname(filename)) {
|
|
95
|
+
if (!filename || !path.extname(filename)) {
|
|
88
96
|
filename = UrlInput.generateFileName(UrlInput.getFileExtension(filename || "") || undefined);
|
|
89
97
|
}
|
|
90
98
|
return filename;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import { StringDict } from "./stringDict.js";
|
|
2
|
-
import { Buffer } from "buffer";
|
|
3
3
|
/**
|
|
4
4
|
* Local response loaded from a file.
|
|
5
5
|
* Note: Has to be initialized through init() before use.
|
|
@@ -7,13 +7,17 @@ import { Buffer } from "buffer";
|
|
|
7
7
|
export declare abstract class BaseLocalResponse {
|
|
8
8
|
private fileBytes;
|
|
9
9
|
private readonly inputHandle;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Whether the local response payload has been loaded.
|
|
12
|
+
*/
|
|
11
13
|
protected initialized: boolean;
|
|
12
14
|
/**
|
|
13
15
|
* Creates an instance of LocalResponse.
|
|
14
16
|
*/
|
|
15
17
|
constructor(inputFile: Buffer | string);
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Loads the local payload from a string, buffer, or file path.
|
|
20
|
+
*/
|
|
17
21
|
init(): Promise<void>;
|
|
18
22
|
/**
|
|
19
23
|
* Returns the dictionary representation of the file.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import * as crypto from "node:crypto";
|
|
2
3
|
import * as fs from "node:fs/promises";
|
|
3
4
|
import { MindeeError } from "../errors/index.js";
|
|
4
|
-
import { Buffer } from "buffer";
|
|
5
5
|
/**
|
|
6
6
|
* Local response loaded from a file.
|
|
7
7
|
* Note: Has to be initialized through init() before use.
|
|
@@ -11,18 +11,22 @@ export class BaseLocalResponse {
|
|
|
11
11
|
* Creates an instance of LocalResponse.
|
|
12
12
|
*/
|
|
13
13
|
constructor(inputFile) {
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Whether the local response payload has been loaded.
|
|
16
|
+
*/
|
|
15
17
|
this.initialized = false;
|
|
16
18
|
if (inputFile === undefined || inputFile === null) {
|
|
17
19
|
throw new TypeError("input cannot be null or undefined");
|
|
18
20
|
}
|
|
19
|
-
if (typeof inputFile === "string" ? !inputFile.trim() :
|
|
21
|
+
if (typeof inputFile === "string" ? !inputFile.trim() : inputFile.length === 0) {
|
|
20
22
|
throw new TypeError("input cannot be empty");
|
|
21
23
|
}
|
|
22
24
|
this.fileBytes = Buffer.alloc(0);
|
|
23
25
|
this.inputHandle = inputFile;
|
|
24
26
|
}
|
|
25
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Loads the local payload from a string, buffer, or file path.
|
|
29
|
+
*/
|
|
26
30
|
async init() {
|
|
27
31
|
/**
|
|
28
32
|
* @param inputFile - The input file, which can be a Buffer, string, or PathLike.
|
|
@@ -37,12 +41,12 @@ export class BaseLocalResponse {
|
|
|
37
41
|
let fileContents;
|
|
38
42
|
try {
|
|
39
43
|
await fs.access(this.inputHandle);
|
|
40
|
-
fileContents = await fs.readFile(this.inputHandle, { encoding: "
|
|
44
|
+
fileContents = await fs.readFile(this.inputHandle, { encoding: "utf8" });
|
|
41
45
|
}
|
|
42
46
|
catch {
|
|
43
47
|
fileContents = this.inputHandle;
|
|
44
48
|
}
|
|
45
|
-
this.fileBytes = Buffer.from(fileContents.replace(/\r/g, "").replace(/\n/g, ""), "
|
|
49
|
+
this.fileBytes = Buffer.from(fileContents.replace(/\r/g, "").replace(/\n/g, ""), "utf8");
|
|
46
50
|
}
|
|
47
51
|
else {
|
|
48
52
|
throw new MindeeError("Incompatible type for input.");
|
|
@@ -58,7 +62,7 @@ export class BaseLocalResponse {
|
|
|
58
62
|
await this.init();
|
|
59
63
|
}
|
|
60
64
|
try {
|
|
61
|
-
const content = this.fileBytes.toString("
|
|
65
|
+
const content = this.fileBytes.toString("utf8");
|
|
62
66
|
return JSON.parse(content);
|
|
63
67
|
}
|
|
64
68
|
catch {
|
|
@@ -102,8 +106,8 @@ export class BaseLocalResponse {
|
|
|
102
106
|
if (!expectedSignature?.trim()) {
|
|
103
107
|
return false;
|
|
104
108
|
}
|
|
105
|
-
const expectedBytes = Buffer.from(expectedSignature, "
|
|
106
|
-
const actualBytes = Buffer.from(signature.toLowerCase(), "
|
|
109
|
+
const expectedBytes = Buffer.from(expectedSignature, "utf8");
|
|
110
|
+
const actualBytes = Buffer.from(signature.toLowerCase(), "utf8");
|
|
107
111
|
if (expectedBytes.length !== actualBytes.length) {
|
|
108
112
|
return false;
|
|
109
113
|
}
|
|
@@ -113,6 +117,6 @@ export class BaseLocalResponse {
|
|
|
113
117
|
* Print the file as a UTF-8 string.
|
|
114
118
|
*/
|
|
115
119
|
toString() {
|
|
116
|
-
return this.fileBytes.toString("
|
|
120
|
+
return this.fileBytes.toString("utf8");
|
|
117
121
|
}
|
|
118
122
|
}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { BufferInput } from "../input/index.js";
|
|
2
1
|
import { Buffer } from "node:buffer";
|
|
3
|
-
|
|
2
|
+
import { BufferInput } from "../input/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a PDF artifact produced by an extraction/splitting operation.
|
|
5
|
+
*/
|
|
4
6
|
export declare class ExtractedPdf {
|
|
5
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Raw bytes of the extracted PDF segment.
|
|
9
|
+
*/
|
|
6
10
|
readonly buffer: Buffer;
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Filename suggested for export.
|
|
13
|
+
*/
|
|
8
14
|
readonly filename: string;
|
|
9
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Number of pages in this extracted PDF.
|
|
17
|
+
*/
|
|
10
18
|
readonly pageCount: number;
|
|
11
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Zero-based indexes of pages included in this extracted PDF.
|
|
21
|
+
*/
|
|
12
22
|
readonly pageIndexes: number[];
|
|
13
23
|
constructor(pdfData: Buffer<ArrayBufferLike>, filename: string, pageIndexes: number[]);
|
|
14
24
|
/**
|
package/src/pdf/extractedPdf.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { writeFileSync } from "node:fs";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
2
4
|
import { BufferInput, MIMETYPES } from "../input/index.js";
|
|
3
5
|
import { MindeeError } from "../errors/index.js";
|
|
4
|
-
import { writeFile } from "fs/promises";
|
|
5
6
|
import { logger } from "../logger.js";
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Represents a PDF artifact produced by an extraction/splitting operation.
|
|
9
|
+
*/
|
|
8
10
|
export class ExtractedPdf {
|
|
9
11
|
constructor(pdfData, filename, pageIndexes) {
|
|
10
12
|
this.buffer = pdfData;
|