From 0f50404e98ad66195cbae6b18327078b9d19c234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:16:40 +0100 Subject: [PATCH 1/6] :boom: :recycle: base for v5 (#413) * :arrow_up: update file-type * :recycle: migrate to ES modules (node18) * :coffin: remove support for obsolete/unused products: * API builder (no longer maintained, use v2) * :coffin: remove support for unused products available in v2: * nutrition facts * business card * US healthcare cards * bill of lading * :coffin: remove support for unused products: * delivery note * :recycle: use undici for HTTP requests and mocking * :sparkles: add ability for a user to specify their own undici `Dispatcher` instance * :sparkles: add basic V2 CLI --- .github/workflows/_static-analysis.yml | 2 +- .mocharc.json | 2 +- bin/mindee.ts | 5 - bin/mindeeV1.ts | 5 + bin/mindeeV2.ts | 5 + docs/code_samples/bill_of_lading_v1_async.txt | 23 - docs/code_samples/business_card_v1_async.txt | 23 - docs/code_samples/custom_v1.txt | 32 - docs/code_samples/delivery_notes_v1_async.txt | 23 - .../code_samples/nutrition_facts_v1_async.txt | 23 - .../us_healthcare_cards_v1_async.txt | 23 - package-lock.json | 1849 ++++++++++++----- package.json | 33 +- src/cliProducts.ts | 75 +- src/{cli.ts => cliV1.ts} | 96 +- src/cliV2.ts | 80 + src/client.ts | 179 +- src/clientV2.ts | 28 +- src/errors/handler.ts | 2 +- src/errors/index.ts | 6 +- src/errors/mindeeError.ts | 2 +- src/geometry/boundingBox.ts | 4 +- src/geometry/boundingBoxUtils.ts | 4 +- src/geometry/index.ts | 12 +- src/geometry/polygon.ts | 6 +- src/geometry/polygonUtils.ts | 4 +- src/http/apiCore.ts | 77 + src/http/apiSettings.ts | 33 +- src/http/apiSettingsV2.ts | 31 +- src/http/baseEndpoint.ts | 100 - src/http/baseSettings.ts | 18 +- src/http/endpoint.ts | 191 +- src/http/error.ts | 8 +- src/http/httpParams.ts | 4 +- src/http/index.ts | 13 +- src/http/mindeeApiV2.ts | 79 +- src/http/responseValidation.ts | 2 +- src/http/workflowEndpoint.ts | 112 +- src/imageOperations/common/extractedImage.ts | 8 +- src/imageOperations/common/imageExtractor.ts | 4 +- src/imageOperations/common/index.ts | 4 +- src/imageOperations/imageCompressor.ts | 2 +- src/imageOperations/index.ts | 7 +- src/imageOperations/internal.ts | 3 - .../extractedInvoiceSplitterImage.ts | 2 +- .../invoiceSplitterExtractor/index.ts | 4 +- .../invoiceSplitterExtractor.ts | 8 +- .../extractedMultiReceiptImage.ts | 2 +- .../multiReceiptsExtractor/index.ts | 4 +- .../multiReceiptsExtractor.ts | 14 +- src/index.ts | 22 +- src/input/dataSchema.ts | 4 +- src/input/index.ts | 12 +- src/input/localResponse.ts | 6 +- src/input/sources/base64Input.ts | 6 +- src/input/sources/bufferInput.ts | 6 +- src/input/sources/bytesInput.ts | 6 +- src/input/sources/index.ts | 21 +- src/input/sources/localInputSource.ts | 17 +- src/input/sources/pathInput.ts | 6 +- src/input/sources/streamInput.ts | 8 +- src/input/sources/urlInput.ts | 54 +- src/internal.ts | 7 - src/parsing/common/apiRequest.ts | 4 +- src/parsing/common/apiResponse.ts | 6 +- src/parsing/common/asyncPredictResponse.ts | 8 +- src/parsing/common/document.ts | 11 +- src/parsing/common/execution.ts | 12 +- src/parsing/common/executionFile.ts | 2 +- src/parsing/common/extras/cropperExtra.ts | 8 +- src/parsing/common/extras/fullTextOcrExtra.ts | 4 +- src/parsing/common/extras/index.ts | 7 +- src/parsing/common/extras/ragExtra.ts | 4 +- .../common/feedback/feedbackResponse.ts | 4 +- src/parsing/common/index.ts | 34 +- src/parsing/common/inference.ts | 19 +- src/parsing/common/mvisionV1.ts | 6 +- src/parsing/common/ocr.ts | 4 +- src/parsing/common/ocrPage.ts | 6 +- src/parsing/common/orientation.ts | 2 +- src/parsing/common/page.ts | 9 +- src/parsing/common/predictResponse.ts | 6 +- src/parsing/common/workflowResponse.ts | 8 +- src/parsing/custom/classificationField.ts | 30 - src/parsing/custom/index.ts | 3 - src/parsing/custom/lineItems.ts | 198 -- src/parsing/custom/listField.ts | 88 - src/parsing/generated/generatedList.ts | 6 +- src/parsing/generated/generatedObject.ts | 4 +- src/parsing/generated/index.ts | 4 +- src/parsing/index.ts | 9 +- src/parsing/standard/addressField.ts | 2 +- src/parsing/standard/amount.ts | 6 +- src/parsing/standard/base.ts | 2 +- src/parsing/standard/boolean.ts | 4 +- src/parsing/standard/classification.ts | 2 +- src/parsing/standard/companyRegistration.ts | 6 +- src/parsing/standard/date.ts | 4 +- src/parsing/standard/field.ts | 4 +- src/parsing/standard/index.ts | 29 +- src/parsing/standard/locale.ts | 2 +- src/parsing/standard/paymentDetails.ts | 4 +- src/parsing/standard/position.ts | 4 +- src/parsing/standard/tax.ts | 6 +- src/parsing/standard/text.ts | 4 +- src/parsing/standard/word.ts | 2 +- src/parsing/v2/commonResponse.ts | 2 +- src/parsing/v2/dataSchemaActiveOption.ts | 2 +- src/parsing/v2/errorItem.ts | 2 +- src/parsing/v2/errorResponse.ts | 4 +- src/parsing/v2/field/baseField.ts | 6 +- src/parsing/v2/field/fieldFactory.ts | 10 +- src/parsing/v2/field/fieldLocation.ts | 4 +- src/parsing/v2/field/index.ts | 12 +- src/parsing/v2/field/inferenceFields.ts | 10 +- src/parsing/v2/field/listField.ts | 12 +- src/parsing/v2/field/objectField.ts | 8 +- src/parsing/v2/field/simpleField.ts | 4 +- src/parsing/v2/index.ts | 29 +- src/parsing/v2/inference.ts | 10 +- src/parsing/v2/inferenceActiveOptions.ts | 4 +- src/parsing/v2/inferenceFile.ts | 2 +- src/parsing/v2/inferenceModel.ts | 2 +- src/parsing/v2/inferenceResponse.ts | 6 +- src/parsing/v2/inferenceResult.ts | 8 +- src/parsing/v2/job.ts | 8 +- src/parsing/v2/jobResponse.ts | 6 +- src/parsing/v2/jobWebhook.ts | 4 +- src/parsing/v2/ragMetadata.ts | 2 +- src/parsing/v2/rawText.ts | 4 +- src/parsing/v2/rawTextPage.ts | 2 +- src/pdf/index.ts | 7 +- src/pdf/pdfCompressor.ts | 6 +- src/pdf/pdfOperation.ts | 8 +- src/pdf/pdfUtils.ts | 2 +- src/product/barcodeReader/barcodeReaderV1.ts | 4 +- .../barcodeReader/barcodeReaderV1Document.ts | 4 +- src/product/barcodeReader/index.ts | 3 +- src/product/barcodeReader/internal.ts | 2 - src/product/billOfLading/billOfLadingV1.ts | 34 - .../billOfLading/billOfLadingV1Carrier.ts | 71 - .../billOfLading/billOfLadingV1CarrierItem.ts | 139 -- .../billOfLading/billOfLadingV1Consignee.ts | 78 - .../billOfLading/billOfLadingV1Document.ts | 126 -- .../billOfLading/billOfLadingV1NotifyParty.ts | 78 - .../billOfLading/billOfLadingV1Shipper.ts | 78 - src/product/billOfLading/index.ts | 1 - src/product/billOfLading/internal.ts | 7 - src/product/businessCard/businessCardV1.ts | 34 - .../businessCard/businessCardV1Document.ts | 106 - src/product/businessCard/index.ts | 1 - src/product/businessCard/internal.ts | 2 - src/product/cropper/cropperV1.ts | 6 +- src/product/cropper/cropperV1Document.ts | 2 +- src/product/cropper/cropperV1Page.ts | 6 +- src/product/cropper/index.ts | 4 +- src/product/cropper/internal.ts | 3 - src/product/custom/customV1.ts | 26 - src/product/custom/customV1Document.ts | 81 - src/product/custom/customV1Page.ts | 51 - src/product/custom/internal.ts | 3 - src/product/deliveryNote/deliveryNoteV1.ts | 34 - .../deliveryNote/deliveryNoteV1Document.ts | 75 - src/product/deliveryNote/index.ts | 1 - src/product/deliveryNote/internal.ts | 2 - src/product/driverLicense/driverLicenseV1.ts | 4 +- .../driverLicense/driverLicenseV1Document.ts | 4 +- src/product/driverLicense/index.ts | 3 +- src/product/driverLicense/internal.ts | 2 - .../financialDocument/financialDocumentV1.ts | 4 +- .../financialDocumentV1Document.ts | 6 +- .../financialDocumentV1LineItem.ts | 6 +- src/product/financialDocument/index.ts | 4 +- src/product/financialDocument/internal.ts | 3 - .../bankAccountDetailsV1.ts | 4 +- .../bankAccountDetailsV1Document.ts | 4 +- .../bankAccountDetailsV2.ts | 4 +- .../bankAccountDetailsV2Bban.ts | 4 +- .../bankAccountDetailsV2Document.ts | 6 +- src/product/fr/bankAccountDetails/index.ts | 7 +- src/product/fr/bankAccountDetails/internal.ts | 5 - src/product/fr/carteGrise/carteGriseV1.ts | 4 +- .../fr/carteGrise/carteGriseV1Document.ts | 4 +- src/product/fr/carteGrise/index.ts | 3 +- src/product/fr/carteGrise/internal.ts | 2 - src/product/fr/energyBill/energyBillV1.ts | 4 +- .../fr/energyBill/energyBillV1Document.ts | 16 +- .../energyBill/energyBillV1EnergyConsumer.ts | 4 +- .../energyBill/energyBillV1EnergySupplier.ts | 4 +- .../fr/energyBill/energyBillV1EnergyUsage.ts | 6 +- .../fr/energyBill/energyBillV1MeterDetail.ts | 4 +- .../fr/energyBill/energyBillV1Subscription.ts | 6 +- .../energyBillV1TaxesAndContribution.ts | 6 +- src/product/fr/energyBill/index.ts | 9 +- src/product/fr/energyBill/internal.ts | 8 - src/product/fr/healthCard/healthCardV1.ts | 4 +- .../fr/healthCard/healthCardV1Document.ts | 4 +- src/product/fr/healthCard/index.ts | 3 +- src/product/fr/healthCard/internal.ts | 2 - src/product/fr/idCard/idCardV1.ts | 6 +- src/product/fr/idCard/idCardV1Document.ts | 4 +- src/product/fr/idCard/idCardV1Page.ts | 7 +- src/product/fr/idCard/idCardV2.ts | 6 +- src/product/fr/idCard/idCardV2Document.ts | 4 +- src/product/fr/idCard/idCardV2Page.ts | 7 +- src/product/fr/idCard/index.ts | 8 +- src/product/fr/idCard/internal.ts | 6 - src/product/fr/index.ts | 18 +- src/product/fr/internal.ts | 11 +- src/product/fr/payslip/index.ts | 22 +- src/product/fr/payslip/internal.ts | 20 - src/product/fr/payslip/payslipV2.ts | 4 +- .../fr/payslip/payslipV2BankAccountDetail.ts | 4 +- src/product/fr/payslip/payslipV2Document.ts | 18 +- src/product/fr/payslip/payslipV2Employee.ts | 4 +- src/product/fr/payslip/payslipV2Employer.ts | 4 +- src/product/fr/payslip/payslipV2Employment.ts | 7 +- src/product/fr/payslip/payslipV2PayDetail.ts | 7 +- src/product/fr/payslip/payslipV2PayPeriod.ts | 4 +- src/product/fr/payslip/payslipV2Pto.ts | 7 +- .../fr/payslip/payslipV2SalaryDetail.ts | 6 +- src/product/fr/payslip/payslipV3.ts | 4 +- .../fr/payslip/payslipV3BankAccountDetail.ts | 4 +- src/product/fr/payslip/payslipV3Document.ts | 18 +- src/product/fr/payslip/payslipV3Employee.ts | 4 +- src/product/fr/payslip/payslipV3Employer.ts | 4 +- src/product/fr/payslip/payslipV3Employment.ts | 4 +- .../fr/payslip/payslipV3PaidTimeOff.ts | 6 +- src/product/fr/payslip/payslipV3PayDetail.ts | 7 +- src/product/fr/payslip/payslipV3PayPeriod.ts | 4 +- .../fr/payslip/payslipV3SalaryDetail.ts | 6 +- src/product/generated/generatedV1.ts | 6 +- src/product/generated/generatedV1Document.ts | 8 +- src/product/generated/generatedV1Page.ts | 8 +- .../generated/generatedV1Prediction.ts | 6 +- src/product/generated/index.ts | 4 + src/product/generated/internal.ts | 4 - src/product/ind/index.ts | 2 +- src/product/ind/indianPassport/index.ts | 3 +- .../ind/indianPassport/indianPassportV1.ts | 4 +- .../indianPassportV1Document.ts | 4 +- src/product/ind/indianPassport/internal.ts | 2 - src/product/ind/internal.ts | 2 +- src/product/index.ts | 35 +- src/product/internal.ts | 35 +- src/product/internationalId/index.ts | 3 +- src/product/internationalId/internal.ts | 2 - .../internationalId/internationalIdV2.ts | 4 +- .../internationalIdV2Document.ts | 4 +- src/product/invoice/index.ts | 4 +- src/product/invoice/internal.ts | 3 - src/product/invoice/invoiceV4.ts | 4 +- src/product/invoice/invoiceV4Document.ts | 6 +- src/product/invoice/invoiceV4LineItem.ts | 6 +- src/product/invoiceSplitter/index.ts | 4 +- src/product/invoiceSplitter/internal.ts | 3 - .../invoiceSplitter/invoiceSplitterV1.ts | 4 +- .../invoiceSplitterV1Document.ts | 4 +- .../invoiceSplitterV1InvoicePageGroup.ts | 4 +- src/product/multiReceiptsDetector/index.ts | 3 +- src/product/multiReceiptsDetector/internal.ts | 2 - .../multiReceiptsDetectorV1.ts | 4 +- .../multiReceiptsDetectorV1Document.ts | 4 +- src/product/nutritionFactsLabel/index.ts | 1 - src/product/nutritionFactsLabel/internal.ts | 15 - .../nutritionFactsLabelV1.ts | 34 - .../nutritionFactsLabelV1AddedSugar.ts | 99 - .../nutritionFactsLabelV1Calorie.ts | 99 - .../nutritionFactsLabelV1Cholesterol.ts | 99 - .../nutritionFactsLabelV1DietaryFiber.ts | 99 - .../nutritionFactsLabelV1Document.ts | 154 -- .../nutritionFactsLabelV1Nutrient.ts | 127 -- .../nutritionFactsLabelV1Protein.ts | 99 - .../nutritionFactsLabelV1SaturatedFat.ts | 99 - .../nutritionFactsLabelV1ServingSize.ts | 74 - .../nutritionFactsLabelV1Sodium.ts | 106 - .../nutritionFactsLabelV1TotalCarbohydrate.ts | 99 - .../nutritionFactsLabelV1TotalFat.ts | 99 - .../nutritionFactsLabelV1TotalSugar.ts | 99 - .../nutritionFactsLabelV1TransFat.ts | 99 - src/product/passport/index.ts | 3 +- src/product/passport/internal.ts | 2 - src/product/passport/passportV1.ts | 4 +- src/product/passport/passportV1Document.ts | 4 +- src/product/receipt/index.ts | 4 +- src/product/receipt/internal.ts | 3 - src/product/receipt/receiptV5.ts | 4 +- src/product/receipt/receiptV5Document.ts | 6 +- src/product/receipt/receiptV5LineItem.ts | 6 +- src/product/resume/index.ts | 8 +- src/product/resume/internal.ts | 7 - src/product/resume/resumeV1.ts | 4 +- src/product/resume/resumeV1Certificate.ts | 7 +- src/product/resume/resumeV1Document.ts | 14 +- src/product/resume/resumeV1Education.ts | 6 +- src/product/resume/resumeV1Language.ts | 6 +- .../resume/resumeV1ProfessionalExperience.ts | 6 +- .../resume/resumeV1SocialNetworksUrl.ts | 6 +- src/product/us/bankCheck/bankCheckV1.ts | 6 +- .../us/bankCheck/bankCheckV1Document.ts | 4 +- src/product/us/bankCheck/bankCheckV1Page.ts | 7 +- src/product/us/bankCheck/index.ts | 4 +- src/product/us/bankCheck/internal.ts | 3 - .../us/healthcareCard/healthcareCardV1.ts | 34 - .../healthcareCard/healthcareCardV1Copay.ts | 82 - .../healthcareCardV1Document.ts | 146 -- src/product/us/healthcareCard/index.ts | 1 - src/product/us/healthcareCard/internal.ts | 3 - src/product/us/index.ts | 5 +- src/product/us/internal.ts | 5 +- src/product/us/usMail/index.ts | 5 +- src/product/us/usMail/internal.ts | 4 - src/product/us/usMail/usMailV3.ts | 4 +- src/product/us/usMail/usMailV3Document.ts | 8 +- .../us/usMail/usMailV3RecipientAddress.ts | 6 +- .../us/usMail/usMailV3SenderAddress.ts | 4 +- tests/geometry.spec.ts | 2 +- tests/index.ts | 7 +- tests/input/pageOperations.spec.ts | 4 +- tests/{v1 => }/input/sources.integration.ts | 8 +- tests/input/sources.spec.ts | 18 +- .../input/urlInputSource.integration.ts | 8 +- tests/input/urlInputSource.spec.ts | 79 +- tests/pdf/pdfOperation.spec.ts | 8 +- tests/pdf/pdfTypes.spec.ts | 15 +- tests/v1/api/asyncResponse.spec.ts | 10 +- tests/v1/api/endpoint.spec.ts | 160 +- tests/v1/api/feedbackResponse.spec.ts | 4 +- tests/v1/api/response.spec.ts | 18 +- .../{index.spec.ts => v1/clientInit.spec.ts} | 14 +- tests/v1/extras/extras.integration.ts | 12 +- tests/v1/extras/fullTextOcr.spec.ts | 6 +- tests/v1/extras/ocr.spec.ts | 6 +- .../invoiceSplitterExtractor.spec.ts | 8 +- .../invoiceSplitterReconstruction.spec.ts | 10 +- .../multiReceiptsExtractor.spec.ts | 8 +- ...multiReceiptsReconstruction.integration.ts | 10 +- .../multiReceiptsReconstruction.spec.ts | 8 +- tests/v1/input/localResponse.spec.ts | 6 +- tests/v1/parsing/standard/amount.spec.ts | 2 +- .../parsing/standard/classification.spec.ts | 2 +- tests/v1/parsing/standard/date.spec.ts | 2 +- tests/v1/parsing/standard/field.spec.ts | 2 +- tests/v1/parsing/standard/locale.spec.ts | 2 +- tests/v1/parsing/standard/orientation.spec.ts | 2 +- .../parsing/standard/paymentDetails.spec.ts | 2 +- tests/v1/parsing/standard/position.spec.ts | 2 +- tests/v1/parsing/standard/tax.spec.ts | 2 +- tests/v1/parsing/standard/text.spec.ts | 2 +- .../barcodeReader/barcodeReaderV1.spec.ts | 4 +- .../billOfLading/billOfLadingV1.spec.ts | 52 - .../businessCard/businessCardV1.spec.ts | 41 - tests/v1/product/cropper/cropperV1.spec.ts | 4 +- .../v1/product/custom/customDocument.spec.ts | 130 -- tests/v1/product/custom/lineItems.spec.ts | 129 -- .../deliveryNote/deliveryNoteV1.spec.ts | 37 - .../driverLicense/driverLicenseV1.spec.ts | 4 +- .../financialDocumentV1.spec.ts | 4 +- .../bankAccountDetailsV1.spec.ts | 4 +- .../bankAccountDetailsV2.spec.ts | 4 +- .../fr/energyBill/energyBillV1.spec.ts | 4 +- .../fr/healthCard/healthCardV1.spec.ts | 4 +- tests/v1/product/fr/idCard/idCardV1.spec.ts | 4 +- tests/v1/product/fr/idCard/idCardV2.spec.ts | 4 +- tests/v1/product/fr/payslip/payslipV2.spec.ts | 4 +- tests/v1/product/fr/payslip/payslipV3.spec.ts | 4 +- .../product/generated/generatedList.spec.ts | 2 +- .../product/generated/generatedObject.spec.ts | 2 +- .../v1/product/generated/generatedV1.spec.ts | 14 +- .../indianPassport/indianPassportV1.spec.ts | 4 +- .../internationalId/internationalIdV2.spec.ts | 4 +- tests/v1/product/invoice/invoiceV4.spec.ts | 4 +- .../invoiceSplitter.integration.ts | 6 +- .../invoiceSplitter/invoiceSplitterV1.spec.ts | 4 +- .../multiReceiptsDetectorV1.spec.ts | 4 +- .../nutritionFactsLabelV1.spec.ts | 68 - tests/v1/product/passport/passportV1.spec.ts | 4 +- tests/v1/product/receipt/receiptV5.spec.ts | 4 +- tests/v1/product/resume/resumeV1.spec.ts | 4 +- .../product/us/bankCheck/bankCheckV1.spec.ts | 4 +- .../healthcareCard/healthcareCardV1.spec.ts | 44 - tests/v1/product/us/usMail/usMailV3.spec.ts | 4 +- tests/v1/workflows/workflow.integration.ts | 14 +- tests/v1/workflows/workflow.spec.ts | 61 +- tests/v2/clientV2.integration.ts | 12 +- tests/v2/clientV2.spec.ts | 73 +- tests/v2/input/inferenceParameter.spec.ts | 8 +- tests/v2/input/localResponse.spec.ts | 4 +- tests/v2/parsing/inference.spec.ts | 8 +- tests/v2/parsing/job.spec.ts | 6 +- tsconfig.json | 30 +- 391 files changed, 2958 insertions(+), 6137 deletions(-) delete mode 100755 bin/mindee.ts create mode 100755 bin/mindeeV1.ts create mode 100755 bin/mindeeV2.ts delete mode 100644 docs/code_samples/bill_of_lading_v1_async.txt delete mode 100644 docs/code_samples/business_card_v1_async.txt delete mode 100644 docs/code_samples/custom_v1.txt delete mode 100644 docs/code_samples/delivery_notes_v1_async.txt delete mode 100644 docs/code_samples/nutrition_facts_v1_async.txt delete mode 100644 docs/code_samples/us_healthcare_cards_v1_async.txt rename src/{cli.ts => cliV1.ts} (74%) create mode 100644 src/cliV2.ts create mode 100644 src/http/apiCore.ts delete mode 100644 src/http/baseEndpoint.ts delete mode 100644 src/imageOperations/internal.ts delete mode 100644 src/internal.ts delete mode 100644 src/parsing/custom/classificationField.ts delete mode 100644 src/parsing/custom/index.ts delete mode 100644 src/parsing/custom/lineItems.ts delete mode 100644 src/parsing/custom/listField.ts delete mode 100644 src/product/barcodeReader/internal.ts delete mode 100644 src/product/billOfLading/billOfLadingV1.ts delete mode 100644 src/product/billOfLading/billOfLadingV1Carrier.ts delete mode 100644 src/product/billOfLading/billOfLadingV1CarrierItem.ts delete mode 100644 src/product/billOfLading/billOfLadingV1Consignee.ts delete mode 100644 src/product/billOfLading/billOfLadingV1Document.ts delete mode 100644 src/product/billOfLading/billOfLadingV1NotifyParty.ts delete mode 100644 src/product/billOfLading/billOfLadingV1Shipper.ts delete mode 100644 src/product/billOfLading/index.ts delete mode 100644 src/product/billOfLading/internal.ts delete mode 100644 src/product/businessCard/businessCardV1.ts delete mode 100644 src/product/businessCard/businessCardV1Document.ts delete mode 100644 src/product/businessCard/index.ts delete mode 100644 src/product/businessCard/internal.ts delete mode 100644 src/product/cropper/internal.ts delete mode 100644 src/product/custom/customV1.ts delete mode 100644 src/product/custom/customV1Document.ts delete mode 100644 src/product/custom/customV1Page.ts delete mode 100644 src/product/custom/internal.ts delete mode 100644 src/product/deliveryNote/deliveryNoteV1.ts delete mode 100644 src/product/deliveryNote/deliveryNoteV1Document.ts delete mode 100644 src/product/deliveryNote/index.ts delete mode 100644 src/product/deliveryNote/internal.ts delete mode 100644 src/product/driverLicense/internal.ts delete mode 100644 src/product/financialDocument/internal.ts delete mode 100644 src/product/fr/bankAccountDetails/internal.ts delete mode 100644 src/product/fr/carteGrise/internal.ts delete mode 100644 src/product/fr/energyBill/internal.ts delete mode 100644 src/product/fr/healthCard/internal.ts delete mode 100644 src/product/fr/idCard/internal.ts delete mode 100644 src/product/fr/payslip/internal.ts create mode 100644 src/product/generated/index.ts delete mode 100644 src/product/generated/internal.ts delete mode 100644 src/product/ind/indianPassport/internal.ts delete mode 100644 src/product/internationalId/internal.ts delete mode 100644 src/product/invoice/internal.ts delete mode 100644 src/product/invoiceSplitter/internal.ts delete mode 100644 src/product/multiReceiptsDetector/internal.ts delete mode 100644 src/product/nutritionFactsLabel/index.ts delete mode 100644 src/product/nutritionFactsLabel/internal.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts delete mode 100644 src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts delete mode 100644 src/product/passport/internal.ts delete mode 100644 src/product/receipt/internal.ts delete mode 100644 src/product/resume/internal.ts delete mode 100644 src/product/us/bankCheck/internal.ts delete mode 100644 src/product/us/healthcareCard/healthcareCardV1.ts delete mode 100644 src/product/us/healthcareCard/healthcareCardV1Copay.ts delete mode 100644 src/product/us/healthcareCard/healthcareCardV1Document.ts delete mode 100644 src/product/us/healthcareCard/index.ts delete mode 100644 src/product/us/healthcareCard/internal.ts delete mode 100644 src/product/us/usMail/internal.ts rename tests/{v1 => }/input/sources.integration.ts (94%) rename tests/{v1 => }/input/urlInputSource.integration.ts (78%) rename tests/{index.spec.ts => v1/clientInit.spec.ts} (54%) rename tests/{ => v1}/imageOperations/invoiceSplitterExtractor.spec.ts (86%) rename tests/v1/{api => imageOperations}/invoiceSplitterReconstruction.spec.ts (88%) rename tests/{ => v1}/imageOperations/multiReceiptsExtractor.spec.ts (92%) rename tests/v1/{api => imageOperations}/multiReceiptsReconstruction.integration.ts (96%) rename tests/v1/{api => imageOperations}/multiReceiptsReconstruction.spec.ts (92%) delete mode 100644 tests/v1/product/billOfLading/billOfLadingV1.spec.ts delete mode 100644 tests/v1/product/businessCard/businessCardV1.spec.ts delete mode 100644 tests/v1/product/custom/customDocument.spec.ts delete mode 100644 tests/v1/product/custom/lineItems.spec.ts delete mode 100644 tests/v1/product/deliveryNote/deliveryNoteV1.spec.ts delete mode 100644 tests/v1/product/nutritionFactsLabel/nutritionFactsLabelV1.spec.ts delete mode 100644 tests/v1/product/us/healthcareCard/healthcareCardV1.spec.ts diff --git a/.github/workflows/_static-analysis.yml b/.github/workflows/_static-analysis.yml index 17db8e65..831822f2 100644 --- a/.github/workflows/_static-analysis.yml +++ b/.github/workflows/_static-analysis.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 22 cache: "npm" - name: Install Node.js dependencies diff --git a/.mocharc.json b/.mocharc.json index 555e7056..c82ad1d5 100644 --- a/.mocharc.json +++ b/.mocharc.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/mocharc", "extension": ["ts"], - "require": "ts-node/register", + "node-option": ["import=tsx"], "spec": ["tests"] } diff --git a/bin/mindee.ts b/bin/mindee.ts deleted file mode 100755 index b1d16ae6..00000000 --- a/bin/mindee.ts +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env node - -import { cli } from "../src/cli"; - -cli(); diff --git a/bin/mindeeV1.ts b/bin/mindeeV1.ts new file mode 100755 index 00000000..8f46f652 --- /dev/null +++ b/bin/mindeeV1.ts @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +import { cliV1 } from "@/cliV1.js"; + +cliV1(); diff --git a/bin/mindeeV2.ts b/bin/mindeeV2.ts new file mode 100755 index 00000000..0040c7d7 --- /dev/null +++ b/bin/mindeeV2.ts @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +import { cliV2 } from "@/cliV2.js"; + +cliV2(); diff --git a/docs/code_samples/bill_of_lading_v1_async.txt b/docs/code_samples/bill_of_lading_v1_async.txt deleted file mode 100644 index dd780dbc..00000000 --- a/docs/code_samples/bill_of_lading_v1_async.txt +++ /dev/null @@ -1,23 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.BillOfLadingV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/business_card_v1_async.txt b/docs/code_samples/business_card_v1_async.txt deleted file mode 100644 index 9d043e17..00000000 --- a/docs/code_samples/business_card_v1_async.txt +++ /dev/null @@ -1,23 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.BusinessCardV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/custom_v1.txt b/docs/code_samples/custom_v1.txt deleted file mode 100644 index 13cdbb2b..00000000 --- a/docs/code_samples/custom_v1.txt +++ /dev/null @@ -1,32 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Create a custom endpoint for your product -const customEndpoint = mindeeClient.createEndpoint( - "my-endpoint", - "my-account", - // "my-version" // Optional: set the version, defaults to "1" -); - -// Parse it -const apiResponse = mindeeClient - .parse( - mindee.product.CustomV1, - inputSource, - { endpoint: customEndpoint } - ); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/delivery_notes_v1_async.txt b/docs/code_samples/delivery_notes_v1_async.txt deleted file mode 100644 index 7ee02c9a..00000000 --- a/docs/code_samples/delivery_notes_v1_async.txt +++ /dev/null @@ -1,23 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.DeliveryNoteV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/nutrition_facts_v1_async.txt b/docs/code_samples/nutrition_facts_v1_async.txt deleted file mode 100644 index bbdc347e..00000000 --- a/docs/code_samples/nutrition_facts_v1_async.txt +++ /dev/null @@ -1,23 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.NutritionFactsLabelV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/docs/code_samples/us_healthcare_cards_v1_async.txt b/docs/code_samples/us_healthcare_cards_v1_async.txt deleted file mode 100644 index 87e6cac0..00000000 --- a/docs/code_samples/us_healthcare_cards_v1_async.txt +++ /dev/null @@ -1,23 +0,0 @@ -const mindee = require("mindee"); -// for TS or modules: -// import * as mindee from "mindee"; - -// Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); - -// Load a file from disk -const inputSource = new mindee.PathInput( - { inputPath: "/path/to/the/file.ext" } -); - -// Parse the file -const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.us.HealthcareCardV1, - inputSource -); - -// Handle the response Promise -apiResponse.then((resp) => { - // print a string summary - console.log(resp.document.toString()); -}); diff --git a/package-lock.json b/package-lock.json index cb60284e..e2c80c95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,13 +11,14 @@ "dependencies": { "@cantoo/pdf-lib": "^2.3.2", "commander": "~9.4.1", - "file-type": "~16.5.4", - "form-data": "~3.0.1", - "node-poppler": "^7.2.2", + "file-type": "^19.6.0", + "form-data": "^3.0.4", + "node-poppler": "^7.2.4", "pdf.js-extract": "^0.2.1", - "sharp": "^0.33.5", + "sharp": "~0.34.5", "tmp": "^0.2.3", - "tslib": "^2.8.1" + "tslib": "^2.8.1", + "undici": "^6.23.0" }, "bin": { "mindee": "bin/mindee.js" @@ -29,17 +30,27 @@ "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^8.52.0", "@typescript-eslint/parser": "^8.52.0", - "chai": "^4.5.0", - "eslint": "^9.20.1", + "chai": "^6.2.2", + "eslint": "^9.39.2", "eslint-plugin-jsdoc": "^50.6.17", "mocha": "^11.7.5", - "nock": "^13.5.6", - "ts-node": "^10.9.2", + "tsc-alias": "^1.8.16", + "tsx": "^4.21.0", "typedoc": "~0.28.15", "typescript": "^5.9.3" }, "engines": { - "node": ">= 18" + "node": ">= 18.17" + } + }, + "node_modules/@borewit/text-codec": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.1.tgz", + "integrity": "sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" } }, "node_modules/@cantoo/pdf-lib": { @@ -57,19 +68,6 @@ "tslib": ">=2" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@emnapi/runtime": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.8.1.tgz", @@ -97,6 +95,448 @@ "node": ">=18" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", + "integrity": "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.2.tgz", + "integrity": "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.2.tgz", + "integrity": "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.2.tgz", + "integrity": "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.2.tgz", + "integrity": "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.2.tgz", + "integrity": "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.2.tgz", + "integrity": "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.2.tgz", + "integrity": "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.2.tgz", + "integrity": "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.2.tgz", + "integrity": "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.2.tgz", + "integrity": "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.2.tgz", + "integrity": "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.2.tgz", + "integrity": "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.2.tgz", + "integrity": "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.2.tgz", + "integrity": "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.2.tgz", + "integrity": "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.2.tgz", + "integrity": "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.2.tgz", + "integrity": "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.2.tgz", + "integrity": "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.2.tgz", + "integrity": "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.2.tgz", + "integrity": "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.2.tgz", + "integrity": "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.2.tgz", + "integrity": "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.2.tgz", + "integrity": "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.2.tgz", + "integrity": "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.2.tgz", + "integrity": "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.9.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", @@ -352,10 +792,19 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@img/colour": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.0.0.tgz", + "integrity": "sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/@img/sharp-darwin-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz", - "integrity": "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", "cpu": [ "arm64" ], @@ -371,13 +820,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.0.4" + "@img/sharp-libvips-darwin-arm64": "1.2.4" } }, "node_modules/@img/sharp-darwin-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz", - "integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", "cpu": [ "x64" ], @@ -393,13 +842,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.0.4" + "@img/sharp-libvips-darwin-x64": "1.2.4" } }, "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz", - "integrity": "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", "cpu": [ "arm64" ], @@ -413,9 +862,9 @@ } }, "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz", - "integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", "cpu": [ "x64" ], @@ -429,9 +878,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz", - "integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", "cpu": [ "arm" ], @@ -445,9 +894,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz", - "integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", "cpu": [ "arm64" ], @@ -460,10 +909,42 @@ "url": "https://opencollective.com/libvips" } }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.4.tgz", - "integrity": "sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", "cpu": [ "s390x" ], @@ -477,9 +958,9 @@ } }, "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz", - "integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", "cpu": [ "x64" ], @@ -493,9 +974,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz", - "integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", "cpu": [ "arm64" ], @@ -509,9 +990,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz", - "integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", "cpu": [ "x64" ], @@ -525,9 +1006,9 @@ } }, "node_modules/@img/sharp-linux-arm": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz", - "integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", "cpu": [ "arm" ], @@ -543,13 +1024,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.0.5" + "@img/sharp-libvips-linux-arm": "1.2.4" } }, "node_modules/@img/sharp-linux-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz", - "integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", "cpu": [ "arm64" ], @@ -565,13 +1046,57 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.0.4" + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" } }, "node_modules/@img/sharp-linux-s390x": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.5.tgz", - "integrity": "sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", "cpu": [ "s390x" ], @@ -587,13 +1112,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.0.4" + "@img/sharp-libvips-linux-s390x": "1.2.4" } }, "node_modules/@img/sharp-linux-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz", - "integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", "cpu": [ "x64" ], @@ -609,13 +1134,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.0.4" + "@img/sharp-libvips-linux-x64": "1.2.4" } }, "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz", - "integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", "cpu": [ "arm64" ], @@ -631,13 +1156,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.0.4" + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" } }, "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz", - "integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", "cpu": [ "x64" ], @@ -653,20 +1178,20 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.0.4" + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" } }, "node_modules/@img/sharp-wasm32": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.5.tgz", - "integrity": "sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", "cpu": [ "wasm32" ], "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", "optional": true, "dependencies": { - "@emnapi/runtime": "^1.2.0" + "@emnapi/runtime": "^1.7.0" }, "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0" @@ -675,10 +1200,29 @@ "url": "https://opencollective.com/libvips" } }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@img/sharp-win32-ia32": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.5.tgz", - "integrity": "sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", "cpu": [ "ia32" ], @@ -695,9 +1239,9 @@ } }, "node_modules/@img/sharp-win32-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz", - "integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", "cpu": [ "x64" ], @@ -731,32 +1275,42 @@ "node": ">=12" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, "engines": { - "node": ">=6.0.0" + "node": ">= 8" } }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">= 8" + } }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" } }, "node_modules/@pdf-lib/standard-fonts": { @@ -788,6 +1342,12 @@ "node": ">=14" } }, + "node_modules/@sec-ant/readable-stream": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", + "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==", + "license": "MIT" + }, "node_modules/@shikijs/engine-oniguruma": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.21.0.tgz", @@ -843,34 +1403,6 @@ "integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==", "license": "MIT" }, - "node_modules/@tsconfig/node10": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz", - "integrity": "sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -1177,18 +1709,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "license": "MIT", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, "node_modules/acorn": { "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", @@ -1212,19 +1732,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -1271,6 +1778,33 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/are-docs-informative": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", @@ -1281,13 +1815,6 @@ "node": ">=14" } }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1295,6 +1822,16 @@ "dev": true, "license": "Python-2.0" }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -1304,40 +1841,33 @@ "engines": { "node": ">=12" } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, "license": "MIT" }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/brace-expansion": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", @@ -1348,6 +1878,19 @@ "balanced-match": "^1.0.0" } }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -1355,30 +1898,6 @@ "dev": true, "license": "ISC" }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, "node_modules/call-bind-apply-helpers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", @@ -1415,32 +1934,13 @@ } }, "node_modules/chai": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", - "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", - "dev": true, - "license": "MIT", - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.3", - "deep-eql": "^4.1.3", - "get-func-name": "^2.0.2", - "loupe": "^2.3.6", - "pathval": "^1.1.1", - "type-detect": "^4.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chai/node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", "dev": true, "license": "MIT", "engines": { - "node": "*" + "node": ">=18" } }, "node_modules/chalk": { @@ -1460,19 +1960,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", - "dev": true, - "license": "MIT", - "dependencies": { - "get-func-name": "^2.0.2" - }, - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", @@ -1646,13 +2133,6 @@ "dev": true, "license": "MIT" }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, - "license": "MIT" - }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -1705,19 +2185,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-eql": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", - "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", - "dev": true, - "license": "MIT", - "dependencies": { - "type-detect": "^4.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1753,6 +2220,19 @@ "node": ">=0.3.1" } }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/dommatrix": { "version": "0.0.24", "resolved": "https://registry.npmjs.org/dommatrix/-/dommatrix-0.0.24.tgz", @@ -1845,6 +2325,48 @@ "node": ">= 0.4" } }, + "node_modules/esbuild": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", + "integrity": "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.2", + "@esbuild/android-arm": "0.27.2", + "@esbuild/android-arm64": "0.27.2", + "@esbuild/android-x64": "0.27.2", + "@esbuild/darwin-arm64": "0.27.2", + "@esbuild/darwin-x64": "0.27.2", + "@esbuild/freebsd-arm64": "0.27.2", + "@esbuild/freebsd-x64": "0.27.2", + "@esbuild/linux-arm": "0.27.2", + "@esbuild/linux-arm64": "0.27.2", + "@esbuild/linux-ia32": "0.27.2", + "@esbuild/linux-loong64": "0.27.2", + "@esbuild/linux-mips64el": "0.27.2", + "@esbuild/linux-ppc64": "0.27.2", + "@esbuild/linux-riscv64": "0.27.2", + "@esbuild/linux-s390x": "0.27.2", + "@esbuild/linux-x64": "0.27.2", + "@esbuild/netbsd-arm64": "0.27.2", + "@esbuild/netbsd-x64": "0.27.2", + "@esbuild/openbsd-arm64": "0.27.2", + "@esbuild/openbsd-x64": "0.27.2", + "@esbuild/openharmony-arm64": "0.27.2", + "@esbuild/sunos-x64": "0.27.2", + "@esbuild/win32-arm64": "0.27.2", + "@esbuild/win32-ia32": "0.27.2", + "@esbuild/win32-x64": "0.27.2" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -2107,24 +2629,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "license": "MIT", - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2132,6 +2636,36 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2146,6 +2680,16 @@ "dev": true, "license": "MIT" }, + "node_modules/fastq": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", + "integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -2178,22 +2722,36 @@ } }, "node_modules/file-type": { - "version": "16.5.4", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", - "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", + "version": "19.6.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-19.6.0.tgz", + "integrity": "sha512-VZR5I7k5wkD0HgFnMsq5hOsSc710MJMu5Nc5QYsbe38NN5iPV/XTObYLc/cpttRTf6lX538+5uO1ZQRhYibiZQ==", "license": "MIT", "dependencies": { - "readable-web-to-node-stream": "^3.0.0", - "strtok3": "^6.2.4", - "token-types": "^4.1.1" + "get-stream": "^9.0.1", + "strtok3": "^9.0.1", + "token-types": "^6.0.0", + "uint8array-extras": "^1.3.0" }, "engines": { - "node": ">=10" + "node": ">=18" }, "funding": { "url": "https://github.com/sindresorhus/file-type?sponsor=1" } }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2275,6 +2833,21 @@ "node": ">= 6" } }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -2294,16 +2867,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" - } - }, "node_modules/get-intrinsic": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", @@ -2341,6 +2904,35 @@ "node": ">= 0.4" } }, + "node_modules/get-stream": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", + "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==", + "license": "MIT", + "dependencies": { + "@sec-ant/readable-stream": "^0.4.1", + "is-stream": "^4.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-tsconfig": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz", + "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "10.5.0", "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", @@ -2388,6 +2980,37 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globby/node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -2538,6 +3161,19 @@ "integrity": "sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==", "license": "MIT" }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2571,6 +3207,16 @@ "node": ">=0.10.0" } }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -2591,6 +3237,18 @@ "node": ">=8" } }, + "node_modules/is-stream": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz", + "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", @@ -2671,13 +3329,6 @@ "dev": true, "license": "MIT" }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "dev": true, - "license": "ISC" - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -2752,16 +3403,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/loupe": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", - "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", - "dev": true, - "license": "MIT", - "dependencies": { - "get-func-name": "^2.0.1" - } - }, "node_modules/lru-cache": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", @@ -2776,13 +3417,6 @@ "dev": true, "license": "MIT" }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, "node_modules/markdown-it": { "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", @@ -2801,21 +3435,58 @@ "markdown-it": "bin/markdown-it.mjs" } }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, "engines": { - "node": ">= 0.4" + "node": ">=8.6" } }, - "node_modules/mdurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, "node_modules/mime-db": { "version": "1.52.0", @@ -2924,6 +3595,20 @@ "dev": true, "license": "MIT" }, + "node_modules/mylas": { + "version": "2.1.14", + "resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.14.tgz", + "integrity": "sha512-BzQguy9W9NJgoVn2mRWzbFrFWWztGCcng2QI9+41frfk+Athwgx3qhqhvStz7ExeUUu7Kzw427sNzHpEZNINog==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/raouldeheer" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -2931,21 +3616,6 @@ "dev": true, "license": "MIT" }, - "node_modules/nock": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.6.tgz", - "integrity": "sha512-o2zOYiCpzRqSzPj0Zt/dQ/DqZeYoaQ7TUonc/xUPjCGl9WeHpNbxgVvOquXYAaJzI0M9BXV3HTzG0p8IUAbBTQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.0", - "json-stringify-safe": "^5.0.1", - "propagate": "^2.0.0" - }, - "engines": { - "node": ">= 10.13" - } - }, "node_modules/node-html-better-parser": { "version": "1.5.8", "resolved": "https://registry.npmjs.org/node-html-better-parser/-/node-html-better-parser-1.5.8.tgz", @@ -2971,6 +3641,16 @@ "url": "https://github.com/sponsors/Fdawgs" } }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -3101,14 +3781,14 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, "license": "MIT", "engines": { - "node": "*" + "node": ">=8" } }, "node_modules/pdf.js-extract": { @@ -3125,12 +3805,12 @@ } }, "node_modules/peek-readable": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", - "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.4.2.tgz", + "integrity": "sha512-peBp3qZyuS6cNIJ2akRNG1uo1WJ1d0wTxg/fxMdZ0BqCVhx242bSFHM9eNqflfJVS9SsgkzgT/1UgnsurBOTMg==", "license": "MIT", "engines": { - "node": ">=8" + "node": ">=14.16" }, "funding": { "type": "github", @@ -3157,33 +3837,27 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "node_modules/plimit-lit": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.6.1.tgz", + "integrity": "sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==", "dev": true, "license": "MIT", + "dependencies": { + "queue-lit": "^1.5.1" + }, "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "license": "MIT", - "engines": { - "node": ">= 0.6.0" + "node": ">=12" } }, - "node_modules/propagate": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", - "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "license": "MIT", "engines": { - "node": ">= 8" + "node": ">= 0.8.0" } }, "node_modules/punycode": { @@ -3206,6 +3880,37 @@ "node": ">=6" } }, + "node_modules/queue-lit": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.2.tgz", + "integrity": "sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -3216,38 +3921,6 @@ "safe-buffer": "^5.1.0" } }, - "node_modules/readable-stream": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", - "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", - "license": "MIT", - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/readable-web-to-node-stream": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.4.tgz", - "integrity": "sha512-9nX56alTf5bwXQ3ZDipHJhusu9NTQJ/CVPtb/XHAJCXihZeitfJvIRS4GqQ/mfIoOE3IelHMrpayVrosdHBuLw==", - "license": "MIT", - "dependencies": { - "readable-stream": "^4.7.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Borewit" - } - }, "node_modules/readdirp": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", @@ -3282,10 +3955,56 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -3325,15 +4044,15 @@ } }, "node_modules/sharp": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.5.tgz", - "integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==", + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "color": "^4.2.3", - "detect-libc": "^2.0.3", - "semver": "^7.6.3" + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" }, "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0" @@ -3342,25 +4061,30 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.33.5", - "@img/sharp-darwin-x64": "0.33.5", - "@img/sharp-libvips-darwin-arm64": "1.0.4", - "@img/sharp-libvips-darwin-x64": "1.0.4", - "@img/sharp-libvips-linux-arm": "1.0.5", - "@img/sharp-libvips-linux-arm64": "1.0.4", - "@img/sharp-libvips-linux-s390x": "1.0.4", - "@img/sharp-libvips-linux-x64": "1.0.4", - "@img/sharp-libvips-linuxmusl-arm64": "1.0.4", - "@img/sharp-libvips-linuxmusl-x64": "1.0.4", - "@img/sharp-linux-arm": "0.33.5", - "@img/sharp-linux-arm64": "0.33.5", - "@img/sharp-linux-s390x": "0.33.5", - "@img/sharp-linux-x64": "0.33.5", - "@img/sharp-linuxmusl-arm64": "0.33.5", - "@img/sharp-linuxmusl-x64": "0.33.5", - "@img/sharp-wasm32": "0.33.5", - "@img/sharp-win32-ia32": "0.33.5", - "@img/sharp-win32-x64": "0.33.5" + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" } }, "node_modules/shebang-command": { @@ -3408,6 +4132,16 @@ "is-arrayish": "^0.3.1" } }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/spdx-exceptions": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", @@ -3433,15 +4167,6 @@ "dev": true, "license": "CC0-1.0" }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", @@ -3560,16 +4285,16 @@ } }, "node_modules/strtok3": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz", - "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-9.1.1.tgz", + "integrity": "sha512-FhwotcEqjr241ZbjFzjlIYg6c5/L/s4yBGWSMvJ9UoExiSqL+FnFA/CaeZx17WGaZMS/4SOZp8wH18jSS4R4lw==", "license": "MIT", "dependencies": { "@tokenizer/token": "^0.3.0", - "peek-readable": "^4.1.0" + "peek-readable": "^5.3.1" }, "engines": { - "node": ">=10" + "node": ">=16" }, "funding": { "type": "github", @@ -3615,17 +4340,31 @@ "node": ">=14.14" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/token-types": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz", - "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-6.1.2.tgz", + "integrity": "sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww==", "license": "MIT", "dependencies": { + "@borewit/text-codec": "^0.2.1", "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" }, "engines": { - "node": ">=10" + "node": ">=14.16" }, "funding": { "type": "github", @@ -3645,58 +4384,90 @@ "typescript": ">=4.8.4" } }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "node_modules/tsc-alias": { + "version": "1.8.16", + "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.16.tgz", + "integrity": "sha512-QjCyu55NFyRSBAl6+MTFwplpFcnm2Pq01rR/uxfqJoLMm6X3O14KEGtaSDZpJYaE1bJBGDjD0eSuiIWPe2T58g==", "dev": true, "license": "MIT", "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" + "chokidar": "^3.5.3", + "commander": "^9.0.0", + "get-tsconfig": "^4.10.0", + "globby": "^11.0.4", + "mylas": "^2.1.9", + "normalize-path": "^3.0.0", + "plimit-lit": "^1.2.6" }, "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" + "tsc-alias": "dist/bin/index.js" }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" + "engines": { + "node": ">=16.20.2" + } + }, + "node_modules/tsc-alias/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" } }, - "node_modules/ts-node/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "node_modules/tsc-alias/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, - "license": "BSD-3-Clause", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, "engines": { - "node": ">=0.3.1" + "node": ">= 6" + } + }, + "node_modules/tsc-alias/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/tsc-alias/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" } }, "node_modules/tslib": { @@ -3705,6 +4476,26 @@ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/tsx": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", + "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.27.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -3718,16 +4509,6 @@ "node": ">= 0.8.0" } }, - "node_modules/type-detect": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", - "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/typedoc": { "version": "0.28.16", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.28.16.tgz", @@ -3773,6 +4554,27 @@ "dev": true, "license": "MIT" }, + "node_modules/uint8array-extras": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/uint8array-extras/-/uint8array-extras-1.5.0.tgz", + "integrity": "sha512-rvKSBiC5zqCCiDZ9kAOszZcDvdAHwwIKJG33Ykj43OKcWsnmcBRL09YTU4nOeHZ8Y2a7l1MgTd08SBe9A8Qj6A==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/undici": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz", + "integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -3790,13 +4592,6 @@ "punycode": "^2.1.0" } }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, "node_modules/web-streams-polyfill": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz", @@ -4050,16 +4845,6 @@ "node": ">=8" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 800da86f..e182aa9a 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,14 @@ "main": "src/index.js", "bin": "bin/mindee.js", "license": "MIT", + "type": "module", "scripts": { - "build": "tsc --build", - "build-for-dist": "tsc --build && cp LICENSE README.md CHANGELOG.md ./dist", + "build": "tsc --build && tsc-alias", + "build-for-dist": "tsc --build && tsc-alias && cp LICENSE README.md CHANGELOG.md ./dist", "clean": "rm -rf ./dist ./docs/_build", - "test": "mocha \"tests/**/*.spec.ts\" --config .mocharc.json", + "test": "mocha \"tests/**/*.spec.ts\"", "test-integration": "mocha \"tests/**/*.integration.ts\"", - "lint": "eslint './src/**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'", + "lint": "tsc --noEmit && eslint './src/**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'", "lint-fix": "eslint './src/**/*.ts' --fix", "docs": "typedoc --out docs/_build ./src/index.ts", "docs-for-dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/" @@ -24,7 +25,7 @@ "CHANGELOG.md" ], "engines": { - "node": ">= 18" + "node": ">= 18.17" }, "repository": { "type": "git", @@ -46,25 +47,26 @@ "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^8.52.0", "@typescript-eslint/parser": "^8.52.0", - "chai": "^4.5.0", - "eslint": "^9.20.1", + "chai": "^6.2.2", + "eslint": "^9.39.2", "eslint-plugin-jsdoc": "^50.6.17", "mocha": "^11.7.5", - "nock": "^13.5.6", - "ts-node": "^10.9.2", + "tsc-alias": "^1.8.16", + "tsx": "^4.21.0", "typedoc": "~0.28.15", "typescript": "^5.9.3" }, "dependencies": { "@cantoo/pdf-lib": "^2.3.2", "commander": "~9.4.1", - "file-type": "~16.5.4", - "form-data": "~3.0.1", - "node-poppler": "^7.2.2", + "file-type": "^19.6.0", + "form-data": "^3.0.4", + "node-poppler": "^7.2.4", "pdf.js-extract": "^0.2.1", - "sharp": "^0.33.5", + "sharp": "~0.34.5", "tmp": "^0.2.3", - "tslib": "^2.8.1" + "tslib": "^2.8.1", + "undici": "^6.23.0" }, "keywords": [ "typescript", @@ -72,6 +74,7 @@ "api", "client", "client library", - "nodejs" + "nodejs", + "sdk" ] } diff --git a/src/cliProducts.ts b/src/cliProducts.ts index 0dcb9400..81e286f7 100644 --- a/src/cliProducts.ts +++ b/src/cliProducts.ts @@ -4,10 +4,9 @@ // The Map's key is the command name as it will appear on the console. // -import * as product from "./product"; -import { Inference, StringDict } from "./parsing/common"; +import * as product from "@/product/index.js"; +import { Inference, StringDict } from "@/parsing/common/index.js"; -export const COMMAND_CUSTOM = "custom"; export const COMMAND_GENERATED = "generated"; export interface ProductConfig { @@ -19,16 +18,6 @@ export interface ProductConfig { } export const CLI_COMMAND_CONFIG = new Map([ - [ - COMMAND_CUSTOM, - { - displayName: "Custom Document", - docClass: product.CustomV1, - allWords: false, - async: false, - sync: true, - }, - ], [ COMMAND_GENERATED, { @@ -49,26 +38,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "bill-of-lading", - { - displayName: "Bill of Lading", - docClass: product.BillOfLadingV1, - allWords: false, - async: true, - sync: false, - }, - ], - [ - "business-card", - { - displayName: "Business Card", - docClass: product.BusinessCardV1, - allWords: false, - async: true, - sync: false, - }, - ], [ "cropper", { @@ -79,16 +48,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "delivery-note", - { - displayName: "Delivery note", - docClass: product.DeliveryNoteV1, - allWords: false, - async: true, - sync: false, - }, - ], [ "driver-license", { @@ -119,16 +78,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "fr-carte-grise", - { - displayName: "FR Carte Grise", - docClass: product.fr.CarteGriseV1, - allWords: false, - async: false, - sync: true, - }, - ], [ "fr-energy-bill", { @@ -219,16 +168,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "nutrition-facts-label", - { - displayName: "Nutrition Facts Label", - docClass: product.NutritionFactsLabelV1, - allWords: false, - async: true, - sync: false, - }, - ], [ "passport", { @@ -269,16 +208,6 @@ export const CLI_COMMAND_CONFIG = new Map([ sync: true, }, ], - [ - "us-healthcare-card", - { - displayName: "US Healthcare Card", - docClass: product.us.HealthcareCardV1, - allWords: false, - async: true, - sync: false, - }, - ], [ "us-us-mail", { diff --git a/src/cli.ts b/src/cliV1.ts similarity index 74% rename from src/cli.ts rename to src/cliV1.ts index 703a9cfd..d14043fe 100644 --- a/src/cli.ts +++ b/src/cliV1.ts @@ -1,14 +1,18 @@ import { Command, OptionValues, Option } from "commander"; -import { AsyncPredictResponse, Document, Inference, StringDict } from "./parsing/common"; -import { Client, PredictOptions } from "./client"; -import { PageOptions, PageOptionsOperation, PathInput } from "./input"; +import { + Document, Inference, StringDict +} from "@/parsing/common/index.js"; +import { Client, PredictOptions } from "./client.js"; +import { PageOptions, PageOptionsOperation, PathInput } from "./input/index.js"; import * as console from "console"; -import { CLI_COMMAND_CONFIG, COMMAND_CUSTOM, COMMAND_GENERATED, ProductConfig } from "./cliProducts"; +import { + CLI_COMMAND_CONFIG, COMMAND_GENERATED, ProductConfig +} from "./cliProducts.js"; +import { Endpoint } from "./http/index.js"; const program = new Command(); - // // EXECUTE THE COMMANDS // @@ -58,7 +62,7 @@ async function callParse( const pageOptions = getPageOptions(options); const inputSource = new PathInput({ inputPath: inputPath }); let response; - if (command === COMMAND_CUSTOM || command === COMMAND_GENERATED) { + if (command === COMMAND_GENERATED) { const customEndpoint = mindeeClient.createEndpoint( options.endpoint, options.account, @@ -90,36 +94,27 @@ async function callEnqueueAndParse( const predictParams = getPredictParams(options); const pageOptions = getPageOptions(options); const inputSource = new PathInput({ inputPath: inputPath }); - let response: AsyncPredictResponse; - if (command === COMMAND_CUSTOM || command === COMMAND_GENERATED) { - const customEndpoint = mindeeClient.createEndpoint( + let customEndpoint: Endpoint | undefined = undefined; + if (command === COMMAND_GENERATED) { + customEndpoint = mindeeClient.createEndpoint( options.endpoint, options.account, options.version ); - response = await mindeeClient.enqueueAndParse(productClass, inputSource, { - endpoint: customEndpoint, - pageOptions: pageOptions, - allWords: predictParams.allWords, - cropper: predictParams.cropper, - initialDelaySec: 2, - delaySec: 1.5, - maxRetries: 80, - }); - } else { - response = await mindeeClient.enqueueAndParse(productClass, inputSource, { - pageOptions: pageOptions, - allWords: predictParams.allWords, - cropper: predictParams.cropper, - initialDelaySec: 2, - delaySec: 1.5, - maxRetries: 80, - }); - if (!response.document) { - throw Error("Document could not be retrieved"); - } - printResponse(response.document, options); } + const response = await mindeeClient.enqueueAndParse(productClass, inputSource, { + endpoint: customEndpoint, + pageOptions: pageOptions, + allWords: predictParams.allWords, + cropper: predictParams.cropper, + initialDelaySec: 2, + delaySec: 1.5, + maxRetries: 80, + }); + if (!response.document) { + throw Error("Document could not be retrieved"); + } + printResponse(response.document, options); } async function callGetDocument( @@ -131,24 +126,6 @@ async function callGetDocument( printResponse(response.document, options); } -async function callSendFeedback( - productClass: new (httpResponse: StringDict) => T, - documentId: string, - feedbackStr: string, - options: any -): Promise { - const mindeeClient = initClient(options); - const feedback = { - feedback: JSON.parse(feedbackStr), - }; - const response = await mindeeClient.sendFeedback( - productClass, - documentId, - feedback - ); - console.log(response.feedback); -} - function printResponse( document: Document, options: any @@ -219,7 +196,7 @@ function routeSwitchboard( } function addPredictAction(prog: Command) { - if (prog.name() === COMMAND_CUSTOM || prog.name() === COMMAND_GENERATED) { + if (prog.name() === COMMAND_GENERATED) { prog.action(function ( inputPath: string, options: OptionValues, @@ -250,7 +227,7 @@ function addPredictAction(prog: Command) { } } -export function cli() { +export function cliV1() { program.name("mindee") .description("Command line interface for Mindee products.") .option("-d, --debug", "high verbosity mode"); @@ -274,21 +251,6 @@ export function cli() { addMainOptions(getDocProductCmd); } - const feedbackProductCmd: Command = productCmd.command("feedback") - .description("Send feedback for a document.") - .argument("", "Unique ID of the document.") - .argument("", "Feedback to send, ex '{\"key\": \"value\"}'.") - .action(async (documentId, feedback, options) => { - const docClass = getConfig(name).docClass; - await callSendFeedback( - docClass, - documentId, - feedback, - { ...options, ...productCmd.opts(), ...program.opts() } - ); - }); - addMainOptions(feedbackProductCmd); - const predictProductCmd: Command = productCmd.command("parse") .description("Send a file for parsing."); @@ -303,7 +265,7 @@ export function cli() { predictProductCmd.addOption(asyncOpt); } - if (name === COMMAND_CUSTOM || name === COMMAND_GENERATED) { + if (name === COMMAND_GENERATED) { addCustomPostOptions(predictProductCmd); } addMainOptions(predictProductCmd); diff --git a/src/cliV2.ts b/src/cliV2.ts new file mode 100644 index 00000000..22407ef4 --- /dev/null +++ b/src/cliV2.ts @@ -0,0 +1,80 @@ +import { Command, OptionValues } from "commander"; +import { ClientV2 } from "./clientV2.js"; +import { PathInput } from "./input/index.js"; +import * as console from "console"; +import { Inference } from "@/parsing/v2/index.js"; + +const program = new Command(); + + +// +// EXECUTE THE COMMANDS +// + +function initClient(options: OptionValues): ClientV2 { + return new ClientV2({ + apiKey: options.apiKey, + debug: options.debug, + }); +} + +async function callEnqueueAndGetInference( + inputPath: string, + options: any +): Promise { + const mindeeClient = initClient(options); + const inputSource = new PathInput({ inputPath: inputPath }); + const response = await mindeeClient.enqueueAndGetInference(inputSource, { + modelId: options.model, + pollingOptions: { + initialDelaySec: 2, + delaySec: 1.5, + maxRetries: 80, + } + }); + if (!response.inference) { + throw Error("Inference could not be retrieved"); + } + printResponse(response.inference); +} + +function printResponse( + document: Inference, +): void { + if (document) { + console.log(`\n${document}`); + } +} + +// +// BUILD THE COMMANDS +// + +function addMainOptions(prog: Command) { + prog.requiredOption( + "-m, --model ", + "Model ID (required)" + ); + prog.option("-k, --api-key ", "API key for document endpoint"); + prog.argument("", "full path to the file"); +} + +export function cliV2() { + program.name("mindee") + .description("Command line interface for Mindee products.") + .option("-d, --debug", "high verbosity mode"); + + const inferenceCmd: Command = program.command("parse") + .description("Send a file and retrieve the inference results."); + + addMainOptions(inferenceCmd); + + inferenceCmd.action(function ( + inputPath: string, + options: OptionValues, + ) { + return callEnqueueAndGetInference(inputPath, options); + }); + + program.parse(process.argv); +} diff --git a/src/client.ts b/src/client.ts index 43599648..7de5de84 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,28 +1,28 @@ +import { Dispatcher } from "undici"; import { InputSource, LocalResponse, PageOptions, -} from "./input"; -import { ApiSettings, Endpoint, EndpointResponse, STANDARD_API_OWNER } from "./http"; +} from "./input/index.js"; +import { + ApiSettings, Endpoint, EndpointResponse, STANDARD_API_OWNER +} from "./http/index.js"; import { AsyncPredictResponse, ExecutionPriority, FeedbackResponse, Inference, PredictResponse, - StringDict -} from "./parsing/common"; -import { errorHandler } from "./errors/handler"; -import { LOG_LEVELS, logger } from "./logger"; -import { InferenceFactory } from "./parsing/common/inference"; -import { CustomV1, GeneratedV1 } from "./product"; - + StringDict, + WorkflowResponse, +} from "./parsing/common/index.js"; +import { errorHandler } from "./errors/handler.js"; +import { LOG_LEVELS, logger } from "./logger.js"; +import { InferenceFactory } from "./parsing/common/inference.js"; +import { GeneratedV1 } from "./product/index.js"; import { setTimeout } from "node:timers/promises"; -import { MindeeError } from "./errors"; -import { WorkflowResponse } from "./parsing/common/workflowResponse"; -import { WorkflowEndpoint } from "./http/workflowEndpoint"; -import { Base64Input, BufferInput, BytesInput, PathInput, StreamInput, UrlInput } from "./input"; -import { Readable } from "stream"; +import { MindeeError } from "./errors/index.js"; +import { WorkflowEndpoint } from "./http/workflowEndpoint.js"; /** * Common options for workflows & predictions. @@ -37,7 +37,6 @@ interface BaseOptions { * This is done before sending the file to the server and is useful to avoid page limitations. */ pageOptions?: PageOptions; - /** * If set, will enable Retrieval-Augmented Generation (only works if a valid workflowId is set). */ @@ -123,6 +122,8 @@ export interface ClientOptions { throwOnError?: boolean; /** Log debug messages. */ debug?: boolean; + /** Custom dispatcher for HTTP requests. */ + dispatcher?: Dispatcher; } /** @@ -131,26 +132,29 @@ export interface ClientOptions { * @category Client */ export class Client { - /** Key of the API. */ - protected apiKey: string; + /** Mindee V1 API settings. */ + protected apiSettings: ApiSettings; /** * @param {ClientOptions} options options for the initialization of a client. */ constructor( - { apiKey, throwOnError, debug }: ClientOptions = { - apiKey: "", + { apiKey, throwOnError, debug, dispatcher }: ClientOptions = { + apiKey: undefined, throwOnError: true, debug: false, + dispatcher: undefined, } ) { - this.apiKey = apiKey ? apiKey : ""; + this.apiSettings = new ApiSettings({ + apiKey: apiKey, + dispatcher: dispatcher, + }); errorHandler.throwOnError = throwOnError ?? true; - logger.level = - debug ?? process.env.MINDEE_DEBUG + logger.level = debug ?? process.env.MINDEE_DEBUG ? LOG_LEVELS["debug"] : LOG_LEVELS["warn"]; - logger.debug("Client initialized"); + logger.debug("Client V1 Initialized"); } /** @@ -174,8 +178,7 @@ export class Client { pageOptions: undefined, } ): Promise> { - const endpoint: Endpoint = - params?.endpoint ?? this.#initializeOTSEndpoint(productClass); + const endpoint: Endpoint = params?.endpoint ?? this.#initializeOTSEndpoint(productClass); if (inputSource === undefined) { throw new Error("The 'parse' function requires an input document."); } @@ -265,7 +268,6 @@ export class Client { } } - /** * Send the document to an asynchronous endpoint and return its ID in the queue. * @param inputSource file to send to the API. @@ -279,7 +281,7 @@ export class Client { workflowId: string, params: WorkflowOptions = {} ): Promise> { - const workflowEndpoint = new WorkflowEndpoint(this.#buildApiSettings(), workflowId); + const workflowEndpoint = new WorkflowEndpoint(this.apiSettings, workflowId); if (inputSource === undefined) { throw new Error("The 'executeWorkflow' function requires an input document."); } @@ -459,20 +461,10 @@ Job status: ${pollResults.job.status}.` endpointName, accountName, endpointVersion, - this.#buildApiSettings() + this.apiSettings ); } - /** - * Builds a document endpoint. - * @returns a custom `Endpoint` object. - */ - #buildApiSettings(): ApiSettings { - return new ApiSettings({ - apiKey: this.apiKey, - }); - } - /** * Creates a custom endpoint with the given values. Raises an error if the endpoint is invalid. * @param endpointName Name of the custom Endpoint. @@ -487,17 +479,13 @@ Job status: ${pollResults.job.status}.` accountName: string, endpointVersion?: string ): Endpoint { - const cleanAccountName: string = this.#cleanAccountName( - CustomV1, - accountName - ); if (!endpointName || endpointName.length === 0) { throw new Error("Missing parameter 'endpointName' for custom build!"); } let cleanEndpointVersion: string; if (!endpointVersion || endpointVersion.length === 0) { logger.debug( - "Warning: No version provided for a custom build, will attempt to poll version 1 by default." + "No version provided for a custom build, will poll using version 1 by default." ); cleanEndpointVersion = "1"; } else { @@ -505,7 +493,7 @@ Job status: ${pollResults.job.status}.` } return this.#buildProductEndpoint( endpointName, - cleanAccountName, + accountName, cleanEndpointVersion ); } @@ -516,9 +504,6 @@ Job status: ${pollResults.job.status}.` #initializeOTSEndpoint( productClass: new (httpResponse: StringDict) => T ): Endpoint { - if (productClass.name === "CustomV1") { - throw new Error("Incorrect parameters for Custom build."); - } const [endpointName, endpointVersion] = this.#getOtsEndpoint(productClass); return this.#buildProductEndpoint( endpointName, @@ -527,33 +512,9 @@ Job status: ${pollResults.job.status}.` ); } - /** - * Checks that an account name is provided for custom builds, and sets the default one otherwise. - * @param productClass product class to use for calling the API and parsing the response. - * @param accountName name of the account's holder. Only required on custom builds. - * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. - * - * @returns the name of the account. Sends an error if one isn't provided for a custom build. - */ - #cleanAccountName( - productClass: new (httpResponse: StringDict) => T, - accountName?: string - ): string { - if (productClass.name === "CustomV1") { - if (!accountName || accountName.length === 0) { - logger.debug( - `Warning: no account name provided for custom build, ${STANDARD_API_OWNER} will be used by default` - ); - return STANDARD_API_OWNER; - } - return accountName; - } - return STANDARD_API_OWNER; - } - /** * Get the name and version of an OTS endpoint. - * @param productClass product class to use for calling the API and parsing the response. + * @param productClass product class to use for calling the API and parsing the response. * Mandatory to retrieve default OTS endpoint data. * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. * @@ -566,78 +527,4 @@ Job status: ${pollResults.job.status}.` InferenceFactory.getEndpoint(productClass); return [endpointName, endpointVersion]; } - - /** - * Load an input document from a local path. - * @param inputPath - * @deprecated Use `new mindee.PathInput()` instead. - */ - docFromPath(inputPath: string): PathInput { - return new PathInput({ - inputPath: inputPath, - }); - } - - /** - * Load an input document from a base64 encoded string. - * @param inputString input content, as a string. - * @param filename file name. - * @deprecated Use `new mindee.Base64Input()` instead. - */ - docFromBase64(inputString: string, filename: string): Base64Input { - return new Base64Input({ - inputString: inputString, - filename: filename, - }); - } - - /** - * Load an input document from a `stream.Readable` object. - * @param inputStream input content, as a readable stream. - * @param filename file name. - * @deprecated Use `new mindee.StreamInput()` instead. - */ - docFromStream(inputStream: Readable, filename: string): StreamInput { - return new StreamInput({ - inputStream: inputStream, - filename: filename, - }); - } - - /** - * Load an input document from bytes. - * @param inputBytes input content, as a Uint8Array or Buffer. - * @param filename file name. - * @deprecated Use `new mindee.BytesInput()` instead. - */ - docFromBytes(inputBytes: Uint8Array, filename: string): BytesInput { - return new BytesInput({ - inputBytes: inputBytes, - filename: filename, - }); - } - - /** - * Load an input document from a URL. - * @param url input url. Must be HTTPS. - * @deprecated Use `new mindee.UrlInput()` instead. - */ - docFromUrl(url: string): UrlInput { - return new UrlInput({ - url: url, - }); - } - - /** - * Load an input document from a Buffer. - * @param buffer input content, as a buffer. - * @param filename file name. - * @deprecated Use `new mindee.BufferInput()` instead. - */ - docFromBuffer(buffer: Buffer, filename: string): BufferInput { - return new BufferInput({ - buffer: buffer, - filename: filename, - }); - } } diff --git a/src/clientV2.ts b/src/clientV2.ts index 9255b219..5dd1064c 100644 --- a/src/clientV2.ts +++ b/src/clientV2.ts @@ -1,12 +1,12 @@ -import { DataSchema, InputSource } from "./input"; -import { errorHandler } from "./errors/handler"; -import { LOG_LEVELS, logger } from "./logger"; - +import { Dispatcher } from "undici"; +import { DataSchema, InputSource } from "./input/index.js"; +import { errorHandler } from "./errors/handler.js"; +import { LOG_LEVELS, logger } from "./logger.js"; import { setTimeout } from "node:timers/promises"; -import { ErrorResponse, InferenceResponse, JobResponse } from "./parsing/v2"; -import { MindeeApiV2 } from "./http/mindeeApiV2"; -import { MindeeHttpErrorV2 } from "./errors/mindeeError"; -import { StringDict } from "./parsing/common"; +import { ErrorResponse, InferenceResponse, JobResponse } from "@/parsing/v2/index.js"; +import { MindeeApiV2 } from "./http/mindeeApiV2.js"; +import { MindeeHttpErrorV2 } from "@/errors/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Parameters for the internal polling loop in {@link ClientV2.enqueueAndGetInference | enqueueAndGetInference()} . @@ -128,6 +128,7 @@ export interface ClientOptions { throwOnError?: boolean; /** Log debug messages. */ debug?: boolean; + dispatcher?: Dispatcher; } /** @@ -136,26 +137,27 @@ export interface ClientOptions { * @category ClientV2 */ export class ClientV2 { - /** Mindee API handler. */ + /** Mindee V2 API handler. */ protected mindeeApi: MindeeApiV2; /** * @param {ClientOptions} options options for the initialization of a client. */ constructor( - { apiKey, throwOnError, debug }: ClientOptions = { - apiKey: "", + { apiKey, throwOnError, debug, dispatcher }: ClientOptions = { + apiKey: undefined, throwOnError: true, debug: false, + dispatcher: undefined, } ) { - this.mindeeApi = new MindeeApiV2(apiKey); + this.mindeeApi = new MindeeApiV2(dispatcher, apiKey); errorHandler.throwOnError = throwOnError ?? true; logger.level = debug ?? process.env.MINDEE_DEBUG ? LOG_LEVELS["debug"] : LOG_LEVELS["warn"]; - logger.debug("ClientV2 initialized"); + logger.debug("Client V2 Initialized"); } /** diff --git a/src/errors/handler.ts b/src/errors/handler.ts index 1f37deac..3141adde 100644 --- a/src/errors/handler.ts +++ b/src/errors/handler.ts @@ -1,4 +1,4 @@ -import { logger } from "../logger"; +import { logger } from "@/logger.js"; /** * Custom Error handling class. diff --git a/src/errors/index.ts b/src/errors/index.ts index 7cc7eeb3..e773bbb8 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -1 +1,5 @@ -export { MindeeError, MindeeMimeTypeError } from "./mindeeError"; +export { + MindeeError, + MindeeMimeTypeError, MindeeImageError, MindeePdfError, + MindeeHttpErrorV2, MindeeApiV2Error, +} from "./mindeeError.js"; diff --git a/src/errors/mindeeError.ts b/src/errors/mindeeError.ts index 53c90ff6..462f5c8f 100644 --- a/src/errors/mindeeError.ts +++ b/src/errors/mindeeError.ts @@ -1,4 +1,4 @@ -import { ErrorDetails, ErrorResponse, ErrorItem } from "../parsing/v2"; +import { ErrorDetails, ErrorResponse, ErrorItem } from "@/parsing/v2/index.js"; /** * Main Mindee Error custom class. diff --git a/src/geometry/boundingBox.ts b/src/geometry/boundingBox.ts index 717716dd..759fe685 100644 --- a/src/geometry/boundingBox.ts +++ b/src/geometry/boundingBox.ts @@ -1,5 +1,5 @@ -import { Point } from "./point"; -import { Polygon } from "./polygon"; +import { Point } from "./point.js"; +import { Polygon } from "./polygon.js"; /** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */ export class BBox { diff --git a/src/geometry/boundingBoxUtils.ts b/src/geometry/boundingBoxUtils.ts index 4e8e8976..81d16522 100644 --- a/src/geometry/boundingBoxUtils.ts +++ b/src/geometry/boundingBoxUtils.ts @@ -1,5 +1,5 @@ -import { BoundingBox, BBox } from "./boundingBox"; -import { Polygon } from "./polygon"; +import { BoundingBox, BBox } from "./boundingBox.js"; +import { Polygon } from "./polygon.js"; /** * Given a Polygon, calculate a polygon that encompasses all points. diff --git a/src/geometry/index.ts b/src/geometry/index.ts index a9d8af2b..fb299af8 100644 --- a/src/geometry/index.ts +++ b/src/geometry/index.ts @@ -1,4 +1,4 @@ -export { Polygon } from "./polygon"; +export { Polygon } from "./polygon.js"; export { compareOnX, compareOnY, @@ -9,14 +9,14 @@ export { relativeY, getMinMaxX, getMinMaxY, -} from "./polygonUtils"; -export { BoundingBox, BBox } from "./boundingBox"; +} from "./polygonUtils.js"; +export { BoundingBox, BBox } from "./boundingBox.js"; export { getBbox, getBBoxForPolygons, getBoundingBox, getBoundingBoxFromBBox, mergeBbox, -} from "./boundingBoxUtils"; -export { MinMax } from "./minMax"; -export { Point } from "./point"; +} from "./boundingBoxUtils.js"; +export type { MinMax } from "./minMax.js"; +export type { Point } from "./point.js"; diff --git a/src/geometry/polygon.ts b/src/geometry/polygon.ts index f79c6594..002757f1 100644 --- a/src/geometry/polygon.ts +++ b/src/geometry/polygon.ts @@ -1,6 +1,6 @@ -import { Point } from "./point"; -import { getCentroid, getMinMaxX, getMinMaxY, isPointInX, isPointInY } from "./polygonUtils"; -import { MinMax } from "./minMax"; +import { Point } from "./point.js"; +import { getCentroid, getMinMaxX, getMinMaxY, isPointInX, isPointInY } from "./polygonUtils.js"; +import { MinMax } from "./minMax.js"; /** A polygon, composed of several Points. */ export class Polygon extends Array { diff --git a/src/geometry/polygonUtils.ts b/src/geometry/polygonUtils.ts index e1a3c38f..062df151 100644 --- a/src/geometry/polygonUtils.ts +++ b/src/geometry/polygonUtils.ts @@ -1,5 +1,5 @@ -import { MinMax } from "./minMax"; -import { Point } from "./point"; +import { MinMax } from "./minMax.js"; +import { Point } from "./point.js"; /** * Get the central point (centroid) given a list of points. diff --git a/src/http/apiCore.ts b/src/http/apiCore.ts new file mode 100644 index 00000000..b74a408e --- /dev/null +++ b/src/http/apiCore.ts @@ -0,0 +1,77 @@ +import { logger } from "@/logger.js"; +import { request, Dispatcher } from "undici"; +import { InputSource, PageOptions, LocalInputSource } from "@/input/index.js"; + +export const TIMEOUT_DEFAULT: number = 120; + +export interface RequestOptions { + hostname: string; + path: string; + method: any; + timeout: number; + headers: any; + body?: any; +} + +export interface EndpointResponse { + messageObj: any; + data: { [key: string]: any }; +} + +/** + * Cuts a document's pages according to the given options. + * @param inputDoc input document. + * @param pageOptions page cutting options. + */ +export async function cutDocPages(inputDoc: InputSource, pageOptions: PageOptions) { + if (inputDoc instanceof LocalInputSource && inputDoc.isPdf()) { + await inputDoc.applyPageOptions(pageOptions); + } +} + +/** + * Reads a response from the API and processes it. + * @param dispatcher custom dispatcher to use for the request. + * @param options options related to the request itself. + * @returns the processed request. + */ +export async function sendRequestAndReadResponse( + dispatcher: Dispatcher, + options: RequestOptions, +): Promise { + const url: string = `https://${options.hostname}${options.path}`; + logger.debug(`${options.method}: ${url}`); + + const response = await request( + url, + { + method: options.method, + headers: options.headers, + bodyTimeout: options.timeout, + body: options.body, + throwOnError: false, + dispatcher: dispatcher + } + ); + logger.debug("Parsing the response ..."); + + let responseBody: string = await response.body.text(); + // handle empty responses from server, for example, in the case of redirects + if (!responseBody) { + responseBody = "{}"; + } + try { + const parsedResponse = JSON.parse(responseBody); + logger.debug("JSON parsed successfully, returning object."); + return { + messageObj: response, + data: parsedResponse, + }; + } catch { + logger.error("Could not parse the return as JSON."); + return { + messageObj: response, + data: { reconstructedResponse: responseBody }, + }; + } +} diff --git a/src/http/apiSettings.ts b/src/http/apiSettings.ts index ecd9c506..361287e2 100644 --- a/src/http/apiSettings.ts +++ b/src/http/apiSettings.ts @@ -1,30 +1,24 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { logger } from "../logger"; -import { BaseSettings, MindeeApiConstructorProps } from "./baseSettings"; +import { logger } from "@/logger.js"; +import { BaseSettings, MindeeApiConstructorProps } from "./baseSettings.js"; -export const API_KEY_ENVVAR_NAME: string = "MINDEE_API_KEY"; -export const API_HOST_ENVVAR_NAME: string = "MINDEE_API_HOST"; export const STANDARD_API_OWNER: string = "mindee"; -export const TIMEOUT_DEFAULT: number = 120; +const API_V1_KEY_ENVVAR_NAME: string = "MINDEE_API_KEY"; +const API_V1_HOST_ENVVAR_NAME: string = "MINDEE_API_HOST"; const DEFAULT_MINDEE_API_HOST: string = "api.mindee.net"; export class ApiSettings extends BaseSettings { - apiKey: string; baseHeaders: Record; constructor({ - apiKey = "", + apiKey, + dispatcher, }: MindeeApiConstructorProps) { - super(); - if (!apiKey || apiKey.length === 0) { - this.apiKey = this.apiKeyFromEnv(); - } else { - this.apiKey = apiKey; - } + super(apiKey, dispatcher); if (!this.apiKey || this.apiKey.length === 0) { throw new Error( - "Your API key could not be set, check your Client Configuration\n." - + `You can set this using the ${API_KEY_ENVVAR_NAME} environment variable.` + "Your V1 API key could not be set, check your Client Configuration\n." + + `You can set this using the ${API_V1_KEY_ENVVAR_NAME} environment variable.` ); } this.baseHeaders = { @@ -33,12 +27,11 @@ export class ApiSettings extends BaseSettings { }; } - protected apiKeyFromEnv(): string { - const envVarValue = process.env[API_KEY_ENVVAR_NAME]; + const envVarValue = process.env[API_V1_KEY_ENVVAR_NAME]; if (envVarValue) { logger.debug( - `Set API key from environment: ${API_KEY_ENVVAR_NAME}` + "Set the V1 API key from the environment" ); return envVarValue; } @@ -46,9 +39,9 @@ export class ApiSettings extends BaseSettings { } protected hostnameFromEnv(): string { - const envVarValue = process.env[API_HOST_ENVVAR_NAME]; + const envVarValue = process.env[API_V1_HOST_ENVVAR_NAME]; if (envVarValue) { - logger.debug(`Set the API hostname to ${envVarValue}`); + logger.debug(`Set the V1 API hostname from the environment to: ${envVarValue}`); return envVarValue; } return DEFAULT_MINDEE_API_HOST; diff --git a/src/http/apiSettingsV2.ts b/src/http/apiSettingsV2.ts index 49cf7d4c..a31c3c50 100644 --- a/src/http/apiSettingsV2.ts +++ b/src/http/apiSettingsV2.ts @@ -1,43 +1,37 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { logger } from "../logger"; -import { BaseSettings, MindeeApiConstructorProps } from "./baseSettings"; -import { MindeeApiV2Error } from "../errors/mindeeError"; +import { logger } from "@/logger.js"; +import { BaseSettings, MindeeApiConstructorProps } from "./baseSettings.js"; +import { MindeeApiV2Error } from "@/errors/index.js"; -export const API_V2_KEY_ENVVAR_NAME: string = "MINDEE_V2_API_KEY"; -export const API_V2_HOST_ENVVAR_NAME: string = "MINDEE_V2_API_HOST"; +const API_V2_KEY_ENVVAR_NAME: string = "MINDEE_V2_API_KEY"; +const API_V2_HOST_ENVVAR_NAME: string = "MINDEE_V2_API_HOST"; const DEFAULT_MINDEE_API_HOST: string = "api-v2.mindee.net"; export class ApiSettingsV2 extends BaseSettings { - apiKey: string; baseHeaders: Record; constructor({ - apiKey = "", + apiKey, + dispatcher, }: MindeeApiConstructorProps) { - super(); - if (!apiKey || apiKey.length === 0) { - this.apiKey = this.apiKeyFromEnv(); - } else { - this.apiKey = apiKey; - } + super(apiKey, dispatcher); if (!this.apiKey || this.apiKey.length === 0) { throw new MindeeApiV2Error( - "Your API V2 key could not be set, check your Client Configuration\n." + "Your V2 API key could not be set, check your Client Configuration\n." + `You can set this using the ${API_V2_KEY_ENVVAR_NAME} environment variable.` ); } this.baseHeaders = { "User-Agent": this.getUserAgent(), - Authorization: `${apiKey}`, + Authorization: `${this.apiKey}`, }; } - protected apiKeyFromEnv(): string { const envVarValue = process.env[API_V2_KEY_ENVVAR_NAME]; if (envVarValue) { logger.debug( - `Set API key from environment: ${API_V2_KEY_ENVVAR_NAME}` + "Set the V2 API key from the environment" ); return envVarValue; } @@ -47,11 +41,10 @@ export class ApiSettingsV2 extends BaseSettings { protected hostnameFromEnv(): string { const envVarValue = process.env[API_V2_HOST_ENVVAR_NAME]; if (envVarValue) { - logger.debug(`Set the API hostname to ${envVarValue}`); + logger.debug(`Set the V2 API hostname from the environment to: ${envVarValue}`); return envVarValue; } return DEFAULT_MINDEE_API_HOST; } - } diff --git a/src/http/baseEndpoint.ts b/src/http/baseEndpoint.ts deleted file mode 100644 index 37b99ed1..00000000 --- a/src/http/baseEndpoint.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { ApiSettings } from "./apiSettings"; -import { logger } from "../logger"; -import { IncomingMessage, ClientRequest } from "http"; -import { request, RequestOptions } from "https"; -import { InputSource, PageOptions } from "../input"; -import { LocalInputSource } from "../input"; - - -export interface EndpointResponse { - messageObj: IncomingMessage; - data: { [key: string]: any }; -} - -/** - * Base endpoint for the Mindee API. - */ -export abstract class BaseEndpoint { - /** Settings relating to the API. */ - settings: ApiSettings; - - /** Entire root of the URL for API calls. */ - urlRoot: string; - - protected constructor( - settings: ApiSettings, - urlRoot: string - ) { - this.settings = settings; - this.urlRoot = urlRoot; - } - - /** - * Cuts a document's pages according to the given options. - * @param inputDoc input document. - * @param pageOptions page cutting options. - */ - public static async cutDocPages(inputDoc: InputSource, pageOptions: PageOptions) { - if (inputDoc instanceof LocalInputSource && inputDoc.isPdf()) { - await inputDoc.applyPageOptions(pageOptions); - } - } - - /** - * Reads a response from the API and processes it. - * @param options options related to the request itself. - * @param resolve the resolved response - * @param reject promise rejection reason. - * @returns the processed request. - */ - public static readResponse( - options: RequestOptions, - resolve: (value: EndpointResponse | PromiseLike) => void, - reject: (reason?: any) => void - ): ClientRequest { - logger.debug( - `${options.method}: https://${options.hostname}${options.path}` - ); - - const req = request(options, function (res: IncomingMessage) { - // when the encoding is set, data chunks will be strings - res.setEncoding("utf-8"); - - let responseBody = ""; - res.on("data", function (chunk: string) { - logger.debug("Receiving data ..."); - responseBody += chunk; - }); - res.on("end", function () { - logger.debug("Parsing the response ..."); - // handle empty responses from server, for example in the case of redirects - if (!responseBody) { - responseBody = "{}"; - } - try { - const parsedResponse = JSON.parse(responseBody); - try { - resolve({ - messageObj: res, - data: parsedResponse, - }); - } catch (error) { - logger.error("Could not construct the return object."); - reject(error); - } - } catch { - logger.error("Could not parse the return as JSON."); - logger.debug(responseBody); - resolve({ - messageObj: res, - data: { reconstructedResponse: responseBody }, - }); - } - }); - }); - req.on("error", (err: any) => { - reject(err); - }); - return req; - } -} diff --git a/src/http/baseSettings.ts b/src/http/baseSettings.ts index 90be6930..ba275b36 100644 --- a/src/http/baseSettings.ts +++ b/src/http/baseSettings.ts @@ -1,16 +1,26 @@ -import { version as sdkVersion } from "../../package.json"; +import { Dispatcher, getGlobalDispatcher } from "undici"; +import packageJson from "../../package.json" with { type: "json" }; import * as os from "os"; -import { TIMEOUT_DEFAULT } from "./apiSettings"; +import { TIMEOUT_DEFAULT } from "./apiCore.js"; export interface MindeeApiConstructorProps { apiKey?: string; + dispatcher?: Dispatcher; } export abstract class BaseSettings { + apiKey: string; hostname: string; timeout: number; + dispatcher: Dispatcher; - protected constructor() { + protected constructor(apiKey?: string, dispatcher?: Dispatcher) { + if (apiKey === undefined || !apiKey || apiKey.length === 0) { + this.apiKey = this.apiKeyFromEnv(); + } else { + this.apiKey = apiKey; + } + this.dispatcher = dispatcher ?? getGlobalDispatcher(); this.hostname = this.hostnameFromEnv(); this.timeout = process.env.MINDEE_REQUEST_TIMEOUT ? parseInt(process.env.MINDEE_REQUEST_TIMEOUT) : TIMEOUT_DEFAULT; } @@ -26,7 +36,7 @@ export abstract class BaseSettings { else if (platform.includes("bsd")) { platform = "bsd"; } - return `mindee-api-nodejs@v${sdkVersion} nodejs-${ + return `mindee-api-nodejs@v${packageJson.version} nodejs-${ process.version } ${platform}`; } diff --git a/src/http/endpoint.ts b/src/http/endpoint.ts index bba83afb..567605de 100644 --- a/src/http/endpoint.ts +++ b/src/http/endpoint.ts @@ -1,19 +1,20 @@ -import { RequestOptions } from "https"; import { URLSearchParams } from "url"; -import FormData from "form-data"; -import { InputSource, LocalInputSource } from "../input"; -import { handleError } from "./error"; -import { ApiSettings } from "./apiSettings"; -import { BaseEndpoint, EndpointResponse } from "./baseEndpoint"; -import { StringDict } from "../parsing/common"; -import { ClientRequest } from "http"; -import { isValidAsyncResponse, isValidSyncResponse } from "./responseValidation"; -import { PredictParams } from "./httpParams"; +import { InputSource, LocalInputSource } from "@/input/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { cutDocPages, sendRequestAndReadResponse, EndpointResponse } from "./apiCore.js"; +import { ApiSettings } from "./apiSettings.js"; +import { handleError } from "./error.js"; +import { PredictParams } from "./httpParams.js"; +import { isValidAsyncResponse, isValidSyncResponse } from "./responseValidation.js"; /** * Endpoint for a product (OTS or Custom). */ -export class Endpoint extends BaseEndpoint { +export class Endpoint { + /** Settings relating to the API. */ + settings: ApiSettings; + /** Root of the URL for API calls. */ + urlRoot: string; /** URL of a product. */ urlName: string; /** Account owning the product. */ @@ -27,20 +28,13 @@ export class Endpoint extends BaseEndpoint { version: string, settings: ApiSettings ) { - super(settings, `/v1/products/${owner}/${urlName}/v${version}`); + this.settings = settings; + this.urlRoot = `/v1/products/${owner}/${urlName}/v${version}`; this.owner = owner; this.urlName = urlName; this.version = version; } - /** - * Changes the url to a workflow ID. - * @param workflowId - */ - useWorkflowId(workflowId: string) { - this.urlRoot = `/v1/workflows/${workflowId}`; - } - /** * Sends a document to the API and parses out the result. * Throws an error if the server's response contains one. @@ -51,7 +45,7 @@ export class Endpoint extends BaseEndpoint { async predict(params: PredictParams): Promise { await params.inputDoc.init(); if (params.pageOptions !== undefined) { - await BaseEndpoint.cutDocPages(params.inputDoc, params.pageOptions); + await cutDocPages(params.inputDoc, params.pageOptions); } const response = await this.#predictReqPost( params.inputDoc, @@ -62,7 +56,6 @@ export class Endpoint extends BaseEndpoint { if (!isValidSyncResponse(response)) { handleError(this.urlName, response, this.extractStatusMessage(response)); } - return response; } @@ -76,7 +69,7 @@ export class Endpoint extends BaseEndpoint { async predictAsync(params: PredictParams): Promise { await params.inputDoc.init(); if (params.pageOptions !== undefined) { - await BaseEndpoint.cutDocPages(params.inputDoc, params.pageOptions); + await cutDocPages(params.inputDoc, params.pageOptions); } const response = await this.#predictAsyncReqPost( params.inputDoc, @@ -143,7 +136,6 @@ export class Endpoint extends BaseEndpoint { if (!isValidAsyncResponse(response)) { handleError("document", response, this.extractStatusMessage(response)); } - return response; } @@ -163,7 +155,6 @@ export class Endpoint extends BaseEndpoint { if (!isValidSyncResponse(response)) { handleError("feedback", response, this.extractStatusMessage(response)); } - return response; } @@ -177,7 +168,7 @@ export class Endpoint extends BaseEndpoint { * @param rag * @param workflowId */ - protected sendFileForPrediction( + protected async sendFileForPrediction( input: InputSource, predictUrl: string, includeWords: boolean = false, @@ -186,52 +177,46 @@ export class Endpoint extends BaseEndpoint { rag: boolean = false, workflowId: string | undefined = undefined ): Promise { - return new Promise((resolve, reject) => { - const searchParams = new URLSearchParams(); - if (cropper) { - searchParams.append("cropper", "true"); - } - if (rag) { - searchParams.append("rag", "true"); - } - if (fullText) { - searchParams.append("full_text_ocr", "true"); - } + const searchParams = new URLSearchParams(); + if (cropper) { + searchParams.set("cropper", "true"); + } + if (rag) { + searchParams.set("rag", "true"); + } + if (fullText) { + searchParams.set("full_text_ocr", "true"); + } - const form = new FormData(); - if (input instanceof LocalInputSource && input.fileObject instanceof Buffer) { - form.append("document", input.fileObject, { - filename: input.filename, - }); - } else { - form.append("document", input.fileObject); - } + const form = new FormData(); + if (input instanceof LocalInputSource && input.fileObject instanceof Buffer) { + form.set("document", new Blob([input.fileObject]), input.filename); + } else { + form.set("document", input.fileObject); + } + if (includeWords) { + form.set("include_mvision", "true"); + } - if (includeWords) { - form.append("include_mvision", "true"); - } - const headers = { ...this.settings.baseHeaders, ...form.getHeaders() }; - let path: string; - if (workflowId === undefined) { - path = `${this.urlRoot}/${predictUrl}`; - } else { - path = `/v1/workflows/${workflowId}/predict_async`; - } - if (searchParams.toString().length > 0) { - path += `?${searchParams}`; - } - const options: RequestOptions = { - method: "POST", - headers: headers, - hostname: this.settings.hostname, - path: path, - timeout: this.settings.timeout, - }; - const req = BaseEndpoint.readResponse(options, resolve, reject); - form.pipe(req); - // potential ECONNRESET if we don't end the request. - req.end(); - }); + let path: string; + if (workflowId === undefined) { + path = `${this.urlRoot}/${predictUrl}`; + } else { + path = `/v1/workflows/${workflowId}/predict_async`; + } + if (searchParams.toString().length > 0) { + path += `?${searchParams}`; + } + + const options = { + method: "POST", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: path, + timeout: this.settings.timeout, + body: form, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } /** @@ -282,36 +267,30 @@ export class Endpoint extends BaseEndpoint { * Make a request to GET the status of a document in the queue. * @param queueId */ - #documentQueueReqGet(queueId: string): Promise { - return new Promise((resolve, reject) => { - const options = { - method: "GET", - headers: this.settings.baseHeaders, - hostname: this.settings.hostname, - path: `${this.urlRoot}/documents/queue/${queueId}`, - }; - const req = BaseEndpoint.readResponse(options, resolve, reject); - // potential ECONNRESET if we don't end the request. - req.end(); - }); + async #documentQueueReqGet(queueId: string): Promise { + const options = { + method: "GET", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: `${this.urlRoot}/documents/queue/${queueId}`, + timeout: this.settings.timeout, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } /** * Make a request to GET a document. * @param documentId */ - #documentGetReq(documentId: string): Promise { - return new Promise((resolve, reject) => { - const options = { - method: "GET", - headers: this.settings.baseHeaders, - hostname: this.settings.hostname, - path: `${this.urlRoot}/documents/${documentId}`, - }; - const req = BaseEndpoint.readResponse(options, resolve, reject); - // potential ECONNRESET if we don't end the request. - req.end(); - }); + async #documentGetReq(documentId: string): Promise { + const options = { + method: "GET", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: `${this.urlRoot}/documents/${documentId}`, + timeout: this.settings.timeout, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } /** @@ -319,19 +298,15 @@ export class Endpoint extends BaseEndpoint { * @param documentId * @param feedback */ - #documentFeedbackPutReq(documentId: string, feedback: StringDict): Promise { - return new Promise((resolve, reject) => { - const options = { - method: "PUT", - headers: this.settings.baseHeaders, - hostname: this.settings.hostname, - path: `/v1/documents/${documentId}/feedback`, - }; - const req: ClientRequest = BaseEndpoint.readResponse(options, resolve, reject); - req.write(JSON.stringify(feedback)); - - // potential ECONNRESET if we don't end the request. - req.end(); - }); + async #documentFeedbackPutReq(documentId: string, feedback: StringDict): Promise { + const options = { + method: "PUT", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: `/v1/documents/${documentId}/feedback`, + body: JSON.stringify(feedback), + timeout: this.settings.timeout, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } } diff --git a/src/http/error.ts b/src/http/error.ts index 12dd9a2d..74c5100b 100644 --- a/src/http/error.ts +++ b/src/http/error.ts @@ -1,7 +1,7 @@ -import { MindeeError } from "../errors"; -import { errorHandler } from "../errors/handler"; -import { StringDict } from "../parsing/common"; -import { EndpointResponse } from "./baseEndpoint"; +import { MindeeError } from "@/errors/index.js"; +import { errorHandler } from "@/errors/handler.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { EndpointResponse } from "./apiCore.js"; export function handleError( urlName: string, diff --git a/src/http/httpParams.ts b/src/http/httpParams.ts index 9db0bd11..8b5f701a 100644 --- a/src/http/httpParams.ts +++ b/src/http/httpParams.ts @@ -1,5 +1,5 @@ -import { InputSource, PageOptions } from "../input"; -import { ExecutionPriority } from "../parsing/common"; +import { InputSource, PageOptions } from "@/input/index.js"; +import { ExecutionPriority } from "@/parsing/common/index.js"; interface HTTPParams { inputDoc: InputSource; diff --git a/src/http/index.ts b/src/http/index.ts index cb44dd56..275d6615 100644 --- a/src/http/index.ts +++ b/src/http/index.ts @@ -1,10 +1,9 @@ -export { Endpoint } from "./endpoint"; -export { EndpointResponse } from "./baseEndpoint"; +export { Endpoint } from "./endpoint.js"; +export type { EndpointResponse } from "./apiCore.js"; export { STANDARD_API_OWNER, - API_KEY_ENVVAR_NAME, ApiSettings, -} from "./apiSettings"; +} from "./apiSettings.js"; export { MindeeHttpError, MindeeHttp400Error, @@ -16,10 +15,10 @@ export { MindeeHttp500Error, MindeeHttp504Error, handleError, -} from "./error"; +} from "./error.js"; export { isValidSyncResponse, isValidAsyncResponse, cleanRequestData, -} from "./responseValidation"; -export { PredictParams, WorkflowParams } from "./httpParams"; +} from "./responseValidation.js"; +export type { PredictParams, WorkflowParams } from "./httpParams.js"; diff --git a/src/http/mindeeApiV2.ts b/src/http/mindeeApiV2.ts index b918b9f2..04f599b8 100644 --- a/src/http/mindeeApiV2.ts +++ b/src/http/mindeeApiV2.ts @@ -1,18 +1,17 @@ -import { ApiSettingsV2 } from "./apiSettingsV2"; -import { InferenceParameters } from "../clientV2"; -import { ErrorResponse, InferenceResponse, JobResponse } from "../parsing/v2"; -import FormData from "form-data"; -import { RequestOptions } from "https"; -import { BaseEndpoint, EndpointResponse } from "./baseEndpoint"; -import { InputSource, LocalInputSource, UrlInput } from "../input"; -import { MindeeApiV2Error, MindeeHttpErrorV2 } from "../errors/mindeeError"; -import { logger } from "../logger"; +import { ApiSettingsV2 } from "./apiSettingsV2.js"; +import { Dispatcher } from "undici"; +import { InferenceParameters } from "@/clientV2.js"; +import { ErrorResponse, InferenceResponse, JobResponse } from "@/parsing/v2/index.js"; +import { sendRequestAndReadResponse, EndpointResponse } from "./apiCore.js"; +import { InputSource, LocalInputSource, UrlInput } from "@/input/index.js"; +import { MindeeApiV2Error, MindeeHttpErrorV2 } from "@/errors/index.js"; +import { logger } from "@/logger.js"; export class MindeeApiV2 { settings: ApiSettingsV2; - constructor(apiKey?: string) { - this.settings = new ApiSettingsV2({ apiKey: apiKey }); + constructor(dispatcher?: Dispatcher, apiKey?: string) { + this.settings = new ApiSettingsV2({ dispatcher: dispatcher, apiKey: apiKey }); } /** @@ -91,56 +90,49 @@ export class MindeeApiV2 { * @param inputSource Local or remote file as an input. * @param params {InferenceParameters} parameters relating to the enqueueing options. */ - #documentEnqueuePost( + async #documentEnqueuePost( inputSource: InputSource, params: InferenceParameters ): Promise { const form = new FormData(); - form.append("model_id", params.modelId); + form.set("model_id", params.modelId); if (params.rag !== undefined && params.rag !== null) { - form.append("rag", params.rag.toString()); + form.set("rag", params.rag.toString()); } if (params.polygon !== undefined && params.polygon !== null) { - form.append("polygon", params.polygon.toString().toLowerCase()); + form.set("polygon", params.polygon.toString().toLowerCase()); } if (params.confidence !== undefined && params.confidence !== null) { - form.append("confidence", params.confidence.toString().toLowerCase()); + form.set("confidence", params.confidence.toString().toLowerCase()); } if (params.rawText !== undefined && params.rawText !== null) { - form.append("raw_text", params.rawText.toString().toLowerCase()); + form.set("raw_text", params.rawText.toString().toLowerCase()); } if (params.textContext !== undefined && params.textContext !== null) { - form.append("text_context", params.textContext); + form.set("text_context", params.textContext); } if (params.dataSchema !== undefined && params.dataSchema !== null) { - form.append("data_schema", params.dataSchema.toString()); + form.set("data_schema", params.dataSchema.toString()); } if (params.webhookIds && params.webhookIds.length > 0) { - form.append("webhook_ids", params.webhookIds.join(",")); + form.set("webhook_ids", params.webhookIds.join(",")); } if (inputSource instanceof LocalInputSource) { - form.append("file", inputSource.fileObject, { - filename: inputSource.filename, - }); + form.set("file", new Blob([inputSource.fileObject]), inputSource.filename); } else { - form.append("url", (inputSource as UrlInput).url); + form.set("url", (inputSource as UrlInput).url); } const path = "/v2/inferences/enqueue"; - const headers = { ...this.settings.baseHeaders, ...form.getHeaders() }; - const options: RequestOptions = { + const options = { method: "POST", - headers: headers, + headers: this.settings.baseHeaders, hostname: this.settings.hostname, path: path, + body: form, timeout: this.settings.timeout, }; - return new Promise((resolve, reject) => { - const req = BaseEndpoint.readResponse(options, resolve, reject); - form.pipe(req); - // potential ECONNRESET if we don't end the request. - req.end(); - }); + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } /** @@ -150,17 +142,14 @@ export class MindeeApiV2 { * @category Asynchronous * @returns a `Promise` containing either the parsed result, or information on the queue. */ - #inferenceResultReqGet(queueId: string, slug: string): Promise { - return new Promise((resolve, reject) => { - const options = { - method: "GET", - headers: this.settings.baseHeaders, - hostname: this.settings.hostname, - path: `/v2/${slug}/${queueId}`, - }; - const req = BaseEndpoint.readResponse(options, resolve, reject); - // potential ECONNRESET if we don't end the request. - req.end(); - }); + async #inferenceResultReqGet(queueId: string, slug: string): Promise { + const options = { + method: "GET", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: `/v2/${slug}/${queueId}`, + timeout: this.settings.timeout, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } } diff --git a/src/http/responseValidation.ts b/src/http/responseValidation.ts index e3bf926f..884cab71 100644 --- a/src/http/responseValidation.ts +++ b/src/http/responseValidation.ts @@ -1,4 +1,4 @@ -import { EndpointResponse } from "./baseEndpoint"; +import { EndpointResponse } from "./apiCore.js"; /** * Checks if the synchronous response is valid. Returns True if the response is valid. diff --git a/src/http/workflowEndpoint.ts b/src/http/workflowEndpoint.ts index 44e1a6cb..595f4309 100644 --- a/src/http/workflowEndpoint.ts +++ b/src/http/workflowEndpoint.ts @@ -1,27 +1,29 @@ -import { BaseEndpoint, EndpointResponse } from "./baseEndpoint"; -import { ApiSettings } from "./apiSettings"; -import { InputSource, LocalInputSource } from "../input"; import { URLSearchParams } from "url"; -import FormData from "form-data"; -import { RequestOptions } from "https"; -import { isValidSyncResponse } from "./responseValidation"; -import { handleError } from "./error"; - -import { WorkflowParams } from "./httpParams"; -import { ExecutionPriority } from "../parsing/common"; +import { InputSource, LocalInputSource } from "@/input/index.js"; +import { ExecutionPriority } from "@/parsing/common/index.js"; +import { cutDocPages, sendRequestAndReadResponse, EndpointResponse } from "./apiCore.js"; +import { ApiSettings } from "./apiSettings.js"; +import { handleError } from "./error.js"; +import { WorkflowParams } from "./httpParams.js"; +import { isValidSyncResponse } from "./responseValidation.js"; /** * Endpoint for a workflow. */ -export class WorkflowEndpoint extends BaseEndpoint { +export class WorkflowEndpoint { + /** Settings relating to the API. */ + settings: ApiSettings; + /** Root of the URL for API calls. */ + urlRoot: string; + constructor( settings: ApiSettings, workflowId: string ) { - super(settings, `/v1/workflows/${workflowId}/executions`); + this.settings = settings; + this.urlRoot = `/v1/workflows/${workflowId}/executions`; } - /** * Sends a document to a workflow execution. * Throws an error if the server's response contains one. @@ -32,13 +34,12 @@ export class WorkflowEndpoint extends BaseEndpoint { async executeWorkflow(params: WorkflowParams): Promise { await params.inputDoc.init(); if (params.pageOptions !== undefined) { - await BaseEndpoint.cutDocPages(params.inputDoc, params.pageOptions); + await cutDocPages(params.inputDoc, params.pageOptions); } const response = await this.#workflowReqPost(params); if (!isValidSyncResponse(response)) { handleError(this.urlRoot, response, response.messageObj?.statusMessage); } - return response; } @@ -67,7 +68,7 @@ export class WorkflowEndpoint extends BaseEndpoint { * @param publicUrl * @param rag */ - protected sendFileForPrediction( + protected async sendFileForPrediction( input: InputSource, alias: string | null = null, priority: ExecutionPriority | null = null, @@ -75,52 +76,43 @@ export class WorkflowEndpoint extends BaseEndpoint { publicUrl: string | null = null, rag: boolean | null = null, ): Promise { - return new Promise((resolve, reject) => { - const searchParams = new URLSearchParams(); - - if (fullText) { - searchParams.append("full_text_ocr", "true"); - } - - if (rag) { - searchParams.append("rag", "true"); - } + const searchParams = new URLSearchParams(); + if (fullText) { + searchParams.set("full_text_ocr", "true"); + } + if (rag) { + searchParams.set("rag", "true"); + } - const form = new FormData(); - if (input instanceof LocalInputSource && input.fileObject instanceof Buffer) { - form.append("document", input.fileObject, { - filename: input.filename, - }); - } else { - form.append("document", input.fileObject); - } + const form = new FormData(); + if (input instanceof LocalInputSource && input.fileObject instanceof Buffer) { + form.set("document", new Blob([input.fileObject]), input.filename); + } else { + form.set("document", input.fileObject); + } + if (alias) { + form.set("alias", alias); + } + if (publicUrl) { + form.set("public_url", publicUrl); + } + if (priority) { + form.set("priority", priority.toString()); + } - if (alias) { - form.append("alias", alias); - } - if (publicUrl) { - form.append("public_url", publicUrl); - } - if (priority) { - form.append("priority", priority.toString()); - } - const headers = { ...this.settings.baseHeaders, ...form.getHeaders() }; + let path = this.urlRoot; + if (searchParams.toString().length > 0) { + path += `?${searchParams}`; + } - let path = this.urlRoot; - if (searchParams.toString().length > 0) { - path += `?${searchParams}`; - } - const options: RequestOptions = { - method: "POST", - headers: headers, - hostname: this.settings.hostname, - path: path, - timeout: this.settings.timeout, - }; - const req = BaseEndpoint.readResponse(options, resolve, reject); - form.pipe(req); - // potential ECONNRESET if we don't end the request. - req.end(); - }); + const options = { + method: "POST", + headers: this.settings.baseHeaders, + hostname: this.settings.hostname, + path: path, + timeout: this.settings.timeout, + body: form, + }; + return await sendRequestAndReadResponse(this.settings.dispatcher, options); } } diff --git a/src/imageOperations/common/extractedImage.ts b/src/imageOperations/common/extractedImage.ts index 175dde35..5e16a1c0 100644 --- a/src/imageOperations/common/extractedImage.ts +++ b/src/imageOperations/common/extractedImage.ts @@ -1,10 +1,10 @@ import { Buffer } from "node:buffer"; -import { MindeeError } from "../../errors"; +import { MindeeError } from "@/errors/index.js"; import { writeFileSync } from "node:fs"; import path from "node:path"; -import { logger } from "../../logger"; -import { BufferInput } from "../../input"; -import { MIMETYPES } from "../../input/sources/localInputSource"; +import { logger } from "@/logger.js"; +import { BufferInput } from "@/input/index.js"; +import { MIMETYPES } from "@/input/sources/localInputSource.js"; import { Poppler } from "node-poppler"; import { writeFile } from "fs/promises"; diff --git a/src/imageOperations/common/imageExtractor.ts b/src/imageOperations/common/imageExtractor.ts index a0dea505..f9895c91 100644 --- a/src/imageOperations/common/imageExtractor.ts +++ b/src/imageOperations/common/imageExtractor.ts @@ -1,6 +1,6 @@ import { PDFDocument, PDFPage, degrees } from "@cantoo/pdf-lib"; -import { getMinMaxX, getMinMaxY, Polygon } from "../../geometry"; -import { adjustForRotation } from "../../geometry/polygonUtils"; +import { getMinMaxX, getMinMaxY, Polygon } from "@/geometry/index.js"; +import { adjustForRotation } from "@/geometry/polygonUtils.js"; /** * Extracts elements from a page based off of a list of bounding boxes. diff --git a/src/imageOperations/common/index.ts b/src/imageOperations/common/index.ts index ef207f84..f87b9a6a 100644 --- a/src/imageOperations/common/index.ts +++ b/src/imageOperations/common/index.ts @@ -1,2 +1,2 @@ -export { ExtractedImage } from "./extractedImage"; -export { extractFromPage } from "./imageExtractor"; +export { ExtractedImage } from "./extractedImage.js"; +export { extractFromPage } from "./imageExtractor.js"; diff --git a/src/imageOperations/imageCompressor.ts b/src/imageOperations/imageCompressor.ts index df23e82c..e9f77c1a 100644 --- a/src/imageOperations/imageCompressor.ts +++ b/src/imageOperations/imageCompressor.ts @@ -1,6 +1,6 @@ import sharp from "sharp"; import { Sharp, Metadata } from "sharp"; -import { MindeeImageError } from "../errors/mindeeError"; +import { MindeeImageError } from "@/errors/index.js"; /** * Compresses an image with the given parameters. diff --git a/src/imageOperations/index.ts b/src/imageOperations/index.ts index 573ec2ad..bac08a1c 100644 --- a/src/imageOperations/index.ts +++ b/src/imageOperations/index.ts @@ -1,3 +1,4 @@ -export { extractReceipts, ExtractedMultiReceiptImage } from "./multiReceiptsExtractor"; -export { extractInvoices, ExtractedInvoiceSplitterImage } from "./invoiceSplitterExtractor"; -export { compressImage } from "./imageCompressor"; +export { extractReceipts, ExtractedMultiReceiptImage } from "./multiReceiptsExtractor/index.js"; +export { extractInvoices, ExtractedInvoiceSplitterImage } from "./invoiceSplitterExtractor/index.js"; +export { compressImage } from "./imageCompressor.js"; +export { ExtractedImage } from "./common/index.js"; diff --git a/src/imageOperations/internal.ts b/src/imageOperations/internal.ts deleted file mode 100644 index 0c15d653..00000000 --- a/src/imageOperations/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { extractReceipts, ExtractedMultiReceiptImage } from "./multiReceiptsExtractor"; -export { extractInvoices, ExtractedInvoiceSplitterImage } from "./invoiceSplitterExtractor"; -export { ExtractedImage } from "./common"; diff --git a/src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts b/src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts index 36f8fdb1..44f88ae9 100644 --- a/src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts +++ b/src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts @@ -1,4 +1,4 @@ -import { ExtractedImage } from "../common/extractedImage"; +import { ExtractedImage } from "@/imageOperations/common/extractedImage.js"; /** * Wrapper class for extracted invoice pages. diff --git a/src/imageOperations/invoiceSplitterExtractor/index.ts b/src/imageOperations/invoiceSplitterExtractor/index.ts index ec4cf214..376c3113 100644 --- a/src/imageOperations/invoiceSplitterExtractor/index.ts +++ b/src/imageOperations/invoiceSplitterExtractor/index.ts @@ -1,2 +1,2 @@ -export { extractInvoices } from "./invoiceSplitterExtractor"; -export { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterImage"; +export { extractInvoices } from "./invoiceSplitterExtractor.js"; +export { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterImage.js"; diff --git a/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts b/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts index 83c4303a..f47a9f28 100644 --- a/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts +++ b/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts @@ -1,8 +1,8 @@ import { PDFDocument } from "@cantoo/pdf-lib"; -import { MindeeError, MindeeMimeTypeError } from "../../errors"; -import { InvoiceSplitterV1 } from "../../product"; -import { LocalInputSource } from "../../input"; -import { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterImage"; +import { MindeeError, MindeeMimeTypeError } from "@/errors/index.js"; +import { InvoiceSplitterV1 } from "@/product/index.js"; +import { LocalInputSource } from "@/input/index.js"; +import { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterImage.js"; async function splitPdf(pdfDoc: PDFDocument, invoicePageGroups: number[][]): Promise { if (invoicePageGroups.length === 0) { diff --git a/src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts b/src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts index 83ce558f..d236fb23 100644 --- a/src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts +++ b/src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts @@ -1,4 +1,4 @@ -import { ExtractedImage } from "../common"; +import { ExtractedImage } from "@/imageOperations/common/extractedImage.js"; /** * Wrapper class for extracted multiple-receipts images. diff --git a/src/imageOperations/multiReceiptsExtractor/index.ts b/src/imageOperations/multiReceiptsExtractor/index.ts index 9800ec30..b889e434 100644 --- a/src/imageOperations/multiReceiptsExtractor/index.ts +++ b/src/imageOperations/multiReceiptsExtractor/index.ts @@ -1,2 +1,2 @@ -export { extractReceipts } from "./multiReceiptsExtractor"; -export { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage"; +export { extractReceipts } from "./multiReceiptsExtractor.js"; +export { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage.js"; diff --git a/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts b/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts index 086fe405..c90cb854 100644 --- a/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts +++ b/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts @@ -1,11 +1,11 @@ import { PDFDocument, PDFImage, PDFPage, degrees } from "@cantoo/pdf-lib"; -import { MindeeError, MindeeMimeTypeError } from "../../errors"; -import { Polygon } from "../../geometry"; -import { MultiReceiptsDetectorV1 } from "../../product"; -import { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage"; -import { LocalInputSource } from "../../input"; -import { extractFromPage } from "../common"; -import { PositionField } from "../../parsing/standard"; +import { MindeeError, MindeeMimeTypeError } from "@/errors/index.js"; +import { Polygon } from "@/geometry/index.js"; +import { MultiReceiptsDetectorV1 } from "@/product/index.js"; +import { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage.js"; +import { LocalInputSource } from "@/input/index.js"; +import { extractFromPage } from "../common/index.js"; +import { PositionField } from "@/parsing/standard/index.js"; /** * Given a page and a set of coordinates, extracts & assigns individual receipts to an ExtractedMultiReceiptImage diff --git a/src/index.ts b/src/index.ts index e1db5918..16849ac0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,8 @@ -export * as product from "./product"; -export { Client, PredictOptions, WorkflowOptions } from "./client"; -export { ClientV2, InferenceParameters, PollingOptions } from "./clientV2"; +export * as product from "./product/index.js"; +export { Client } from "./client.js"; +export type { PredictOptions, WorkflowOptions } from "./client.js"; +export { ClientV2 } from "./clientV2.js"; +export type { InferenceParameters, PollingOptions } from "./clientV2.js"; export { AsyncPredictResponse, PredictResponse, @@ -8,14 +10,14 @@ export { Prediction, Document, Page, -} from "./parsing/common"; +} from "./parsing/common/index.js"; export { InferenceFile, InferenceResponse, JobResponse, RawText, RagMetadata, -} from "./parsing/v2"; +} from "./parsing/v2/index.js"; export { InputSource, Base64Input, @@ -23,10 +25,8 @@ export { BytesInput, PathInput, StreamInput, - UrlInput, - PageOptions, - PageOptionsOperation, + UrlInput, PageOptionsOperation, LocalResponse -} from "./input"; -export * as internal from "./internal"; -export * as imageOperations from "./imageOperations"; +} from "./input/index.js"; +export type { PageOptions } from "./input/index.js"; +export * as imageOperations from "./imageOperations/index.js"; diff --git a/src/input/dataSchema.ts b/src/input/dataSchema.ts index 5cfd3515..b5135f9e 100644 --- a/src/input/dataSchema.ts +++ b/src/input/dataSchema.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../parsing/common"; -import { MindeeError } from "../errors"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { MindeeError } from "../errors/index.js"; export class DataSchemaField { /** diff --git a/src/input/index.ts b/src/input/index.ts index 3b8e1e66..24ec093b 100644 --- a/src/input/index.ts +++ b/src/input/index.ts @@ -1,4 +1,8 @@ -export { DataSchema, DataSchemaField, DataSchemaReplace } from "./dataSchema"; -export * from "./sources"; -export { LocalResponse } from "./localResponse"; -export { PageOptions, PageOptionsOperation } from "./pageOptions"; +export { + DataSchema, DataSchemaField, DataSchemaReplace +} from "./dataSchema.js"; +export * from "./sources/index.js"; +export { LocalResponse } from "./localResponse.js"; +export { PageOptionsOperation } from "./pageOptions.js"; +export type { PageOptions } from "./pageOptions.js"; + diff --git a/src/input/localResponse.ts b/src/input/localResponse.ts index c13ca803..b5af6c27 100644 --- a/src/input/localResponse.ts +++ b/src/input/localResponse.ts @@ -1,9 +1,9 @@ import * as crypto from "crypto"; import * as fs from "node:fs/promises"; -import { StringDict } from "../parsing/common"; -import { MindeeError } from "../errors"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { MindeeError } from "../errors/index.js"; import { Buffer } from "buffer"; -import { CommonResponse } from "../parsing/v2"; +import { CommonResponse } from "../parsing/v2/index.js"; /** * Local response loaded from a file. diff --git a/src/input/sources/base64Input.ts b/src/input/sources/base64Input.ts index c4ce6c11..d8c67fc3 100644 --- a/src/input/sources/base64Input.ts +++ b/src/input/sources/base64Input.ts @@ -1,6 +1,6 @@ -import { LocalInputSource } from "./localInputSource"; -import { INPUT_TYPE_BASE64 } from "./inputSource"; -import { logger } from "../../logger"; +import { LocalInputSource } from "./localInputSource.js"; +import { INPUT_TYPE_BASE64 } from "./inputSource.js"; +import { logger } from "@/logger.js"; interface Base64InputProps { inputString: string; diff --git a/src/input/sources/bufferInput.ts b/src/input/sources/bufferInput.ts index aed8908e..f3cd7135 100644 --- a/src/input/sources/bufferInput.ts +++ b/src/input/sources/bufferInput.ts @@ -1,6 +1,6 @@ -import { LocalInputSource } from "./localInputSource"; -import { INPUT_TYPE_BUFFER } from "./inputSource"; -import { logger } from "../../logger"; +import { LocalInputSource } from "./localInputSource.js"; +import { INPUT_TYPE_BUFFER } from "./inputSource.js"; +import { logger } from "@/logger.js"; interface BufferInputProps { buffer: Buffer; diff --git a/src/input/sources/bytesInput.ts b/src/input/sources/bytesInput.ts index d61eab46..3387b34c 100644 --- a/src/input/sources/bytesInput.ts +++ b/src/input/sources/bytesInput.ts @@ -1,6 +1,6 @@ -import { INPUT_TYPE_BYTES } from "./inputSource"; -import { LocalInputSource } from "./localInputSource"; -import { logger } from "../../logger"; +import { INPUT_TYPE_BYTES } from "./inputSource.js"; +import { LocalInputSource } from "./localInputSource.js"; +import { logger } from "@/logger.js"; interface BytesInputProps { inputBytes: Uint8Array; diff --git a/src/input/sources/index.ts b/src/input/sources/index.ts index 1f9b59b7..34b7feff 100644 --- a/src/input/sources/index.ts +++ b/src/input/sources/index.ts @@ -1,16 +1,15 @@ -export { Base64Input } from "./base64Input"; -export { BufferInput } from "./bufferInput"; -export { BytesInput } from "./bytesInput"; +export { Base64Input } from "./base64Input.js"; +export { BufferInput } from "./bufferInput.js"; +export { BytesInput } from "./bytesInput.js"; export { InputSource, INPUT_TYPE_PATH, - INPUT_TYPE_STREAM, - InputConstructor, - INPUT_TYPE_BUFFER, + INPUT_TYPE_STREAM, INPUT_TYPE_BUFFER, INPUT_TYPE_BASE64, INPUT_TYPE_BYTES -} from "./inputSource"; -export { LocalInputSource } from "./localInputSource"; -export { PathInput } from "./pathInput"; -export { StreamInput } from "./streamInput"; -export { UrlInput } from "./urlInput"; +} from "./inputSource.js"; +export type { InputConstructor } from "./inputSource.js"; +export { LocalInputSource } from "./localInputSource.js"; +export { PathInput } from "./pathInput.js"; +export { StreamInput } from "./streamInput.js"; +export { UrlInput } from "./urlInput.js"; diff --git a/src/input/sources/localInputSource.ts b/src/input/sources/localInputSource.ts index 203b6c39..9e66615c 100644 --- a/src/input/sources/localInputSource.ts +++ b/src/input/sources/localInputSource.ts @@ -1,11 +1,10 @@ -import { errorHandler } from "../../errors/handler"; -import { logger } from "../../logger"; -import { compressImage } from "../../imageOperations"; -import { compressPdf, countPages } from "../../pdf"; +import { errorHandler } from "@/errors/handler.js"; +import { logger } from "@/logger.js"; +import { compressImage } from "@/imageOperations/index.js"; +import { compressPdf, countPages, extractPages, hasSourceText } from "@/pdf/index.js"; import path from "path"; -import * as fileType from "file-type"; -import { PageOptions } from "../pageOptions"; -import { extractPages, hasSourceText } from "../../pdf"; +import { fileTypeFromBuffer } from "file-type"; +import { PageOptions } from "../pageOptions.js"; import { InputSource, InputConstructor, @@ -13,7 +12,7 @@ import { INPUT_TYPE_BASE64, INPUT_TYPE_BYTES, INPUT_TYPE_PATH, INPUT_TYPE_BUFFER -} from "./inputSource"; +} from "./inputSource.js"; export const MIMETYPES = new Map([ [".pdf", "application/pdf"], @@ -67,7 +66,7 @@ export abstract class LocalInputSource extends InputSource { if (fileExt) { mimeType = MIMETYPES.get(fileExt.toLowerCase()) || ""; } else { - const guess = await fileType.fromBuffer(this.fileObject); + const guess = await fileTypeFromBuffer(this.fileObject); if (guess !== undefined) { mimeType = guess.mime; } else { diff --git a/src/input/sources/pathInput.ts b/src/input/sources/pathInput.ts index 7c39244d..c6f05851 100644 --- a/src/input/sources/pathInput.ts +++ b/src/input/sources/pathInput.ts @@ -1,7 +1,7 @@ -import { INPUT_TYPE_PATH } from "./inputSource"; -import { LocalInputSource } from "./localInputSource"; +import { INPUT_TYPE_PATH } from "./inputSource.js"; +import { LocalInputSource } from "./localInputSource.js"; import path from "path"; -import { logger } from "../../logger"; +import { logger } from "@/logger.js"; import { promises as fs } from "fs"; interface PathInputProps { diff --git a/src/input/sources/streamInput.ts b/src/input/sources/streamInput.ts index 71037612..01c0eb2d 100644 --- a/src/input/sources/streamInput.ts +++ b/src/input/sources/streamInput.ts @@ -1,8 +1,8 @@ import { Readable } from "stream"; -import { LocalInputSource } from "./localInputSource"; -import { INPUT_TYPE_STREAM } from "./inputSource"; -import { logger } from "../../logger"; -import { MindeeError } from "../../errors"; +import { LocalInputSource } from "./localInputSource.js"; +import { INPUT_TYPE_STREAM } from "./inputSource.js"; +import { logger } from "@/logger.js"; +import { MindeeError } from "@/errors/index.js"; interface StreamInputProps { inputStream: Readable; diff --git a/src/input/sources/urlInput.ts b/src/input/sources/urlInput.ts index 708fcd16..20e2a3d9 100644 --- a/src/input/sources/urlInput.ts +++ b/src/input/sources/urlInput.ts @@ -1,19 +1,20 @@ -import { InputSource } from "./inputSource"; +import { InputSource } from "./inputSource.js"; import { URL } from "url"; import { basename, extname } from "path"; import { randomBytes } from "crypto"; import { writeFile } from "fs/promises"; -import { request as httpsRequest } from "https"; -import { IncomingMessage } from "http"; -import { BytesInput } from "./bytesInput"; -import { logger } from "../../logger"; +import { request, Dispatcher, getGlobalDispatcher } from "undici"; +import { BytesInput } from "./bytesInput.js"; +import { logger } from "@/logger.js"; export class UrlInput extends InputSource { public readonly url: string; + public readonly dispatcher; - constructor({ url }: { url: string }) { + constructor({ url, dispatcher }: { url: string, dispatcher?: Dispatcher }) { super(); this.url = url; + this.dispatcher = dispatcher ?? getGlobalDispatcher(); } async init() { @@ -102,7 +103,6 @@ export class UrlInput extends InputSource { UrlInput.getFileExtension(filename || "") || undefined ); } - return filename; } @@ -114,26 +114,28 @@ export class UrlInput extends InputSource { maxRedirects: number ): Promise<{ content: Buffer; finalUrl: string }> { const parsedUrl = new URL(url); - const options = { - hostname: parsedUrl.hostname, - path: parsedUrl.pathname + parsedUrl.search, - method: "GET", - headers: headers, - auth: auth, - }; - - const response = await new Promise((resolve, reject) => { - const req = httpsRequest(options, resolve); - req.on("error", reject); - req.end(); - }); + + const response = await request( + parsedUrl, + { + method: "GET", + headers: headers, + throwOnError: false, + dispatcher: this.dispatcher, + } + ); if (response.statusCode && response.statusCode >= 300 && response.statusCode < 400) { + logger.debug(`Redirecting to: ${response.headers.location}`); if (redirects === maxRedirects) { - throw new Error(`Can't reach URL after ${redirects} out of ${maxRedirects} redirects, aborting operation.`); + throw new Error( + `Can't reach URL after ${redirects} out of ${maxRedirects} redirects, aborting operation.` + ); } if (response.headers.location) { - return await this.makeRequest(response.headers.location, auth, headers, redirects + 1, maxRedirects); + return await this.makeRequest( + response.headers.location.toString(), auth, headers, redirects + 1, maxRedirects + ); } throw new Error("Redirect location not found"); } @@ -141,11 +143,7 @@ export class UrlInput extends InputSource { if (!response.statusCode || response.statusCode >= 400 || response.statusCode < 200) { throw new Error(`Couldn't retrieve file from server, error code ${response.statusCode}.`); } - - const chunks: Buffer[] = []; - for await (const chunk of response) { - chunks.push(chunk); - } - return { content: Buffer.concat(chunks), finalUrl: url }; + const arrayBuffer = await response.body.arrayBuffer(); + return { content: Buffer.from(arrayBuffer), finalUrl: url }; } } diff --git a/src/internal.ts b/src/internal.ts deleted file mode 100644 index bb7ffc12..00000000 --- a/src/internal.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * as input from "./input"; -export * as geometry from "./geometry"; -export * as http from "./http"; -export * as imageOperations from "./imageOperations/internal"; -export * as parsing from "./parsing"; -export * as pdf from "./pdf"; -export * as product from "./product/internal"; diff --git a/src/parsing/common/apiRequest.ts b/src/parsing/common/apiRequest.ts index 5ce160a0..a502f161 100644 --- a/src/parsing/common/apiRequest.ts +++ b/src/parsing/common/apiRequest.ts @@ -1,7 +1,7 @@ -import { StringDict } from "./stringDict"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Holds the information relating to an API HTTP request. - * + * * @category API Response */ export class ApiRequest { diff --git a/src/parsing/common/apiResponse.ts b/src/parsing/common/apiResponse.ts index 43900038..39654808 100644 --- a/src/parsing/common/apiResponse.ts +++ b/src/parsing/common/apiResponse.ts @@ -1,9 +1,9 @@ -import { ApiRequest } from "./apiRequest"; -import { StringDict } from "./stringDict"; +import { ApiRequest } from "./apiRequest.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** Base wrapper for API requests. - * + * * @category API Response */ export abstract class ApiResponse { diff --git a/src/parsing/common/asyncPredictResponse.ts b/src/parsing/common/asyncPredictResponse.ts index aee7b144..6c60ac2c 100644 --- a/src/parsing/common/asyncPredictResponse.ts +++ b/src/parsing/common/asyncPredictResponse.ts @@ -1,7 +1,7 @@ -import { ApiResponse } from "./apiResponse"; -import { StringDict } from "./stringDict"; -import { Inference } from "./inference"; -import { Document } from "./document"; +import { ApiResponse } from "./apiResponse.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Inference } from "./inference.js"; +import { Document } from "./document.js"; /** Wrapper for asynchronous request queues. Holds information regarding a job (queue). * diff --git a/src/parsing/common/document.ts b/src/parsing/common/document.ts index d7a28bb4..c94867ed 100644 --- a/src/parsing/common/document.ts +++ b/src/parsing/common/document.ts @@ -1,9 +1,8 @@ -import { CropperExtra, FullTextOcrExtra } from "./extras"; -import { ExtraField, Extras } from "./extras/extras"; -import { Inference } from "./inference"; -import { Ocr } from "./ocr"; -import { StringDict } from "./stringDict"; -import { RAGExtra } from "./extras/ragExtra"; +import { CropperExtra, FullTextOcrExtra, ExtraField, Extras } from "./extras/index.js"; +import { Inference } from "./inference.js"; +import { Ocr } from "./ocr.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { RAGExtra } from "./extras/ragExtra.js"; /** * Document prediction wrapper class. Holds the results of a parsed document. diff --git a/src/parsing/common/execution.ts b/src/parsing/common/execution.ts index 24ff111a..78d66660 100644 --- a/src/parsing/common/execution.ts +++ b/src/parsing/common/execution.ts @@ -1,9 +1,9 @@ -import { Inference } from "./inference"; -import { GeneratedV1Document } from "../../product/generated/generatedV1Document"; -import { ExecutionFile } from "./executionFile"; -import { StringDict } from "./stringDict"; -import { ExecutionPriority } from "./executionPriority"; -import { parseDate } from "./dateParser"; +import { Inference } from "./inference.js"; +import { GeneratedV1Document } from "@/product/generated/generatedV1Document.js"; +import { ExecutionFile } from "./executionFile.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { ExecutionPriority } from "./executionPriority.js"; +import { parseDate } from "./dateParser.js"; /** * Representation of an execution for a workflow. diff --git a/src/parsing/common/executionFile.ts b/src/parsing/common/executionFile.ts index 25dbdb6b..72e9db13 100644 --- a/src/parsing/common/executionFile.ts +++ b/src/parsing/common/executionFile.ts @@ -1,4 +1,4 @@ -import { StringDict } from "./stringDict"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Representation of an execution's file info. diff --git a/src/parsing/common/extras/cropperExtra.ts b/src/parsing/common/extras/cropperExtra.ts index 20934146..303f37aa 100644 --- a/src/parsing/common/extras/cropperExtra.ts +++ b/src/parsing/common/extras/cropperExtra.ts @@ -1,7 +1,7 @@ -import { PositionField } from "../../standard"; -import { StringDict } from "../stringDict"; -import { cleanOutString } from "../summaryHelper"; -import { ExtraField } from "./extras"; +import { PositionField } from "@/parsing/standard/position.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanOutString } from "../summaryHelper.js"; +import { ExtraField } from "./extras.js"; export class CropperExtra extends ExtraField { cropping: PositionField[] = []; diff --git a/src/parsing/common/extras/fullTextOcrExtra.ts b/src/parsing/common/extras/fullTextOcrExtra.ts index 217776ae..94f0a949 100644 --- a/src/parsing/common/extras/fullTextOcrExtra.ts +++ b/src/parsing/common/extras/fullTextOcrExtra.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../stringDict"; -import { ExtraField } from "./extras"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { ExtraField } from "./extras.js"; export class FullTextOcrExtra extends ExtraField { content?: string; diff --git a/src/parsing/common/extras/index.ts b/src/parsing/common/extras/index.ts index c2485ff0..114fc798 100644 --- a/src/parsing/common/extras/index.ts +++ b/src/parsing/common/extras/index.ts @@ -1,3 +1,4 @@ -export { CropperExtra } from "./cropperExtra"; -export { Extras } from "./extras"; -export { FullTextOcrExtra } from "./fullTextOcrExtra"; +export { CropperExtra } from "./cropperExtra.js"; +export { Extras, ExtraField } from "./extras.js"; +export { FullTextOcrExtra } from "./fullTextOcrExtra.js"; +export { RAGExtra } from "./ragExtra.js"; diff --git a/src/parsing/common/extras/ragExtra.ts b/src/parsing/common/extras/ragExtra.ts index 38f520ed..cd0a28d0 100644 --- a/src/parsing/common/extras/ragExtra.ts +++ b/src/parsing/common/extras/ragExtra.ts @@ -1,5 +1,5 @@ -import { ExtraField } from "./extras"; -import { StringDict } from "../stringDict"; +import { ExtraField } from "./extras.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class RAGExtra extends ExtraField { /** diff --git a/src/parsing/common/feedback/feedbackResponse.ts b/src/parsing/common/feedback/feedbackResponse.ts index db8cf4ea..b31408ee 100644 --- a/src/parsing/common/feedback/feedbackResponse.ts +++ b/src/parsing/common/feedback/feedbackResponse.ts @@ -1,5 +1,5 @@ -import { ApiResponse } from "../apiResponse"; -import { StringDict } from "../stringDict"; +import { ApiResponse } from "../apiResponse.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Wrapper for feedback response. diff --git a/src/parsing/common/index.ts b/src/parsing/common/index.ts index 914cf4cc..f66cf009 100644 --- a/src/parsing/common/index.ts +++ b/src/parsing/common/index.ts @@ -1,16 +1,18 @@ -export { Document } from "./document"; -export { Execution } from "./execution"; -export { ExecutionFile } from "./executionFile"; -export { ExecutionPriority } from "./executionPriority"; -export { Inference } from "./inference"; -export { FeedbackResponse } from "./feedback/feedbackResponse"; -export { OrientationField } from "./orientation"; -export { StringDict } from "./stringDict"; -export { AsyncPredictResponse } from "./asyncPredictResponse"; -export { PredictResponse } from "./predictResponse"; -export { Prediction } from "./prediction"; -export { Page } from "./page"; -export { cleanOutString, lineSeparator } from "./summaryHelper"; -export * as extras from "./extras"; -export { floatToString, cleanSpecialChars } from "./summaryHelper"; -export { parseDate } from "./dateParser"; +export { Document } from "./document.js"; +export { Execution } from "./execution.js"; +export { ExecutionFile } from "./executionFile.js"; +export { ExecutionPriority } from "./executionPriority.js"; +export { Inference } from "./inference.js"; +export { FeedbackResponse } from "./feedback/feedbackResponse.js"; +export { OrientationField } from "./orientation.js"; +export type { StringDict } from "./stringDict.js"; +export { AsyncPredictResponse } from "./asyncPredictResponse.js"; +export { PredictResponse } from "./predictResponse.js"; +export { Prediction } from "./prediction.js"; +export { Page } from "./page.js"; +export { + cleanOutString, lineSeparator, floatToString, cleanSpecialChars +} from "./summaryHelper.js"; +export * as extras from "./extras/index.js"; +export { parseDate } from "./dateParser.js"; +export { WorkflowResponse } from "./workflowResponse.js"; diff --git a/src/parsing/common/inference.ts b/src/parsing/common/inference.ts index 6cfa7826..a1e0237d 100644 --- a/src/parsing/common/inference.ts +++ b/src/parsing/common/inference.ts @@ -1,10 +1,10 @@ -import { StringDict } from "../common"; -import { ExtraField, Extras } from "./extras/extras"; -import { Page } from "./page"; -import type { Prediction } from "./prediction"; -import { Product } from "./product"; -import { CropperExtra, FullTextOcrExtra } from "./extras"; -import { RAGExtra } from "./extras/ragExtra"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Page } from "./page.js"; +import type { Prediction } from "./prediction.js"; +import { Product } from "./product.js"; +import { + CropperExtra, FullTextOcrExtra, ExtraField, Extras, RAGExtra +} from "./extras/index.js"; /** * @@ -108,11 +108,6 @@ export class InferenceFactory { public static getEndpoint( inferenceClass: new (httpResponse: StringDict) => T ): [string, string] { - if (inferenceClass.name === "CustomV1") { - throw new Error( - "Cannot process custom endpoint as OTS API endpoints. Please provide an endpoint name & version manually." - ); - } const emptyProduct = new inferenceClass({ prediction: {}, pages: [], diff --git a/src/parsing/common/mvisionV1.ts b/src/parsing/common/mvisionV1.ts index f95aef12..dfe6d1ed 100644 --- a/src/parsing/common/mvisionV1.ts +++ b/src/parsing/common/mvisionV1.ts @@ -1,6 +1,6 @@ -import { Word } from "../standard"; -import { StringDict } from "./stringDict"; -import { OcrPage } from "./ocrPage"; +import { Word } from "../standard/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { OcrPage } from "./ocrPage.js"; export class MvisionV1 { /** List of words found on the page. */ diff --git a/src/parsing/common/ocr.ts b/src/parsing/common/ocr.ts index 015967c9..21718519 100644 --- a/src/parsing/common/ocr.ts +++ b/src/parsing/common/ocr.ts @@ -1,5 +1,5 @@ -import { StringDict } from "./stringDict"; -import { MvisionV1 } from "./mvisionV1"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { MvisionV1 } from "./mvisionV1.js"; export class Ocr { /** Default Mindee OCR */ diff --git a/src/parsing/common/ocrPage.ts b/src/parsing/common/ocrPage.ts index b3ceacf3..b78216f8 100644 --- a/src/parsing/common/ocrPage.ts +++ b/src/parsing/common/ocrPage.ts @@ -3,9 +3,9 @@ import { compareOnY, getCentroid, isPointInPolygonY, -} from "../../geometry"; -import { Word } from "../standard"; -import { StringDict } from "./stringDict"; +} from "@/geometry/index.js"; +import { Word } from "@/parsing/standard/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class OcrPage { /** Flat list of all words read */ diff --git a/src/parsing/common/orientation.ts b/src/parsing/common/orientation.ts index f74bb6a7..19cd3da5 100644 --- a/src/parsing/common/orientation.ts +++ b/src/parsing/common/orientation.ts @@ -1,4 +1,4 @@ -import { BaseField, BaseFieldConstructor } from "../standard"; +import { BaseField, BaseFieldConstructor } from "@/parsing/standard/index.js"; interface OrientationFieldConstructor extends BaseFieldConstructor { pageId: number; diff --git a/src/parsing/common/page.ts b/src/parsing/common/page.ts index 5a592d81..7330a28d 100644 --- a/src/parsing/common/page.ts +++ b/src/parsing/common/page.ts @@ -1,8 +1,7 @@ -import { CropperExtra, FullTextOcrExtra } from "./extras"; -import { ExtraField, Extras } from "./extras/extras"; -import { OrientationField } from "./orientation"; -import { Prediction } from "./prediction"; -import { StringDict } from "./stringDict"; +import { CropperExtra, FullTextOcrExtra, ExtraField, Extras } from "./extras/index.js"; +import { OrientationField } from "./orientation.js"; +import { Prediction } from "./prediction.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** diff --git a/src/parsing/common/predictResponse.ts b/src/parsing/common/predictResponse.ts index 4aac4cc4..e0a31858 100644 --- a/src/parsing/common/predictResponse.ts +++ b/src/parsing/common/predictResponse.ts @@ -1,5 +1,7 @@ -import { ApiResponse } from "./apiResponse"; -import { Document, Inference, StringDict } from "."; +import { ApiResponse } from "./apiResponse.js"; +import { Document } from "./document.js"; +import { Inference } from "./inference.js"; +import { StringDict } from "./stringDict.js"; /** Wrapper for synchronous prediction response. * diff --git a/src/parsing/common/workflowResponse.ts b/src/parsing/common/workflowResponse.ts index b2b907fa..a82236b5 100644 --- a/src/parsing/common/workflowResponse.ts +++ b/src/parsing/common/workflowResponse.ts @@ -1,7 +1,7 @@ -import { StringDict } from "./stringDict"; -import { ApiResponse } from "./apiResponse"; -import { Execution } from "./execution"; -import { Inference } from "./inference"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { ApiResponse } from "./apiResponse.js"; +import { Execution } from "./execution.js"; +import { Inference } from "./inference.js"; /** Wrapper for workflow requests. diff --git a/src/parsing/custom/classificationField.ts b/src/parsing/custom/classificationField.ts deleted file mode 100644 index a4452b5f..00000000 --- a/src/parsing/custom/classificationField.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { StringDict } from "../common"; - -export class ClassificationField { - /** The value for the classification. */ - value: string; - /** - * The confidence score of the prediction. - * Note: Score is calculated on **word selection**, not its textual content (OCR). - */ - confidence: number; - pageId?: number; - constructor({ - prediction, - pageId, - }: { - prediction: StringDict; - pageId?: number; - }) { - this.value = prediction["value"]; - this.confidence = prediction["confidence"]; - this.pageId ??= pageId; - } - - /** - * Default string representation. - */ - toString(): string { - return `${this.value}`; - } -} diff --git a/src/parsing/custom/index.ts b/src/parsing/custom/index.ts deleted file mode 100644 index 21f65537..00000000 --- a/src/parsing/custom/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { CustomLine, CustomLines, getLineItems } from "./lineItems"; -export { ClassificationField } from "./classificationField"; -export { ListField, ListFieldValue } from "./listField"; diff --git a/src/parsing/custom/lineItems.ts b/src/parsing/custom/lineItems.ts deleted file mode 100644 index 89a9121b..00000000 --- a/src/parsing/custom/lineItems.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { errorHandler } from "../../errors/handler"; -import { MindeeError } from "../../errors"; -import { - BBox, - Polygon, - getBbox, - getBBoxForPolygons, - getMinMaxY, - mergeBbox, - getBoundingBoxFromBBox, - MinMax, -} from "../../geometry"; -import { ListField, ListFieldValue } from "./listField"; - -export class CustomLine { - /** - * Number of the current line. - * Starts at 1. - */ - rowNumber: number; - /** - * List of the fields associated to the current line, identified by their column name. - */ - fields: Map; - /** - * The BBox of the entire line, all fields included. - */ - bbox: BBox; - - constructor(rowNumber: number) { - this.rowNumber = rowNumber; - this.bbox = new BBox(1, 1, 0, 0); - this.fields = new Map(); - } - - /** - * Extends the current bbox of the line with the bbox. - */ - extendWithBbox(bbox: BBox): void { - this.bbox = mergeBbox(this.bbox, bbox); - } - - /** - * Extends the current bbox of the line with the polygon. - */ - extendWith(polygon: Polygon): void { - this.bbox = mergeBbox(this.bbox, getBbox(polygon)); - } - - updateField(name: string, fieldValue: ListFieldValue): void { - if (!this.fields.has(name)) { - this.fields.set(name, fieldValue); - } else { - const existingField = this.fields.get(name); - - if (existingField === undefined) { - errorHandler.throw( - new MindeeError(`The field '${name}' should exist but was not found.`) - ); - return; - } - - const mergedContent = - existingField?.content === undefined - ? fieldValue.content - : existingField.content + " " + fieldValue.content; - - const mergedBbox = getBBoxForPolygons([ - existingField.polygon, - fieldValue.polygon, - ]); - - this.fields.set( - name, - new ListFieldValue({ - content: mergedContent, - confidence: existingField.confidence * fieldValue.confidence, - polygon: getBoundingBoxFromBBox(mergedBbox), - }) - ); - } - } -} - -export class CustomLines extends Array {} - -/** - * Get line items from fields. - */ -export function getLineItems( - anchorNames: string[], - fieldNames: string[], - fields: Map, - heightLineTolerance: number, -): CustomLines { - const fieldsToTransformIntoLines: Map = new Map( - [...fields].filter(([k]) => fieldNames.includes(k)) - ); - - const anchorName: string = findBestAnchor(anchorNames, fieldsToTransformIntoLines); - const linesPrepared: CustomLine[] = prepare( - anchorName, - fieldsToTransformIntoLines, - heightLineTolerance - ); - - linesPrepared.forEach((currentLine) => { - fieldsToTransformIntoLines.forEach((field, fieldName) => { - field.values.forEach((listFieldValue) => { - const minMaxY: MinMax = getMinMaxY(listFieldValue.polygon); - if ( - Math.abs(minMaxY.max - currentLine.bbox.yMax) <= heightLineTolerance && - Math.abs(minMaxY.min - currentLine.bbox.yMin) <= heightLineTolerance - ) { - currentLine.updateField(fieldName, listFieldValue); - } - }); - }); - }); - return linesPrepared; -} - -/** - * Loop through the possible anchor fields and find the one with the most values. - */ -function findBestAnchor( - possibleAnchorNames: string[], - fields: Map -): string { - let anchorName = ""; - let anchorRows = 0; - - possibleAnchorNames.forEach((fieldName) => { - const fieldValues: ListFieldValue[]|undefined = fields.get(fieldName)?.values; - if (fieldValues !== undefined && fieldValues.length > anchorRows) { - anchorRows = fieldValues.length; - anchorName = fieldName; - } - }); - - if (anchorName === "") { - errorHandler.throw(new MindeeError("No anchor was found.")); - } - - return anchorName; -} - -/** - * Check if the bbox fits inside the line. - */ -function isBboxInLine(line: CustomLine, bbox: BBox, heightTolerance: number): boolean { - if (Math.abs(bbox.yMin - line.bbox.yMin) <= heightTolerance) { - return true; - } - return Math.abs(line.bbox.yMin - bbox.yMin) <= heightTolerance; -} - -function prepare( - anchorName: string, - fields: Map, - heightLineTolerance: number -): CustomLine[] { - const linesPrepared: CustomLine[] = []; - - const anchorField = fields.get(anchorName); - if (anchorField === undefined || anchorField.values.length === 0) { - errorHandler.throw(new MindeeError("No lines have been detected.")); - } - - let currentLineNumber: number = 1; - let currentLine: CustomLine = new CustomLine(currentLineNumber); - - if (anchorField !== undefined) { - let currentValue: ListFieldValue = anchorField.values[0]; - currentLine.extendWith(currentValue.polygon); - - for (let index = 1; index < anchorField.values.length; index++) { - currentValue = anchorField.values[index]; - const currentFieldBbox = getBbox(currentValue.polygon); - - if (!isBboxInLine(currentLine, currentFieldBbox, heightLineTolerance)) { - linesPrepared.push(currentLine); - currentLineNumber++; - currentLine = new CustomLine(currentLineNumber); - } - currentLine.extendWithBbox(currentFieldBbox); - } - - if ( - linesPrepared.filter((line) => line.rowNumber === currentLineNumber) - .length === 0 - ) { - linesPrepared.push(currentLine); - } - } - - return linesPrepared; -} diff --git a/src/parsing/custom/listField.ts b/src/parsing/custom/listField.ts deleted file mode 100644 index f961fa21..00000000 --- a/src/parsing/custom/listField.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { BaseFieldConstructor } from "../standard"; -import { Polygon, getBoundingBox, BoundingBox } from "../../geometry"; -import { StringDict } from "../common"; - -export class ListFieldValue { - /** Extracted content of the prediction */ - content: string; - /** - * The confidence score of the prediction. - * Note: Score is calculated on **word selection**, not its textual content (OCR). - */ - confidence: number; - /** - * Contains exactly 4 relative vertices coordinates (points) of a right - * rectangle containing the word in the document. - */ - bbox?: BoundingBox; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the word in the document. - */ - polygon: Polygon = new Polygon(); - /** The document page on which the information was found. */ - pageId?: number; - - constructor(prediction: StringDict, pageId?: number) { - this.content = prediction["content"]; - this.confidence = prediction["confidence"]; - if (prediction["polygon"]) { - this.polygon = prediction["polygon"]; - this.bbox = getBoundingBox(prediction["polygon"]); - } - if (pageId !== undefined) { - this.pageId = pageId; - } - } - - /** - * Default string representation. - */ - toString(): string { - return `${this.content}`; - } -} - -export class ListField { - readonly values: ListFieldValue[]; - confidence: number; - /** True if the field was reconstructed or computed using other fields. */ - reconstructed: boolean; - - /** - * @param {BaseFieldConstructor} constructor Constructor parameters. - */ - constructor({ - prediction = {}, - reconstructed = false, - pageId, - }: BaseFieldConstructor) { - this.values = []; - this.confidence = prediction["confidence"]; - this.reconstructed = reconstructed; - - if (prediction["values"] !== undefined) { - prediction["values"].forEach((field: StringDict) => { - if (pageId === undefined) { - pageId = field["page_id"]; - } - this.values.push(new ListFieldValue(field, pageId)); - }); - } - } - - contentsList(): Array { - return this.values.map((item) => item.content); - } - - contentsString(separator: string = " "): string { - return this.values.map((item) => `${item.content}`).join(separator); - } - - /** - * Default string representation. - */ - toString(): string { - return this.contentsString(); - } -} diff --git a/src/parsing/generated/generatedList.ts b/src/parsing/generated/generatedList.ts index f225ae33..819f1e6f 100644 --- a/src/parsing/generated/generatedList.ts +++ b/src/parsing/generated/generatedList.ts @@ -1,6 +1,6 @@ -import { StringDict } from "../common"; -import { StringField } from "../standard"; -import { GeneratedObjectField, isGeneratedObject } from "./generatedObject"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringField } from "@/parsing/standard/index.js"; +import { GeneratedObjectField, isGeneratedObject } from "./generatedObject.js"; export interface GeneratedListFieldConstructor { prediction: StringDict[]; diff --git a/src/parsing/generated/generatedObject.ts b/src/parsing/generated/generatedObject.ts index 0e989664..582d444b 100644 --- a/src/parsing/generated/generatedObject.ts +++ b/src/parsing/generated/generatedObject.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { BaseFieldConstructor, PositionField } from "../standard"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { BaseFieldConstructor, PositionField } from "@/parsing/standard/index.js"; /** A JSON-like object, with miscellaneous values. */ diff --git a/src/parsing/generated/index.ts b/src/parsing/generated/index.ts index 258cd302..cc6ab17b 100644 --- a/src/parsing/generated/index.ts +++ b/src/parsing/generated/index.ts @@ -1,2 +1,2 @@ -export { GeneratedObjectField, isGeneratedObject } from "./generatedObject"; -export { GeneratedListField } from "./generatedList"; +export { GeneratedObjectField, isGeneratedObject } from "./generatedObject.js"; +export { GeneratedListField } from "./generatedList.js"; diff --git a/src/parsing/index.ts b/src/parsing/index.ts index 6960d97b..d854428f 100644 --- a/src/parsing/index.ts +++ b/src/parsing/index.ts @@ -1,5 +1,4 @@ -export * as common from "./common"; -export * as custom from "./custom"; -export * as standard from "./standard"; -export * as generated from "./generated"; -export * as v2 from "./v2"; +export * as common from "./common/index.js"; +export * as standard from "./standard/index.js"; +export * as generated from "./generated/index.js"; +export * as v2 from "./v2/index.js"; diff --git a/src/parsing/standard/addressField.ts b/src/parsing/standard/addressField.ts index f8b4901d..bacbdbc0 100644 --- a/src/parsing/standard/addressField.ts +++ b/src/parsing/standard/addressField.ts @@ -1,4 +1,4 @@ -import { StringField, FieldConstructor } from "./text"; +import { StringField, FieldConstructor } from "./text.js"; /** * A field containing a detailed address value broken down into components diff --git a/src/parsing/standard/amount.ts b/src/parsing/standard/amount.ts index 1976555c..135aeea3 100644 --- a/src/parsing/standard/amount.ts +++ b/src/parsing/standard/amount.ts @@ -1,6 +1,6 @@ -import { Field } from "./field"; -import { BaseFieldConstructor } from "./base"; -import { floatToString } from "../common"; +import { Field } from "./field.js"; +import { BaseFieldConstructor } from "./base.js"; +import { floatToString } from "@/parsing/common/index.js"; /** * A field containing an amount value. diff --git a/src/parsing/standard/base.ts b/src/parsing/standard/base.ts index b0339d48..cd23901a 100644 --- a/src/parsing/standard/base.ts +++ b/src/parsing/standard/base.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * @property {object} prediction - Prediction object from HTTP response. diff --git a/src/parsing/standard/boolean.ts b/src/parsing/standard/boolean.ts index 83a767ae..e490b3b7 100644 --- a/src/parsing/standard/boolean.ts +++ b/src/parsing/standard/boolean.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { Field } from "./field"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Field } from "./field.js"; export interface FieldConstructor { prediction: StringDict; diff --git a/src/parsing/standard/classification.ts b/src/parsing/standard/classification.ts index 865f22bd..d33cdfbb 100644 --- a/src/parsing/standard/classification.ts +++ b/src/parsing/standard/classification.ts @@ -1,4 +1,4 @@ -import { BaseField, BaseFieldConstructor } from "./base"; +import { BaseField, BaseFieldConstructor } from "./base.js"; /** * Represents a classifier value. diff --git a/src/parsing/standard/companyRegistration.ts b/src/parsing/standard/companyRegistration.ts index b315f9ac..69d46223 100644 --- a/src/parsing/standard/companyRegistration.ts +++ b/src/parsing/standard/companyRegistration.ts @@ -1,6 +1,6 @@ -import { Field } from "./field"; -import { BaseFieldConstructor } from "./base"; -import { cleanOutString } from "../common"; +import { Field } from "./field.js"; +import { BaseFieldConstructor } from "./base.js"; +import { cleanOutString } from "@/parsing/common/index.js"; /** * A company registration item. diff --git a/src/parsing/standard/date.ts b/src/parsing/standard/date.ts index ff295910..f7b18e31 100644 --- a/src/parsing/standard/date.ts +++ b/src/parsing/standard/date.ts @@ -1,5 +1,5 @@ -import { Field } from "./field"; -import { BaseFieldConstructor } from "./base"; +import { Field } from "./field.js"; +import { BaseFieldConstructor } from "./base.js"; /** * A field containing a date value. diff --git a/src/parsing/standard/field.ts b/src/parsing/standard/field.ts index 2fe81230..7bb34c6f 100644 --- a/src/parsing/standard/field.ts +++ b/src/parsing/standard/field.ts @@ -1,5 +1,5 @@ -import { BaseField, BaseFieldConstructor } from "./base"; -import { Polygon, BoundingBox, getBoundingBox } from "../../geometry"; +import { BaseField, BaseFieldConstructor } from "./base.js"; +import { Polygon, BoundingBox, getBoundingBox } from "@/geometry/index.js"; /** * A basic field with position and page information. diff --git a/src/parsing/standard/index.ts b/src/parsing/standard/index.ts index a04b929d..19a4b41a 100644 --- a/src/parsing/standard/index.ts +++ b/src/parsing/standard/index.ts @@ -1,14 +1,15 @@ -export { AddressField } from "./addressField"; -export { AmountField } from "./amount"; -export { BaseField, BaseFieldConstructor } from "./base"; -export { BooleanField } from "./boolean"; -export { ClassificationField } from "./classification"; -export { CompanyRegistrationField } from "./companyRegistration"; -export { DateField } from "./date"; -export { LocaleField } from "./locale"; -export { Field } from "./field"; -export { Taxes, TaxField } from "./tax"; -export { StringField } from "./text"; -export { PaymentDetailsField } from "./paymentDetails"; -export { PositionField } from "./position"; -export { Word } from "./word"; +export { AddressField } from "./addressField.js"; +export { AmountField } from "./amount.js"; +export { BaseField } from "./base.js"; +export type { BaseFieldConstructor } from "./base.js"; +export { BooleanField } from "./boolean.js"; +export { ClassificationField } from "./classification.js"; +export { CompanyRegistrationField } from "./companyRegistration.js"; +export { DateField } from "./date.js"; +export { LocaleField } from "./locale.js"; +export { Field } from "./field.js"; +export { Taxes, TaxField } from "./tax.js"; +export { StringField } from "./text.js"; +export { PaymentDetailsField } from "./paymentDetails.js"; +export { PositionField } from "./position.js"; +export type { Word } from "./word.js"; diff --git a/src/parsing/standard/locale.ts b/src/parsing/standard/locale.ts index 02a49a15..f5a41ba5 100644 --- a/src/parsing/standard/locale.ts +++ b/src/parsing/standard/locale.ts @@ -1,4 +1,4 @@ -import { BaseField, BaseFieldConstructor } from "./base"; +import { BaseField, BaseFieldConstructor } from "./base.js"; /** * The locale detected on the document. diff --git a/src/parsing/standard/paymentDetails.ts b/src/parsing/standard/paymentDetails.ts index d412d02f..c1c06c46 100644 --- a/src/parsing/standard/paymentDetails.ts +++ b/src/parsing/standard/paymentDetails.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { Field } from "./field"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Field } from "./field.js"; /** * @property {StringDict} constructor.prediction - Prediction object from HTTP response diff --git a/src/parsing/standard/position.ts b/src/parsing/standard/position.ts index a9835f7e..23b88fc6 100644 --- a/src/parsing/standard/position.ts +++ b/src/parsing/standard/position.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { Polygon } from "../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; export interface PositionFieldConstructor { prediction: StringDict; diff --git a/src/parsing/standard/tax.ts b/src/parsing/standard/tax.ts index 316c877f..25707551 100644 --- a/src/parsing/standard/tax.ts +++ b/src/parsing/standard/tax.ts @@ -1,6 +1,6 @@ -import { floatToString, StringDict } from "../common"; -import { Field } from "./field"; -import { BaseFieldConstructor } from "./base"; +import { floatToString, StringDict } from "@/parsing/common/index.js"; +import { Field } from "./field.js"; +import { BaseFieldConstructor } from "./base.js"; /** * @property {string} constructor.rateKey - Key to use to get the tax rate in the prediction dict. diff --git a/src/parsing/standard/text.ts b/src/parsing/standard/text.ts index 6fe97c58..014f92f7 100644 --- a/src/parsing/standard/text.ts +++ b/src/parsing/standard/text.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { Field } from "./field"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Field } from "./field.js"; export interface FieldConstructor { prediction: StringDict; diff --git a/src/parsing/standard/word.ts b/src/parsing/standard/word.ts index 9b66ba31..cb093b0a 100644 --- a/src/parsing/standard/word.ts +++ b/src/parsing/standard/word.ts @@ -1,4 +1,4 @@ -import * as geometry from "../../geometry"; +import * as geometry from "@/geometry/index.js"; export type Word = { /** diff --git a/src/parsing/v2/commonResponse.ts b/src/parsing/v2/commonResponse.ts index 824f3e6b..f6ab596a 100644 --- a/src/parsing/v2/commonResponse.ts +++ b/src/parsing/v2/commonResponse.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; export abstract class CommonResponse { diff --git a/src/parsing/v2/dataSchemaActiveOption.ts b/src/parsing/v2/dataSchemaActiveOption.ts index ded79271..d804aeff 100644 --- a/src/parsing/v2/dataSchemaActiveOption.ts +++ b/src/parsing/v2/dataSchemaActiveOption.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Data schema options activated during the inference. diff --git a/src/parsing/v2/errorItem.ts b/src/parsing/v2/errorItem.ts index b66f4956..63cae233 100644 --- a/src/parsing/v2/errorItem.ts +++ b/src/parsing/v2/errorItem.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Explicit details on a problem. diff --git a/src/parsing/v2/errorResponse.ts b/src/parsing/v2/errorResponse.ts index d23afec3..17de3b3e 100644 --- a/src/parsing/v2/errorResponse.ts +++ b/src/parsing/v2/errorResponse.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { ErrorItem } from "./errorItem"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { ErrorItem } from "./errorItem.js"; export interface ErrorDetails { /** diff --git a/src/parsing/v2/field/baseField.ts b/src/parsing/v2/field/baseField.ts index 7d1f1eca..4af5c38f 100644 --- a/src/parsing/v2/field/baseField.ts +++ b/src/parsing/v2/field/baseField.ts @@ -1,6 +1,6 @@ -import { FieldConfidence } from "./fieldConfidence"; -import { StringDict } from "../../common"; -import { FieldLocation } from "./fieldLocation"; +import { FieldConfidence } from "./fieldConfidence.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { FieldLocation } from "./fieldLocation.js"; export abstract class BaseField { protected _indentLevel: number; diff --git a/src/parsing/v2/field/fieldFactory.ts b/src/parsing/v2/field/fieldFactory.ts index afc2e46f..aa42bc43 100644 --- a/src/parsing/v2/field/fieldFactory.ts +++ b/src/parsing/v2/field/fieldFactory.ts @@ -1,11 +1,11 @@ /** * Factory helper. */ -import { StringDict } from "../../common"; -import { MindeeApiV2Error } from "../../../errors/mindeeError"; -import { ListField } from "./listField"; -import { ObjectField } from "./objectField"; -import { SimpleField } from "./simpleField"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { MindeeApiV2Error } from "@/errors/index.js"; +import { ListField } from "./listField.js"; +import { ObjectField } from "./objectField.js"; +import { SimpleField } from "./simpleField.js"; export function createField(serverResponse: StringDict, indentLevel = 0) { if (typeof serverResponse !== "object" || serverResponse === null) { diff --git a/src/parsing/v2/field/fieldLocation.ts b/src/parsing/v2/field/fieldLocation.ts index 9a291d96..95b5fd3f 100644 --- a/src/parsing/v2/field/fieldLocation.ts +++ b/src/parsing/v2/field/fieldLocation.ts @@ -1,5 +1,5 @@ -import { Polygon } from "../../../geometry"; -import { StringDict } from "../../common"; +import { Polygon } from "@/geometry/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; /** * Location of a field. diff --git a/src/parsing/v2/field/index.ts b/src/parsing/v2/field/index.ts index bfbd648f..7b4a651e 100644 --- a/src/parsing/v2/field/index.ts +++ b/src/parsing/v2/field/index.ts @@ -1,6 +1,6 @@ -export { InferenceFields } from "./inferenceFields"; -export { FieldConfidence } from "./fieldConfidence"; -export { FieldLocation } from "./fieldLocation"; -export { ListField } from "./listField"; -export { ObjectField } from "./objectField"; -export { SimpleField } from "./simpleField"; +export { InferenceFields } from "./inferenceFields.js"; +export { FieldConfidence } from "./fieldConfidence.js"; +export { FieldLocation } from "./fieldLocation.js"; +export { ListField } from "./listField.js"; +export { ObjectField } from "./objectField.js"; +export { SimpleField } from "./simpleField.js"; diff --git a/src/parsing/v2/field/inferenceFields.ts b/src/parsing/v2/field/inferenceFields.ts index d2f92c11..4c66ad8a 100644 --- a/src/parsing/v2/field/inferenceFields.ts +++ b/src/parsing/v2/field/inferenceFields.ts @@ -1,8 +1,8 @@ -import { StringDict } from "../../common"; -import type { ListField } from "./listField"; -import type { ObjectField } from "./objectField"; -import type { SimpleField } from "./simpleField"; -import { createField } from "./fieldFactory"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import type { ListField } from "./listField.js"; +import type { ObjectField } from "./objectField.js"; +import type { SimpleField } from "./simpleField.js"; +import { createField } from "./fieldFactory.js"; export class InferenceFields extends Map { diff --git a/src/parsing/v2/field/listField.ts b/src/parsing/v2/field/listField.ts index 160a395a..f51a925e 100644 --- a/src/parsing/v2/field/listField.ts +++ b/src/parsing/v2/field/listField.ts @@ -1,9 +1,9 @@ -import { MindeeApiV2Error } from "../../../errors/mindeeError"; -import { StringDict } from "../../common"; -import { BaseField } from "./baseField"; -import { ObjectField } from "./objectField"; -import { SimpleField } from "./simpleField"; -import { createField } from "./fieldFactory"; +import { MindeeApiV2Error } from "@/errors/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { BaseField } from "./baseField.js"; +import { ObjectField } from "./objectField.js"; +import { SimpleField } from "./simpleField.js"; +import { createField } from "./fieldFactory.js"; export class ListField extends BaseField { /** diff --git a/src/parsing/v2/field/objectField.ts b/src/parsing/v2/field/objectField.ts index 20dc0e6a..a5920ca9 100644 --- a/src/parsing/v2/field/objectField.ts +++ b/src/parsing/v2/field/objectField.ts @@ -1,7 +1,7 @@ -import { InferenceFields } from "./inferenceFields"; -import { StringDict } from "../../common"; -import { BaseField } from "./baseField"; -import type { SimpleField } from "./simpleField"; +import { InferenceFields } from "./inferenceFields.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { BaseField } from "./baseField.js"; +import type { SimpleField } from "./simpleField.js"; export class ObjectField extends BaseField { readonly fields: InferenceFields; diff --git a/src/parsing/v2/field/simpleField.ts b/src/parsing/v2/field/simpleField.ts index 78a1ae4e..2779e9bb 100644 --- a/src/parsing/v2/field/simpleField.ts +++ b/src/parsing/v2/field/simpleField.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../common"; -import { BaseField } from "./baseField"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { BaseField } from "./baseField.js"; export class SimpleField extends BaseField { readonly value: string | number | boolean | null; diff --git a/src/parsing/v2/index.ts b/src/parsing/v2/index.ts index b459c00c..e5e212bb 100644 --- a/src/parsing/v2/index.ts +++ b/src/parsing/v2/index.ts @@ -1,14 +1,15 @@ -export { CommonResponse } from "./commonResponse"; -export { ErrorResponse, ErrorDetails } from "./errorResponse"; -export { ErrorItem } from "./errorItem"; -export { Inference } from "./inference"; -export { InferenceActiveOptions } from "./inferenceActiveOptions"; -export { InferenceFile } from "./inferenceFile"; -export { InferenceModel } from "./inferenceModel"; -export { InferenceResponse } from "./inferenceResponse"; -export { InferenceResult } from "./inferenceResult"; -export { Job } from "./job"; -export { JobResponse } from "./jobResponse"; -export { RawText } from "./rawText"; -export { JobWebhook } from "./jobWebhook"; -export { RagMetadata } from "./ragMetadata"; +export { CommonResponse } from "./commonResponse.js"; +export { ErrorResponse } from "./errorResponse.js"; +export type { ErrorDetails } from "./errorResponse.js"; +export { ErrorItem } from "./errorItem.js"; +export { Inference } from "./inference.js"; +export { InferenceActiveOptions } from "./inferenceActiveOptions.js"; +export { InferenceFile } from "./inferenceFile.js"; +export { InferenceModel } from "./inferenceModel.js"; +export { InferenceResponse } from "./inferenceResponse.js"; +export { InferenceResult } from "./inferenceResult.js"; +export { Job } from "./job.js"; +export { JobResponse } from "./jobResponse.js"; +export { RawText } from "./rawText.js"; +export { JobWebhook } from "./jobWebhook.js"; +export { RagMetadata } from "./ragMetadata.js"; diff --git a/src/parsing/v2/inference.ts b/src/parsing/v2/inference.ts index 34006575..aa8b8e4b 100644 --- a/src/parsing/v2/inference.ts +++ b/src/parsing/v2/inference.ts @@ -1,8 +1,8 @@ -import { StringDict } from "../common"; -import { InferenceModel } from "./inferenceModel"; -import { InferenceResult } from "./inferenceResult"; -import { InferenceFile } from "./inferenceFile"; -import { InferenceActiveOptions } from "./inferenceActiveOptions"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { InferenceModel } from "./inferenceModel.js"; +import { InferenceResult } from "./inferenceResult.js"; +import { InferenceFile } from "./inferenceFile.js"; +import { InferenceActiveOptions } from "./inferenceActiveOptions.js"; export class Inference { /** diff --git a/src/parsing/v2/inferenceActiveOptions.ts b/src/parsing/v2/inferenceActiveOptions.ts index 5223dd02..6f23a712 100644 --- a/src/parsing/v2/inferenceActiveOptions.ts +++ b/src/parsing/v2/inferenceActiveOptions.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { DataSchemaActiveOption } from "./dataSchemaActiveOption"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { DataSchemaActiveOption } from "./dataSchemaActiveOption.js"; export class InferenceActiveOptions { /** diff --git a/src/parsing/v2/inferenceFile.ts b/src/parsing/v2/inferenceFile.ts index 8e9998f4..4c95edb1 100644 --- a/src/parsing/v2/inferenceFile.ts +++ b/src/parsing/v2/inferenceFile.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class InferenceFile { /** diff --git a/src/parsing/v2/inferenceModel.ts b/src/parsing/v2/inferenceModel.ts index 6577f1dc..15e9adb7 100644 --- a/src/parsing/v2/inferenceModel.ts +++ b/src/parsing/v2/inferenceModel.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class InferenceModel { /** diff --git a/src/parsing/v2/inferenceResponse.ts b/src/parsing/v2/inferenceResponse.ts index 3e6a55e8..6020a567 100644 --- a/src/parsing/v2/inferenceResponse.ts +++ b/src/parsing/v2/inferenceResponse.ts @@ -1,6 +1,6 @@ -import { CommonResponse } from "./commonResponse"; -import { Inference } from "./inference"; -import { StringDict } from "../common"; +import { CommonResponse } from "./commonResponse.js"; +import { Inference } from "./inference.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class InferenceResponse extends CommonResponse { /** diff --git a/src/parsing/v2/inferenceResult.ts b/src/parsing/v2/inferenceResult.ts index 1468234f..5ce3964e 100644 --- a/src/parsing/v2/inferenceResult.ts +++ b/src/parsing/v2/inferenceResult.ts @@ -1,7 +1,7 @@ -import { InferenceFields } from "./field"; -import { StringDict } from "../common"; -import { RawText } from "./rawText"; -import { RagMetadata } from "./ragMetadata"; +import { InferenceFields } from "./field/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { RawText } from "./rawText.js"; +import { RagMetadata } from "./ragMetadata.js"; export class InferenceResult { /** diff --git a/src/parsing/v2/job.ts b/src/parsing/v2/job.ts index 7b77349b..738c6cb5 100644 --- a/src/parsing/v2/job.ts +++ b/src/parsing/v2/job.ts @@ -1,7 +1,7 @@ -import { StringDict } from "../common"; -import { ErrorResponse } from "./errorResponse"; -import { JobWebhook } from "./jobWebhook"; -import { parseDate } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { ErrorResponse } from "./errorResponse.js"; +import { JobWebhook } from "./jobWebhook.js"; +import { parseDate } from "@/parsing/common/index.js"; /** * Job information for a V2 polling attempt. diff --git a/src/parsing/v2/jobResponse.ts b/src/parsing/v2/jobResponse.ts index f8405ae1..85d0794d 100644 --- a/src/parsing/v2/jobResponse.ts +++ b/src/parsing/v2/jobResponse.ts @@ -1,6 +1,6 @@ -import { CommonResponse } from "./commonResponse"; -import { StringDict } from "../common"; -import { Job } from "./job"; +import { CommonResponse } from "./commonResponse.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Job } from "./job.js"; export class JobResponse extends CommonResponse { /** diff --git a/src/parsing/v2/jobWebhook.ts b/src/parsing/v2/jobWebhook.ts index 399b333b..e499dc2d 100644 --- a/src/parsing/v2/jobWebhook.ts +++ b/src/parsing/v2/jobWebhook.ts @@ -1,5 +1,5 @@ -import { ErrorResponse } from "./errorResponse"; -import { StringDict, parseDate } from "../common"; +import { ErrorResponse } from "./errorResponse.js"; +import { StringDict, parseDate } from "@/parsing/common/index.js"; /** * JobWebhook information. diff --git a/src/parsing/v2/ragMetadata.ts b/src/parsing/v2/ragMetadata.ts index 0195b7d4..1c78bf95 100644 --- a/src/parsing/v2/ragMetadata.ts +++ b/src/parsing/v2/ragMetadata.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class RagMetadata { /** diff --git a/src/parsing/v2/rawText.ts b/src/parsing/v2/rawText.ts index d1241394..c6a7874a 100644 --- a/src/parsing/v2/rawText.ts +++ b/src/parsing/v2/rawText.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../common"; -import { RawTextPage } from "./rawTextPage"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { RawTextPage } from "./rawTextPage.js"; export class RawText { /** diff --git a/src/parsing/v2/rawTextPage.ts b/src/parsing/v2/rawTextPage.ts index df5c3e76..646881f1 100644 --- a/src/parsing/v2/rawTextPage.ts +++ b/src/parsing/v2/rawTextPage.ts @@ -1,4 +1,4 @@ -import { StringDict } from "../common"; +import { StringDict } from "@/parsing/common/stringDict.js"; export class RawTextPage { /** diff --git a/src/pdf/index.ts b/src/pdf/index.ts index 9c57e895..752c5ffd 100644 --- a/src/pdf/index.ts +++ b/src/pdf/index.ts @@ -1,3 +1,4 @@ -export { extractPages, countPages, SplitPdf } from "./pdfOperation"; -export { compressPdf } from "./pdfCompressor"; -export { hasSourceText } from "./pdfUtils"; +export { extractPages, countPages } from "./pdfOperation.js"; +export type { SplitPdf } from "./pdfOperation.js"; +export { compressPdf } from "./pdfCompressor.js"; +export { hasSourceText } from "./pdfUtils.js"; diff --git a/src/pdf/pdfCompressor.ts b/src/pdf/pdfCompressor.ts index d9dae77a..32409017 100644 --- a/src/pdf/pdfCompressor.ts +++ b/src/pdf/pdfCompressor.ts @@ -1,10 +1,10 @@ -import { logger } from "../logger"; +import { logger } from "@/logger.js"; import tmp from "tmp"; -import { ExtractedPdfInfo, extractTextFromPdf, hasSourceText } from "./pdfUtils"; +import { ExtractedPdfInfo, extractTextFromPdf, hasSourceText } from "./pdfUtils.js"; import * as fs from "node:fs"; import { Poppler } from "node-poppler"; import { PDFDocument, PDFFont, PDFPage, rgb, StandardFonts } from "@cantoo/pdf-lib"; -import { compressImage } from "../imageOperations"; +import { compressImage } from "@/imageOperations/imageCompressor.js"; /** * Compresses each page of a provided PDF buffer. diff --git a/src/pdf/pdfOperation.ts b/src/pdf/pdfOperation.ts index 50999812..d4b48e4b 100644 --- a/src/pdf/pdfOperation.ts +++ b/src/pdf/pdfOperation.ts @@ -1,8 +1,8 @@ -import { errorHandler } from "../errors/handler"; +import { errorHandler } from "@/errors/handler.js"; import { PDFDocument } from "@cantoo/pdf-lib"; -import { PageOptions, PageOptionsOperation } from "../input"; -import { MindeeError } from "../errors"; -import { logger } from "../logger"; +import { PageOptions, PageOptionsOperation } from "@/input/pageOptions.js"; +import { MindeeError } from "@/errors/index.js"; +import { logger } from "@/logger.js"; export interface SplitPdf { file: Buffer; diff --git a/src/pdf/pdfUtils.ts b/src/pdf/pdfUtils.ts index 3618d9f9..4aa83758 100644 --- a/src/pdf/pdfUtils.ts +++ b/src/pdf/pdfUtils.ts @@ -1,5 +1,5 @@ import { PDFExtract, PDFExtractOptions, PDFExtractResult } from "pdf.js-extract"; -import { MindeePdfError } from "../errors/mindeeError"; +import { MindeePdfError } from "@/errors/index.js"; export interface PageTextInfo { diff --git a/src/product/barcodeReader/barcodeReaderV1.ts b/src/product/barcodeReader/barcodeReaderV1.ts index a804105e..37aceb25 100644 --- a/src/product/barcodeReader/barcodeReaderV1.ts +++ b/src/product/barcodeReader/barcodeReaderV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { BarcodeReaderV1Document } from "./barcodeReaderV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { BarcodeReaderV1Document } from "./barcodeReaderV1Document.js"; /** * Barcode Reader API version 1 inference prediction. diff --git a/src/product/barcodeReader/barcodeReaderV1Document.ts b/src/product/barcodeReader/barcodeReaderV1Document.ts index 0b381956..b0d9f4d5 100644 --- a/src/product/barcodeReader/barcodeReaderV1Document.ts +++ b/src/product/barcodeReader/barcodeReaderV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../parsing/common"; -import { StringField } from "../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { StringField } from "@/parsing/standard/index.js"; /** * Barcode Reader API version 1.0 document data. diff --git a/src/product/barcodeReader/index.ts b/src/product/barcodeReader/index.ts index 58042c9a..5917e148 100644 --- a/src/product/barcodeReader/index.ts +++ b/src/product/barcodeReader/index.ts @@ -1 +1,2 @@ -export { BarcodeReaderV1 } from "./barcodeReaderV1"; +export { BarcodeReaderV1 } from "./barcodeReaderV1.js"; +export { BarcodeReaderV1Document } from "./barcodeReaderV1Document.js"; diff --git a/src/product/barcodeReader/internal.ts b/src/product/barcodeReader/internal.ts deleted file mode 100644 index e37102d3..00000000 --- a/src/product/barcodeReader/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { BarcodeReaderV1 } from "./barcodeReaderV1"; -export { BarcodeReaderV1Document } from "./barcodeReaderV1Document"; diff --git a/src/product/billOfLading/billOfLadingV1.ts b/src/product/billOfLading/billOfLadingV1.ts deleted file mode 100644 index 7cecccd1..00000000 --- a/src/product/billOfLading/billOfLadingV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { BillOfLadingV1Document } from "./billOfLadingV1Document"; - -/** - * Bill of Lading API version 1 inference prediction. - */ -export class BillOfLadingV1 extends Inference { - /** The endpoint's name. */ - endpointName = "bill_of_lading"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: BillOfLadingV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new BillOfLadingV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - BillOfLadingV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/billOfLading/billOfLadingV1Carrier.ts b/src/product/billOfLading/billOfLadingV1Carrier.ts deleted file mode 100644 index 4506be10..00000000 --- a/src/product/billOfLading/billOfLadingV1Carrier.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The shipping company responsible for transporting the goods. - */ -export class BillOfLadingV1Carrier { - /** The name of the carrier. */ - name: string | null; - /** The professional number of the carrier. */ - professionalNumber: string | null; - /** The Standard Carrier Alpha Code (SCAC) of the carrier. */ - scac: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.name = prediction["name"]; - this.professionalNumber = prediction["professional_number"]; - this.scac = prediction["scac"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - name: this.name ?? "", - professionalNumber: this.professionalNumber ?? "", - scac: this.scac ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Name: " + - printable.name + - ", Professional Number: " + - printable.professionalNumber + - ", SCAC: " + - printable.scac - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Name: ${printable.name} - :Professional Number: ${printable.professionalNumber} - :SCAC: ${printable.scac}`.trimEnd(); - } -} diff --git a/src/product/billOfLading/billOfLadingV1CarrierItem.ts b/src/product/billOfLading/billOfLadingV1CarrierItem.ts deleted file mode 100644 index 045d63de..00000000 --- a/src/product/billOfLading/billOfLadingV1CarrierItem.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { cleanSpecialChars, floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The goods being shipped. - */ -export class BillOfLadingV1CarrierItem { - /** A description of the item. */ - description: string | null; - /** The gross weight of the item. */ - grossWeight: number | null; - /** The measurement of the item. */ - measurement: number | null; - /** The unit of measurement for the measurement. */ - measurementUnit: string | null; - /** The quantity of the item being shipped. */ - quantity: number | null; - /** The unit of measurement for weights. */ - weightUnit: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.description = prediction["description"]; - if ( - prediction["gross_weight"] !== undefined && - prediction["gross_weight"] !== null && - !isNaN(prediction["gross_weight"]) - ) { - this.grossWeight = +parseFloat(prediction["gross_weight"]); - } else { - this.grossWeight = null; - } - if ( - prediction["measurement"] !== undefined && - prediction["measurement"] !== null && - !isNaN(prediction["measurement"]) - ) { - this.measurement = +parseFloat(prediction["measurement"]); - } else { - this.measurement = null; - } - this.measurementUnit = prediction["measurement_unit"]; - if ( - prediction["quantity"] !== undefined && - prediction["quantity"] !== null && - !isNaN(prediction["quantity"]) - ) { - this.quantity = +parseFloat(prediction["quantity"]); - } else { - this.quantity = null; - } - this.weightUnit = prediction["weight_unit"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - description: this.description ? - this.description.length <= 36 ? - cleanSpecialChars(this.description) : - cleanSpecialChars(this.description).slice(0, 33) + "..." : - "", - grossWeight: - this.grossWeight !== undefined ? floatToString(this.grossWeight) : "", - measurement: - this.measurement !== undefined ? floatToString(this.measurement) : "", - measurementUnit: this.measurementUnit ? - this.measurementUnit.length <= 16 ? - cleanSpecialChars(this.measurementUnit) : - cleanSpecialChars(this.measurementUnit).slice(0, 13) + "..." : - "", - quantity: this.quantity !== undefined ? floatToString(this.quantity) : "", - weightUnit: this.weightUnit ? - this.weightUnit.length <= 11 ? - cleanSpecialChars(this.weightUnit) : - cleanSpecialChars(this.weightUnit).slice(0, 8) + "..." : - "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Description: " + - printable.description + - ", Gross Weight: " + - printable.grossWeight + - ", Measurement: " + - printable.measurement + - ", Measurement Unit: " + - printable.measurementUnit + - ", Quantity: " + - printable.quantity + - ", Weight Unit: " + - printable.weightUnit - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.description.padEnd(36) + - " | " + - printable.grossWeight.padEnd(12) + - " | " + - printable.measurement.padEnd(11) + - " | " + - printable.measurementUnit.padEnd(16) + - " | " + - printable.quantity.padEnd(8) + - " | " + - printable.weightUnit.padEnd(11) + - " |" - ); - } -} diff --git a/src/product/billOfLading/billOfLadingV1Consignee.ts b/src/product/billOfLading/billOfLadingV1Consignee.ts deleted file mode 100644 index 5807ca79..00000000 --- a/src/product/billOfLading/billOfLadingV1Consignee.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The party to whom the goods are being shipped. - */ -export class BillOfLadingV1Consignee { - /** The address of the consignee. */ - address: string | null; - /** The email of the shipper. */ - email: string | null; - /** The name of the consignee. */ - name: string | null; - /** The phone number of the consignee. */ - phone: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.email = prediction["email"]; - this.name = prediction["name"]; - this.phone = prediction["phone"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - email: this.email ?? "", - name: this.name ?? "", - phone: this.phone ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Email: " + - printable.email + - ", Name: " + - printable.name + - ", Phone: " + - printable.phone - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Email: ${printable.email} - :Name: ${printable.name} - :Phone: ${printable.phone}`.trimEnd(); - } -} diff --git a/src/product/billOfLading/billOfLadingV1Document.ts b/src/product/billOfLading/billOfLadingV1Document.ts deleted file mode 100644 index 95400160..00000000 --- a/src/product/billOfLading/billOfLadingV1Document.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { BillOfLadingV1Shipper } from "./billOfLadingV1Shipper"; -import { BillOfLadingV1Consignee } from "./billOfLadingV1Consignee"; -import { BillOfLadingV1NotifyParty } from "./billOfLadingV1NotifyParty"; -import { BillOfLadingV1Carrier } from "./billOfLadingV1Carrier"; -import { BillOfLadingV1CarrierItem } from "./billOfLadingV1CarrierItem"; -import { DateField, StringField } from "../../parsing/standard"; - -/** - * Bill of Lading API version 1.1 document data. - */ -export class BillOfLadingV1Document implements Prediction { - /** A unique identifier assigned to a Bill of Lading document. */ - billOfLadingNumber: StringField; - /** The shipping company responsible for transporting the goods. */ - carrier: BillOfLadingV1Carrier; - /** The goods being shipped. */ - carrierItems: BillOfLadingV1CarrierItem[] = []; - /** The party to whom the goods are being shipped. */ - consignee: BillOfLadingV1Consignee; - /** The date when the bill of lading is issued. */ - dateOfIssue: DateField; - /** The date when the vessel departs from the port of loading. */ - departureDate: DateField; - /** The party to be notified of the arrival of the goods. */ - notifyParty: BillOfLadingV1NotifyParty; - /** The place where the goods are to be delivered. */ - placeOfDelivery: StringField; - /** The port where the goods are unloaded from the vessel. */ - portOfDischarge: StringField; - /** The port where the goods are loaded onto the vessel. */ - portOfLoading: StringField; - /** The party responsible for shipping the goods. */ - shipper: BillOfLadingV1Shipper; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.billOfLadingNumber = new StringField({ - prediction: rawPrediction["bill_of_lading_number"], - pageId: pageId, - }); - this.carrier = new BillOfLadingV1Carrier({ - prediction: rawPrediction["carrier"], - pageId: pageId, - }); - rawPrediction["carrier_items"] && - rawPrediction["carrier_items"].map( - (itemPrediction: StringDict) => - this.carrierItems.push( - new BillOfLadingV1CarrierItem({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.consignee = new BillOfLadingV1Consignee({ - prediction: rawPrediction["consignee"], - pageId: pageId, - }); - this.dateOfIssue = new DateField({ - prediction: rawPrediction["date_of_issue"], - pageId: pageId, - }); - this.departureDate = new DateField({ - prediction: rawPrediction["departure_date"], - pageId: pageId, - }); - this.notifyParty = new BillOfLadingV1NotifyParty({ - prediction: rawPrediction["notify_party"], - pageId: pageId, - }); - this.placeOfDelivery = new StringField({ - prediction: rawPrediction["place_of_delivery"], - pageId: pageId, - }); - this.portOfDischarge = new StringField({ - prediction: rawPrediction["port_of_discharge"], - pageId: pageId, - }); - this.portOfLoading = new StringField({ - prediction: rawPrediction["port_of_loading"], - pageId: pageId, - }); - this.shipper = new BillOfLadingV1Shipper({ - prediction: rawPrediction["shipper"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - let carrierItemsSummary:string = ""; - if (this.carrierItems && this.carrierItems.length > 0) { - const carrierItemsColSizes:number[] = [38, 14, 13, 18, 10, 13]; - carrierItemsSummary += "\n" + lineSeparator(carrierItemsColSizes, "-") + "\n "; - carrierItemsSummary += "| Description "; - carrierItemsSummary += "| Gross Weight "; - carrierItemsSummary += "| Measurement "; - carrierItemsSummary += "| Measurement Unit "; - carrierItemsSummary += "| Quantity "; - carrierItemsSummary += "| Weight Unit "; - carrierItemsSummary += "|\n" + lineSeparator(carrierItemsColSizes, "="); - carrierItemsSummary += this.carrierItems.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(carrierItemsColSizes, "-") - ).join(""); - } - const outStr = `:Bill of Lading Number: ${this.billOfLadingNumber} -:Shipper: ${this.shipper.toFieldList()} -:Consignee: ${this.consignee.toFieldList()} -:Notify Party: ${this.notifyParty.toFieldList()} -:Carrier: ${this.carrier.toFieldList()} -:Items: ${carrierItemsSummary} -:Port of Loading: ${this.portOfLoading} -:Port of Discharge: ${this.portOfDischarge} -:Place of Delivery: ${this.placeOfDelivery} -:Date of issue: ${this.dateOfIssue} -:Departure Date: ${this.departureDate}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/product/billOfLading/billOfLadingV1NotifyParty.ts b/src/product/billOfLading/billOfLadingV1NotifyParty.ts deleted file mode 100644 index f1dd05d3..00000000 --- a/src/product/billOfLading/billOfLadingV1NotifyParty.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The party to be notified of the arrival of the goods. - */ -export class BillOfLadingV1NotifyParty { - /** The address of the notify party. */ - address: string | null; - /** The email of the shipper. */ - email: string | null; - /** The name of the notify party. */ - name: string | null; - /** The phone number of the notify party. */ - phone: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.email = prediction["email"]; - this.name = prediction["name"]; - this.phone = prediction["phone"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - email: this.email ?? "", - name: this.name ?? "", - phone: this.phone ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Email: " + - printable.email + - ", Name: " + - printable.name + - ", Phone: " + - printable.phone - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Email: ${printable.email} - :Name: ${printable.name} - :Phone: ${printable.phone}`.trimEnd(); - } -} diff --git a/src/product/billOfLading/billOfLadingV1Shipper.ts b/src/product/billOfLading/billOfLadingV1Shipper.ts deleted file mode 100644 index de70a1c8..00000000 --- a/src/product/billOfLading/billOfLadingV1Shipper.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The party responsible for shipping the goods. - */ -export class BillOfLadingV1Shipper { - /** The address of the shipper. */ - address: string | null; - /** The email of the shipper. */ - email: string | null; - /** The name of the shipper. */ - name: string | null; - /** The phone number of the shipper. */ - phone: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - this.address = prediction["address"]; - this.email = prediction["email"]; - this.name = prediction["name"]; - this.phone = prediction["phone"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - address: this.address ?? "", - email: this.email ?? "", - name: this.name ?? "", - phone: this.phone ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Address: " + - printable.address + - ", Email: " + - printable.email + - ", Name: " + - printable.name + - ", Phone: " + - printable.phone - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Address: ${printable.address} - :Email: ${printable.email} - :Name: ${printable.name} - :Phone: ${printable.phone}`.trimEnd(); - } -} diff --git a/src/product/billOfLading/index.ts b/src/product/billOfLading/index.ts deleted file mode 100644 index c68593ae..00000000 --- a/src/product/billOfLading/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { BillOfLadingV1 } from "./billOfLadingV1"; diff --git a/src/product/billOfLading/internal.ts b/src/product/billOfLading/internal.ts deleted file mode 100644 index 3fe053d0..00000000 --- a/src/product/billOfLading/internal.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { BillOfLadingV1 } from "./billOfLadingV1"; -export { BillOfLadingV1Carrier } from "./billOfLadingV1Carrier"; -export { BillOfLadingV1CarrierItem } from "./billOfLadingV1CarrierItem"; -export { BillOfLadingV1Consignee } from "./billOfLadingV1Consignee"; -export { BillOfLadingV1Document } from "./billOfLadingV1Document"; -export { BillOfLadingV1NotifyParty } from "./billOfLadingV1NotifyParty"; -export { BillOfLadingV1Shipper } from "./billOfLadingV1Shipper"; diff --git a/src/product/businessCard/businessCardV1.ts b/src/product/businessCard/businessCardV1.ts deleted file mode 100644 index 10e0772f..00000000 --- a/src/product/businessCard/businessCardV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { BusinessCardV1Document } from "./businessCardV1Document"; - -/** - * Business Card API version 1 inference prediction. - */ -export class BusinessCardV1 extends Inference { - /** The endpoint's name. */ - endpointName = "business_card"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: BusinessCardV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new BusinessCardV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - BusinessCardV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/businessCard/businessCardV1Document.ts b/src/product/businessCard/businessCardV1Document.ts deleted file mode 100644 index bce69379..00000000 --- a/src/product/businessCard/businessCardV1Document.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "../../parsing/common"; -import { StringField } from "../../parsing/standard"; - -/** - * Business Card API version 1.0 document data. - */ -export class BusinessCardV1Document implements Prediction { - /** The address of the person. */ - address: StringField; - /** The company the person works for. */ - company: StringField; - /** The email address of the person. */ - email: StringField; - /** The Fax number of the person. */ - faxNumber: StringField; - /** The given name of the person. */ - firstname: StringField; - /** The job title of the person. */ - jobTitle: StringField; - /** The lastname of the person. */ - lastname: StringField; - /** The mobile number of the person. */ - mobileNumber: StringField; - /** The phone number of the person. */ - phoneNumber: StringField; - /** The social media profiles of the person or company. */ - socialMedia: StringField[] = []; - /** The website of the person or company. */ - website: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.address = new StringField({ - prediction: rawPrediction["address"], - pageId: pageId, - }); - this.company = new StringField({ - prediction: rawPrediction["company"], - pageId: pageId, - }); - this.email = new StringField({ - prediction: rawPrediction["email"], - pageId: pageId, - }); - this.faxNumber = new StringField({ - prediction: rawPrediction["fax_number"], - pageId: pageId, - }); - this.firstname = new StringField({ - prediction: rawPrediction["firstname"], - pageId: pageId, - }); - this.jobTitle = new StringField({ - prediction: rawPrediction["job_title"], - pageId: pageId, - }); - this.lastname = new StringField({ - prediction: rawPrediction["lastname"], - pageId: pageId, - }); - this.mobileNumber = new StringField({ - prediction: rawPrediction["mobile_number"], - pageId: pageId, - }); - this.phoneNumber = new StringField({ - prediction: rawPrediction["phone_number"], - pageId: pageId, - }); - rawPrediction["social_media"] && - rawPrediction["social_media"].map( - (itemPrediction: StringDict) => - this.socialMedia.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.website = new StringField({ - prediction: rawPrediction["website"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const socialMedia = this.socialMedia.join("\n "); - const outStr = `:Firstname: ${this.firstname} -:Lastname: ${this.lastname} -:Job Title: ${this.jobTitle} -:Company: ${this.company} -:Email: ${this.email} -:Phone Number: ${this.phoneNumber} -:Mobile Number: ${this.mobileNumber} -:Fax Number: ${this.faxNumber} -:Address: ${this.address} -:Website: ${this.website} -:Social Media: ${socialMedia}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/product/businessCard/index.ts b/src/product/businessCard/index.ts deleted file mode 100644 index 3fabf887..00000000 --- a/src/product/businessCard/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { BusinessCardV1 } from "./businessCardV1"; diff --git a/src/product/businessCard/internal.ts b/src/product/businessCard/internal.ts deleted file mode 100644 index 41074098..00000000 --- a/src/product/businessCard/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { BusinessCardV1 } from "./businessCardV1"; -export { BusinessCardV1Document } from "./businessCardV1Document"; diff --git a/src/product/cropper/cropperV1.ts b/src/product/cropper/cropperV1.ts index 2968138c..9d950687 100644 --- a/src/product/cropper/cropperV1.ts +++ b/src/product/cropper/cropperV1.ts @@ -1,6 +1,6 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { CropperV1Document } from "./cropperV1Document"; -import { CropperV1Page } from "./cropperV1Page"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { CropperV1Document } from "./cropperV1Document.js"; +import { CropperV1Page } from "./cropperV1Page.js"; /** * Cropper API version 1 inference prediction. diff --git a/src/product/cropper/cropperV1Document.ts b/src/product/cropper/cropperV1Document.ts index bc7a85c6..1044739c 100644 --- a/src/product/cropper/cropperV1Document.ts +++ b/src/product/cropper/cropperV1Document.ts @@ -1,4 +1,4 @@ -import { Prediction } from "../../parsing/common"; +import { Prediction } from "@/parsing/common/index.js"; /** diff --git a/src/product/cropper/cropperV1Page.ts b/src/product/cropper/cropperV1Page.ts index de1b0a66..2ea83a3c 100644 --- a/src/product/cropper/cropperV1Page.ts +++ b/src/product/cropper/cropperV1Page.ts @@ -1,7 +1,7 @@ -import { StringDict, cleanOutString } from "../../parsing/common"; -import { PositionField } from "../../parsing/standard"; +import { StringDict, cleanOutString } from "@/parsing/common/index.js"; +import { PositionField } from "@/parsing/standard/index.js"; -import { CropperV1Document } from "./cropperV1Document"; +import { CropperV1Document } from "./cropperV1Document.js"; /** * Cropper API version 1.1 page data. diff --git a/src/product/cropper/index.ts b/src/product/cropper/index.ts index 53be02fc..c99760e5 100644 --- a/src/product/cropper/index.ts +++ b/src/product/cropper/index.ts @@ -1 +1,3 @@ -export { CropperV1 } from "./cropperV1"; +export { CropperV1 } from "./cropperV1.js"; +export { CropperV1Document } from "./cropperV1Document.js"; +export { CropperV1Page } from "./cropperV1Page.js"; diff --git a/src/product/cropper/internal.ts b/src/product/cropper/internal.ts deleted file mode 100644 index 898b1d4e..00000000 --- a/src/product/cropper/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { CropperV1 } from "./cropperV1"; -export { CropperV1Document } from "./cropperV1Document"; -export { CropperV1Page } from "./cropperV1Page"; diff --git a/src/product/custom/customV1.ts b/src/product/custom/customV1.ts deleted file mode 100644 index a77f72a4..00000000 --- a/src/product/custom/customV1.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Inference, Page, StringDict } from "../../parsing/common"; -import { CustomV1Document } from "./customV1Document"; -import { CustomV1Page } from "./customV1Page"; - -/** - * Inference prediction for Custom builds. - */ -export class CustomV1 extends Inference { - /** The endpoint's name. Note: placeholder for custom APIs. */ - endpointName = "custom"; - /** The endpoint's version. Note: placeholder for custom APIs. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: CustomV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new CustomV1Document(rawPrediction["prediction"]); - this.pages = rawPrediction["pages"].map( - (page: StringDict) => - new Page(CustomV1Page, page, page["id"], page["orientation"]) - ); - } -} diff --git a/src/product/custom/customV1Document.ts b/src/product/custom/customV1Document.ts deleted file mode 100644 index 55c781a5..00000000 --- a/src/product/custom/customV1Document.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { cleanOutString } from "../../parsing/common"; -import { StringDict, Prediction } from "../../parsing/common"; -import { ClassificationField, ListField, getLineItems, CustomLines } from "../../parsing/custom"; - -/** - * Document data for Custom builds. - */ -export class CustomV1Document implements Prediction { - /** Map of fields for a Custom build. */ - fields: Map = new Map(); - /** Map of classification fields for a Custom build. */ - classifications: Map = new Map(); - - constructor(rawPrediction: StringDict, pageId?: number) { - Object.entries(rawPrediction).forEach( - ([fieldName, fieldValue]: [string, any]) => { - this.setField(fieldName, fieldValue, pageId); - } - ); - } - - /** - * Sorts and sets fields between classification fields and regular fields. - * Note: Currently, two types of fields possible in a custom API response: - * fields having a list of values, and classification fields. - * @param fieldName name of the field. - * @param fieldValue value of the field. - * @param pageId page the field was found on. - */ - protected setField(fieldName: string, fieldValue: any, pageId?: number) { - if (fieldValue && fieldValue["values"] !== undefined) { - // Only value lists have the 'values' attribute. - this.fields.set( - fieldName, - new ListField({ - prediction: fieldValue as StringDict, - pageId: pageId, - }) - ); - } else if (fieldValue && fieldValue["value"] !== undefined) { - // Only classifications have the 'value' attribute. - this.classifications.set( - fieldName, - new ClassificationField({ prediction: fieldValue }) - ); - } else { - throw new Error( - `Unknown API field type for field ${fieldName} : ${fieldValue}` - ); - } - } - - /** - * Order column fields into line items. - * @param anchorNames list of possible anchor fields. - * @param fieldNames list of all column fields. - * @param heightTolerance height tolerance to apply to lines. - */ - columnsToLineItems(anchorNames: string[], fieldNames: string[], heightTolerance: number = 0.01): CustomLines { - return getLineItems( - anchorNames, - fieldNames, - this.fields, - heightTolerance - ); - } - - /** - * Default string representation. - */ - toString(): string { - let outStr = ""; - this.classifications.forEach((fieldData, name) => { - outStr += `:${name}: ${fieldData}\n`; - }); - this.fields.forEach((fieldData, name) => { - outStr += `:${name}: ${fieldData}\n`; - }); - return cleanOutString(outStr).trimEnd(); - } -} diff --git a/src/product/custom/customV1Page.ts b/src/product/custom/customV1Page.ts deleted file mode 100644 index 3f432ae2..00000000 --- a/src/product/custom/customV1Page.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { cleanOutString } from "../../parsing/common"; -import { StringDict, Prediction } from "../../parsing/common"; -import { ListField, CustomLines, getLineItems } from "../../parsing/custom"; - -/** - * Page data for Custom builds. - */ -export class CustomV1Page implements Prediction { - /** Map of page-specific fields for a Custom build. Cannot include Classification fields. */ - fields: Map = new Map(); - - constructor(rawPrediction: StringDict, pageId?: number) { - Object.entries(rawPrediction).forEach( - ([fieldName, fieldValue]: [string, any]) => { - this.fields.set( - fieldName, - new ListField({ - prediction: fieldValue as StringDict, - pageId: pageId, - }) - ); - } - ); - } - - /** - * Order column fields into line items. - * @param anchorNames list of possible anchor fields. - * @param fieldNames list of all column fields. - * @param heightTolerance height tolerance to apply to lines. - */ - columnsToLineItems(anchorNames: string[], fieldNames: string[], heightTolerance: number = 0.01): CustomLines { - return getLineItems( - anchorNames, - fieldNames, - this.fields, - heightTolerance - ); - } - - /** - * Default string representation. - */ - toString(): string { - let outStr = ""; - this.fields.forEach((fieldData, name) => { - outStr += `:${name}: ${fieldData}\n`; - }); - return cleanOutString(outStr).trimEnd(); - } -} diff --git a/src/product/custom/internal.ts b/src/product/custom/internal.ts deleted file mode 100644 index daf01bdd..00000000 --- a/src/product/custom/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { CustomV1 } from "./customV1"; -export { CustomV1Document } from "./customV1Document"; -export { CustomV1Page } from "./customV1Page"; diff --git a/src/product/deliveryNote/deliveryNoteV1.ts b/src/product/deliveryNote/deliveryNoteV1.ts deleted file mode 100644 index c2e25301..00000000 --- a/src/product/deliveryNote/deliveryNoteV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { DeliveryNoteV1Document } from "./deliveryNoteV1Document"; - -/** - * Delivery note API version 1 inference prediction. - */ -export class DeliveryNoteV1 extends Inference { - /** The endpoint's name. */ - endpointName = "delivery_notes"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: DeliveryNoteV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new DeliveryNoteV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - DeliveryNoteV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/deliveryNote/deliveryNoteV1Document.ts b/src/product/deliveryNote/deliveryNoteV1Document.ts deleted file mode 100644 index e3b2febf..00000000 --- a/src/product/deliveryNote/deliveryNoteV1Document.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString, -} from "../../parsing/common"; -import { - AmountField, - DateField, - StringField, -} from "../../parsing/standard"; - -/** - * Delivery note API version 1.2 document data. - */ -export class DeliveryNoteV1Document implements Prediction { - /** The address of the customer receiving the goods. */ - customerAddress: StringField; - /** The name of the customer receiving the goods. */ - customerName: StringField; - /** The date on which the delivery is scheduled to arrive. */ - deliveryDate: DateField; - /** A unique identifier for the delivery note. */ - deliveryNumber: StringField; - /** The address of the supplier providing the goods. */ - supplierAddress: StringField; - /** The name of the supplier providing the goods. */ - supplierName: StringField; - /** The total monetary value of the goods being delivered. */ - totalAmount: AmountField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.customerAddress = new StringField({ - prediction: rawPrediction["customer_address"], - pageId: pageId, - }); - this.customerName = new StringField({ - prediction: rawPrediction["customer_name"], - pageId: pageId, - }); - this.deliveryDate = new DateField({ - prediction: rawPrediction["delivery_date"], - pageId: pageId, - }); - this.deliveryNumber = new StringField({ - prediction: rawPrediction["delivery_number"], - pageId: pageId, - }); - this.supplierAddress = new StringField({ - prediction: rawPrediction["supplier_address"], - pageId: pageId, - }); - this.supplierName = new StringField({ - prediction: rawPrediction["supplier_name"], - pageId: pageId, - }); - this.totalAmount = new AmountField({ - prediction: rawPrediction["total_amount"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const outStr = `:Delivery Date: ${this.deliveryDate} -:Delivery Number: ${this.deliveryNumber} -:Supplier Name: ${this.supplierName} -:Supplier Address: ${this.supplierAddress} -:Customer Name: ${this.customerName} -:Customer Address: ${this.customerAddress} -:Total Amount: ${this.totalAmount}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/product/deliveryNote/index.ts b/src/product/deliveryNote/index.ts deleted file mode 100644 index 46266a46..00000000 --- a/src/product/deliveryNote/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { DeliveryNoteV1 } from "./deliveryNoteV1"; diff --git a/src/product/deliveryNote/internal.ts b/src/product/deliveryNote/internal.ts deleted file mode 100644 index 887d45d6..00000000 --- a/src/product/deliveryNote/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { DeliveryNoteV1 } from "./deliveryNoteV1"; -export { DeliveryNoteV1Document } from "./deliveryNoteV1Document"; diff --git a/src/product/driverLicense/driverLicenseV1.ts b/src/product/driverLicense/driverLicenseV1.ts index 1ccd03ce..f47b4b6d 100644 --- a/src/product/driverLicense/driverLicenseV1.ts +++ b/src/product/driverLicense/driverLicenseV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { DriverLicenseV1Document } from "./driverLicenseV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { DriverLicenseV1Document } from "./driverLicenseV1Document.js"; /** * Driver License API version 1 inference prediction. diff --git a/src/product/driverLicense/driverLicenseV1Document.ts b/src/product/driverLicense/driverLicenseV1Document.ts index 559dcd5a..2620c08b 100644 --- a/src/product/driverLicense/driverLicenseV1Document.ts +++ b/src/product/driverLicense/driverLicenseV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../parsing/common"; -import { DateField, StringField } from "../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { DateField, StringField } from "@/parsing/standard/index.js"; /** * Driver License API version 1.0 document data. diff --git a/src/product/driverLicense/index.ts b/src/product/driverLicense/index.ts index 8213a78c..eaa3cc47 100644 --- a/src/product/driverLicense/index.ts +++ b/src/product/driverLicense/index.ts @@ -1 +1,2 @@ -export { DriverLicenseV1 } from "./driverLicenseV1"; +export { DriverLicenseV1 } from "./driverLicenseV1.js"; +export { DriverLicenseV1Document } from "./driverLicenseV1Document.js"; diff --git a/src/product/driverLicense/internal.ts b/src/product/driverLicense/internal.ts deleted file mode 100644 index b3a91e93..00000000 --- a/src/product/driverLicense/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { DriverLicenseV1 } from "./driverLicenseV1"; -export { DriverLicenseV1Document } from "./driverLicenseV1Document"; diff --git a/src/product/financialDocument/financialDocumentV1.ts b/src/product/financialDocument/financialDocumentV1.ts index 6b27a3ee..0e9364b6 100644 --- a/src/product/financialDocument/financialDocumentV1.ts +++ b/src/product/financialDocument/financialDocumentV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { FinancialDocumentV1Document } from "./financialDocumentV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { FinancialDocumentV1Document } from "./financialDocumentV1Document.js"; /** * Financial Document API version 1 inference prediction. diff --git a/src/product/financialDocument/financialDocumentV1Document.ts b/src/product/financialDocument/financialDocumentV1Document.ts index d9e0a78b..c4224779 100644 --- a/src/product/financialDocument/financialDocumentV1Document.ts +++ b/src/product/financialDocument/financialDocumentV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem"; +} from "@/parsing/common/index.js"; +import { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem.js"; import { AddressField, AmountField, @@ -14,7 +14,7 @@ import { PaymentDetailsField, StringField, Taxes, -} from "../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * Financial Document API version 1.14 document data. diff --git a/src/product/financialDocument/financialDocumentV1LineItem.ts b/src/product/financialDocument/financialDocumentV1LineItem.ts index dc5caa64..16c99c67 100644 --- a/src/product/financialDocument/financialDocumentV1LineItem.ts +++ b/src/product/financialDocument/financialDocumentV1LineItem.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * List of line item present on the document. diff --git a/src/product/financialDocument/index.ts b/src/product/financialDocument/index.ts index e431c1b2..1fdd2f1d 100644 --- a/src/product/financialDocument/index.ts +++ b/src/product/financialDocument/index.ts @@ -1 +1,3 @@ -export { FinancialDocumentV1 } from "./financialDocumentV1"; +export { FinancialDocumentV1 } from "./financialDocumentV1.js"; +export { FinancialDocumentV1Document } from "./financialDocumentV1Document.js"; +export { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem.js"; diff --git a/src/product/financialDocument/internal.ts b/src/product/financialDocument/internal.ts deleted file mode 100644 index 39507866..00000000 --- a/src/product/financialDocument/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { FinancialDocumentV1 } from "./financialDocumentV1"; -export { FinancialDocumentV1Document } from "./financialDocumentV1Document"; -export { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem"; diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts b/src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts index 40ba7aef..cf017376 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts +++ b/src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { BankAccountDetailsV1Document } from "./bankAccountDetailsV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { BankAccountDetailsV1Document } from "./bankAccountDetailsV1Document.js"; /** * Bank Account Details API version 1 inference prediction. diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts b/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts index 3f1e373c..47a73b34 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts +++ b/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; -import { StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { StringField } from "@/parsing/standard/index.js"; /** * Bank Account Details API version 1.0 document data. diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts b/src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts index 71118cef..8358ecdf 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts +++ b/src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { BankAccountDetailsV2Document } from "./bankAccountDetailsV2Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { BankAccountDetailsV2Document } from "./bankAccountDetailsV2Document.js"; /** * Bank Account Details API version 2 inference prediction. diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts b/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts index 6f464d63..0659716b 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts +++ b/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Full extraction of BBAN, including: branch code, bank code, account and key. diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts b/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts index 422e139e..d26ba0d8 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts +++ b/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts @@ -2,9 +2,9 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; -import { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban"; -import { StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban.js"; +import { StringField } from "@/parsing/standard/index.js"; /** * Bank Account Details API version 2.0 document data. diff --git a/src/product/fr/bankAccountDetails/index.ts b/src/product/fr/bankAccountDetails/index.ts index bc20b9c1..80219ea3 100644 --- a/src/product/fr/bankAccountDetails/index.ts +++ b/src/product/fr/bankAccountDetails/index.ts @@ -1,2 +1,5 @@ -export { BankAccountDetailsV1 } from "./bankAccountDetailsV1"; -export { BankAccountDetailsV2 } from "./bankAccountDetailsV2"; +export { BankAccountDetailsV1 } from "./bankAccountDetailsV1.js"; +export { BankAccountDetailsV1Document } from "./bankAccountDetailsV1Document.js"; +export { BankAccountDetailsV2 } from "./bankAccountDetailsV2.js"; +export { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban.js"; +export { BankAccountDetailsV2Document } from "./bankAccountDetailsV2Document.js"; diff --git a/src/product/fr/bankAccountDetails/internal.ts b/src/product/fr/bankAccountDetails/internal.ts deleted file mode 100644 index b39cb7cf..00000000 --- a/src/product/fr/bankAccountDetails/internal.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { BankAccountDetailsV1 } from "./bankAccountDetailsV1"; -export { BankAccountDetailsV1Document } from "./bankAccountDetailsV1Document"; -export { BankAccountDetailsV2 } from "./bankAccountDetailsV2"; -export { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban"; -export { BankAccountDetailsV2Document } from "./bankAccountDetailsV2Document"; diff --git a/src/product/fr/carteGrise/carteGriseV1.ts b/src/product/fr/carteGrise/carteGriseV1.ts index fd8d510f..29d6425b 100644 --- a/src/product/fr/carteGrise/carteGriseV1.ts +++ b/src/product/fr/carteGrise/carteGriseV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { CarteGriseV1Document } from "./carteGriseV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { CarteGriseV1Document } from "./carteGriseV1Document.js"; /** * Carte Grise API version 1 inference prediction. diff --git a/src/product/fr/carteGrise/carteGriseV1Document.ts b/src/product/fr/carteGrise/carteGriseV1Document.ts index 5d3c1911..0b3e9683 100644 --- a/src/product/fr/carteGrise/carteGriseV1Document.ts +++ b/src/product/fr/carteGrise/carteGriseV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; -import { DateField, StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { DateField, StringField } from "@/parsing/standard/index.js"; /** * Carte Grise API version 1.1 document data. diff --git a/src/product/fr/carteGrise/index.ts b/src/product/fr/carteGrise/index.ts index f60c5723..2aad17b0 100644 --- a/src/product/fr/carteGrise/index.ts +++ b/src/product/fr/carteGrise/index.ts @@ -1 +1,2 @@ -export { CarteGriseV1 } from "./carteGriseV1"; +export { CarteGriseV1 } from "./carteGriseV1.js"; +export { CarteGriseV1Document } from "./carteGriseV1Document.js"; diff --git a/src/product/fr/carteGrise/internal.ts b/src/product/fr/carteGrise/internal.ts deleted file mode 100644 index c9f0cc46..00000000 --- a/src/product/fr/carteGrise/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { CarteGriseV1 } from "./carteGriseV1"; -export { CarteGriseV1Document } from "./carteGriseV1Document"; diff --git a/src/product/fr/energyBill/energyBillV1.ts b/src/product/fr/energyBill/energyBillV1.ts index a24f0d42..2370f834 100644 --- a/src/product/fr/energyBill/energyBillV1.ts +++ b/src/product/fr/energyBill/energyBillV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { EnergyBillV1Document } from "./energyBillV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { EnergyBillV1Document } from "./energyBillV1Document.js"; /** * Energy Bill API version 1 inference prediction. diff --git a/src/product/fr/energyBill/energyBillV1Document.ts b/src/product/fr/energyBill/energyBillV1Document.ts index 87a9f281..e2c9a1cb 100644 --- a/src/product/fr/energyBill/energyBillV1Document.ts +++ b/src/product/fr/energyBill/energyBillV1Document.ts @@ -2,18 +2,18 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../../parsing/common"; -import { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier"; -import { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer"; -import { EnergyBillV1Subscription } from "./energyBillV1Subscription"; -import { EnergyBillV1EnergyUsage } from "./energyBillV1EnergyUsage"; -import { EnergyBillV1TaxesAndContribution } from "./energyBillV1TaxesAndContribution"; -import { EnergyBillV1MeterDetail } from "./energyBillV1MeterDetail"; +} from "@/parsing/common/index.js"; +import { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier.js"; +import { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer.js"; +import { EnergyBillV1Subscription } from "./energyBillV1Subscription.js"; +import { EnergyBillV1EnergyUsage } from "./energyBillV1EnergyUsage.js"; +import { EnergyBillV1TaxesAndContribution } from "./energyBillV1TaxesAndContribution.js"; +import { EnergyBillV1MeterDetail } from "./energyBillV1MeterDetail.js"; import { AmountField, DateField, StringField, -} from "../../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * Energy Bill API version 1.2 document data. diff --git a/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts b/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts index ceb202ee..24e934ba 100644 --- a/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts +++ b/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The entity that consumes the energy. diff --git a/src/product/fr/energyBill/energyBillV1EnergySupplier.ts b/src/product/fr/energyBill/energyBillV1EnergySupplier.ts index badfdf7e..2b400e71 100644 --- a/src/product/fr/energyBill/energyBillV1EnergySupplier.ts +++ b/src/product/fr/energyBill/energyBillV1EnergySupplier.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The company that supplies the energy. diff --git a/src/product/fr/energyBill/energyBillV1EnergyUsage.ts b/src/product/fr/energyBill/energyBillV1EnergyUsage.ts index d2e90d2a..afaf10a4 100644 --- a/src/product/fr/energyBill/energyBillV1EnergyUsage.ts +++ b/src/product/fr/energyBill/energyBillV1EnergyUsage.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Details of energy consumption. diff --git a/src/product/fr/energyBill/energyBillV1MeterDetail.ts b/src/product/fr/energyBill/energyBillV1MeterDetail.ts index db04ab24..2458b68a 100644 --- a/src/product/fr/energyBill/energyBillV1MeterDetail.ts +++ b/src/product/fr/energyBill/energyBillV1MeterDetail.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the energy meter. diff --git a/src/product/fr/energyBill/energyBillV1Subscription.ts b/src/product/fr/energyBill/energyBillV1Subscription.ts index 43c470dd..7161ddd2 100644 --- a/src/product/fr/energyBill/energyBillV1Subscription.ts +++ b/src/product/fr/energyBill/energyBillV1Subscription.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The subscription details fee for the energy service. diff --git a/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts b/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts index 97b377ab..ce6e0854 100644 --- a/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts +++ b/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Details of Taxes and Contributions. diff --git a/src/product/fr/energyBill/index.ts b/src/product/fr/energyBill/index.ts index 291672c2..15d42df0 100644 --- a/src/product/fr/energyBill/index.ts +++ b/src/product/fr/energyBill/index.ts @@ -1 +1,8 @@ -export { EnergyBillV1 } from "./energyBillV1"; +export { EnergyBillV1 } from "./energyBillV1.js"; +export { EnergyBillV1Document } from "./energyBillV1Document.js"; +export { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer.js"; +export { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier.js"; +export { EnergyBillV1EnergyUsage } from "./energyBillV1EnergyUsage.js"; +export { EnergyBillV1MeterDetail } from "./energyBillV1MeterDetail.js"; +export { EnergyBillV1Subscription } from "./energyBillV1Subscription.js"; +export { EnergyBillV1TaxesAndContribution } from "./energyBillV1TaxesAndContribution.js"; diff --git a/src/product/fr/energyBill/internal.ts b/src/product/fr/energyBill/internal.ts deleted file mode 100644 index 734b7e74..00000000 --- a/src/product/fr/energyBill/internal.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { EnergyBillV1 } from "./energyBillV1"; -export { EnergyBillV1Document } from "./energyBillV1Document"; -export { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer"; -export { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier"; -export { EnergyBillV1EnergyUsage } from "./energyBillV1EnergyUsage"; -export { EnergyBillV1MeterDetail } from "./energyBillV1MeterDetail"; -export { EnergyBillV1Subscription } from "./energyBillV1Subscription"; -export { EnergyBillV1TaxesAndContribution } from "./energyBillV1TaxesAndContribution"; diff --git a/src/product/fr/healthCard/healthCardV1.ts b/src/product/fr/healthCard/healthCardV1.ts index 59c4ed20..cf9651ed 100644 --- a/src/product/fr/healthCard/healthCardV1.ts +++ b/src/product/fr/healthCard/healthCardV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { HealthCardV1Document } from "./healthCardV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { HealthCardV1Document } from "./healthCardV1Document.js"; /** * Health Card API version 1 inference prediction. diff --git a/src/product/fr/healthCard/healthCardV1Document.ts b/src/product/fr/healthCard/healthCardV1Document.ts index 2c50e641..a9f4b475 100644 --- a/src/product/fr/healthCard/healthCardV1Document.ts +++ b/src/product/fr/healthCard/healthCardV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; -import { DateField, StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { DateField, StringField } from "@/parsing/standard/index.js"; /** * Health Card API version 1.0 document data. diff --git a/src/product/fr/healthCard/index.ts b/src/product/fr/healthCard/index.ts index dd23fa4e..0cf330a5 100644 --- a/src/product/fr/healthCard/index.ts +++ b/src/product/fr/healthCard/index.ts @@ -1 +1,2 @@ -export { HealthCardV1 } from "./healthCardV1"; +export { HealthCardV1 } from "./healthCardV1.js"; +export { HealthCardV1Document } from "./healthCardV1Document.js"; diff --git a/src/product/fr/healthCard/internal.ts b/src/product/fr/healthCard/internal.ts deleted file mode 100644 index 22d5f9e1..00000000 --- a/src/product/fr/healthCard/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { HealthCardV1 } from "./healthCardV1"; -export { HealthCardV1Document } from "./healthCardV1Document"; diff --git a/src/product/fr/idCard/idCardV1.ts b/src/product/fr/idCard/idCardV1.ts index 452e7c66..1c5385b0 100644 --- a/src/product/fr/idCard/idCardV1.ts +++ b/src/product/fr/idCard/idCardV1.ts @@ -1,6 +1,6 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { IdCardV1Document } from "./idCardV1Document"; -import { IdCardV1Page } from "./idCardV1Page"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { IdCardV1Document } from "./idCardV1Document.js"; +import { IdCardV1Page } from "./idCardV1Page.js"; /** * Carte Nationale d'Identité API version 1 inference prediction. diff --git a/src/product/fr/idCard/idCardV1Document.ts b/src/product/fr/idCard/idCardV1Document.ts index b5c28256..e4a411e3 100644 --- a/src/product/fr/idCard/idCardV1Document.ts +++ b/src/product/fr/idCard/idCardV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; -import { DateField, StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { DateField, StringField } from "@/parsing/standard/index.js"; /** * Carte Nationale d'Identité API version 1.1 document data. diff --git a/src/product/fr/idCard/idCardV1Page.ts b/src/product/fr/idCard/idCardV1Page.ts index 89580313..25ecc5be 100644 --- a/src/product/fr/idCard/idCardV1Page.ts +++ b/src/product/fr/idCard/idCardV1Page.ts @@ -1,7 +1,6 @@ -import { StringDict, cleanOutString } from "../../../parsing/common"; -import { ClassificationField } from "../../../parsing/standard"; - -import { IdCardV1Document } from "./idCardV1Document"; +import { StringDict, cleanOutString } from "@/parsing/common/index.js"; +import { ClassificationField } from "@/parsing/standard/index.js"; +import { IdCardV1Document } from "./idCardV1Document.js"; /** * Carte Nationale d'Identité API version 1.1 page data. diff --git a/src/product/fr/idCard/idCardV2.ts b/src/product/fr/idCard/idCardV2.ts index 6bcac786..6e8b0319 100644 --- a/src/product/fr/idCard/idCardV2.ts +++ b/src/product/fr/idCard/idCardV2.ts @@ -1,6 +1,6 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { IdCardV2Document } from "./idCardV2Document"; -import { IdCardV2Page } from "./idCardV2Page"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { IdCardV2Document } from "./idCardV2Document.js"; +import { IdCardV2Page } from "./idCardV2Page.js"; /** * Carte Nationale d'Identité API version 2 inference prediction. diff --git a/src/product/fr/idCard/idCardV2Document.ts b/src/product/fr/idCard/idCardV2Document.ts index a0931453..0ccf3ec8 100644 --- a/src/product/fr/idCard/idCardV2Document.ts +++ b/src/product/fr/idCard/idCardV2Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; -import { DateField, StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { DateField, StringField } from "@/parsing/standard/index.js"; /** * Carte Nationale d'Identité API version 2.0 document data. diff --git a/src/product/fr/idCard/idCardV2Page.ts b/src/product/fr/idCard/idCardV2Page.ts index 70974dd5..cd0ec833 100644 --- a/src/product/fr/idCard/idCardV2Page.ts +++ b/src/product/fr/idCard/idCardV2Page.ts @@ -1,7 +1,6 @@ -import { StringDict, cleanOutString } from "../../../parsing/common"; -import { ClassificationField } from "../../../parsing/standard"; - -import { IdCardV2Document } from "./idCardV2Document"; +import { StringDict, cleanOutString } from "@/parsing/common/index.js"; +import { ClassificationField } from "@/parsing/standard/index.js"; +import { IdCardV2Document } from "./idCardV2Document.js"; /** * Carte Nationale d'Identité API version 2.0 page data. diff --git a/src/product/fr/idCard/index.ts b/src/product/fr/idCard/index.ts index d3798f37..f8dc520e 100644 --- a/src/product/fr/idCard/index.ts +++ b/src/product/fr/idCard/index.ts @@ -1,2 +1,6 @@ -export { IdCardV1 } from "./idCardV1"; -export { IdCardV2 } from "./idCardV2"; +export { IdCardV1 } from "./idCardV1.js"; +export { IdCardV1Document } from "./idCardV1Document.js"; +export { IdCardV1Page } from "./idCardV1Page.js"; +export { IdCardV2 } from "./idCardV2.js"; +export { IdCardV2Document } from "./idCardV2Document.js"; +export { IdCardV2Page } from "./idCardV2Page.js"; diff --git a/src/product/fr/idCard/internal.ts b/src/product/fr/idCard/internal.ts deleted file mode 100644 index d7e8ab6e..00000000 --- a/src/product/fr/idCard/internal.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { IdCardV1 } from "./idCardV1"; -export { IdCardV1Document } from "./idCardV1Document"; -export { IdCardV1Page } from "./idCardV1Page"; -export { IdCardV2 } from "./idCardV2"; -export { IdCardV2Document } from "./idCardV2Document"; -export { IdCardV2Page } from "./idCardV2Page"; diff --git a/src/product/fr/index.ts b/src/product/fr/index.ts index 451ec161..2d9f4949 100644 --- a/src/product/fr/index.ts +++ b/src/product/fr/index.ts @@ -1,9 +1,9 @@ -export { BankAccountDetailsV1 } from "./bankAccountDetails/bankAccountDetailsV1"; -export { BankAccountDetailsV2 } from "./bankAccountDetails/bankAccountDetailsV2"; -export { CarteGriseV1 } from "./carteGrise/carteGriseV1"; -export { EnergyBillV1 } from "./energyBill/energyBillV1"; -export { HealthCardV1 } from "./healthCard/healthCardV1"; -export { IdCardV1 } from "./idCard/idCardV1"; -export { IdCardV2 } from "./idCard/idCardV2"; -export { PayslipV2 } from "./payslip/payslipV2"; -export { PayslipV3 } from "./payslip/payslipV3"; +export { BankAccountDetailsV1 } from "./bankAccountDetails/index.js"; +export { BankAccountDetailsV2 } from "./bankAccountDetails/index.js"; +export { EnergyBillV1 } from "./energyBill/index.js"; +export { HealthCardV1 } from "./healthCard/index.js"; +export { IdCardV1 } from "./idCard/index.js"; +export { IdCardV2 } from "./idCard/index.js"; +export { PayslipV2 } from "./payslip/index.js"; +export { PayslipV3 } from "./payslip/index.js"; +export { CarteGriseV1 } from "./carteGrise/index.js"; diff --git a/src/product/fr/internal.ts b/src/product/fr/internal.ts index 33f2441a..f2348565 100644 --- a/src/product/fr/internal.ts +++ b/src/product/fr/internal.ts @@ -1,6 +1,5 @@ -export * as bankAccountDetails from "./bankAccountDetails/internal"; -export * as carteGrise from "./carteGrise/internal"; -export * as energyBill from "./energyBill/internal"; -export * as healthCard from "./healthCard/internal"; -export * as idCard from "./idCard/internal"; -export * as payslip from "./payslip/internal"; +export * as bankAccountDetails from "./bankAccountDetails/index.js"; +export * as energyBill from "./energyBill/index.js"; +export * as healthCard from "./healthCard/index.js"; +export * as idCard from "./idCard/index.js"; +export * as payslip from "./payslip/index.js"; diff --git a/src/product/fr/payslip/index.ts b/src/product/fr/payslip/index.ts index 12c775ba..f528d035 100644 --- a/src/product/fr/payslip/index.ts +++ b/src/product/fr/payslip/index.ts @@ -1,2 +1,20 @@ -export { PayslipV2 } from "./payslipV2"; -export { PayslipV3 } from "./payslipV3"; +export { PayslipV2 } from "./payslipV2.js"; +export { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail.js"; +export { PayslipV2Document } from "./payslipV2Document.js"; +export { PayslipV2Employee } from "./payslipV2Employee.js"; +export { PayslipV2Employer } from "./payslipV2Employer.js"; +export { PayslipV2Employment } from "./payslipV2Employment.js"; +export { PayslipV2PayDetail } from "./payslipV2PayDetail.js"; +export { PayslipV2PayPeriod } from "./payslipV2PayPeriod.js"; +export { PayslipV2Pto } from "./payslipV2Pto.js"; +export { PayslipV2SalaryDetail } from "./payslipV2SalaryDetail.js"; +export { PayslipV3 } from "./payslipV3.js"; +export { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail.js"; +export { PayslipV3Document } from "./payslipV3Document.js"; +export { PayslipV3Employee } from "./payslipV3Employee.js"; +export { PayslipV3Employer } from "./payslipV3Employer.js"; +export { PayslipV3Employment } from "./payslipV3Employment.js"; +export { PayslipV3PaidTimeOff } from "./payslipV3PaidTimeOff.js"; +export { PayslipV3PayDetail } from "./payslipV3PayDetail.js"; +export { PayslipV3PayPeriod } from "./payslipV3PayPeriod.js"; +export { PayslipV3SalaryDetail } from "./payslipV3SalaryDetail.js"; diff --git a/src/product/fr/payslip/internal.ts b/src/product/fr/payslip/internal.ts deleted file mode 100644 index cefd5848..00000000 --- a/src/product/fr/payslip/internal.ts +++ /dev/null @@ -1,20 +0,0 @@ -export { PayslipV2 } from "./payslipV2"; -export { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail"; -export { PayslipV2Document } from "./payslipV2Document"; -export { PayslipV2Employee } from "./payslipV2Employee"; -export { PayslipV2Employer } from "./payslipV2Employer"; -export { PayslipV2Employment } from "./payslipV2Employment"; -export { PayslipV2PayDetail } from "./payslipV2PayDetail"; -export { PayslipV2PayPeriod } from "./payslipV2PayPeriod"; -export { PayslipV2Pto } from "./payslipV2Pto"; -export { PayslipV2SalaryDetail } from "./payslipV2SalaryDetail"; -export { PayslipV3 } from "./payslipV3"; -export { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail"; -export { PayslipV3Document } from "./payslipV3Document"; -export { PayslipV3Employee } from "./payslipV3Employee"; -export { PayslipV3Employer } from "./payslipV3Employer"; -export { PayslipV3Employment } from "./payslipV3Employment"; -export { PayslipV3PaidTimeOff } from "./payslipV3PaidTimeOff"; -export { PayslipV3PayDetail } from "./payslipV3PayDetail"; -export { PayslipV3PayPeriod } from "./payslipV3PayPeriod"; -export { PayslipV3SalaryDetail } from "./payslipV3SalaryDetail"; diff --git a/src/product/fr/payslip/payslipV2.ts b/src/product/fr/payslip/payslipV2.ts index cb1e12ea..2ae4d0f0 100644 --- a/src/product/fr/payslip/payslipV2.ts +++ b/src/product/fr/payslip/payslipV2.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { PayslipV2Document } from "./payslipV2Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { PayslipV2Document } from "./payslipV2Document.js"; /** * Payslip API version 2 inference prediction. diff --git a/src/product/fr/payslip/payslipV2BankAccountDetail.ts b/src/product/fr/payslip/payslipV2BankAccountDetail.ts index 033f531b..0fba12d1 100644 --- a/src/product/fr/payslip/payslipV2BankAccountDetail.ts +++ b/src/product/fr/payslip/payslipV2BankAccountDetail.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employee's bank account. diff --git a/src/product/fr/payslip/payslipV2Document.ts b/src/product/fr/payslip/payslipV2Document.ts index 83126ef0..3750c764 100644 --- a/src/product/fr/payslip/payslipV2Document.ts +++ b/src/product/fr/payslip/payslipV2Document.ts @@ -2,15 +2,15 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../../parsing/common"; -import { PayslipV2Employee } from "./payslipV2Employee"; -import { PayslipV2Employer } from "./payslipV2Employer"; -import { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail"; -import { PayslipV2Employment } from "./payslipV2Employment"; -import { PayslipV2SalaryDetail } from "./payslipV2SalaryDetail"; -import { PayslipV2PayDetail } from "./payslipV2PayDetail"; -import { PayslipV2Pto } from "./payslipV2Pto"; -import { PayslipV2PayPeriod } from "./payslipV2PayPeriod"; +} from "@/parsing/common/index.js"; +import { PayslipV2Employee } from "./payslipV2Employee.js"; +import { PayslipV2Employer } from "./payslipV2Employer.js"; +import { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail.js"; +import { PayslipV2Employment } from "./payslipV2Employment.js"; +import { PayslipV2SalaryDetail } from "./payslipV2SalaryDetail.js"; +import { PayslipV2PayDetail } from "./payslipV2PayDetail.js"; +import { PayslipV2Pto } from "./payslipV2Pto.js"; +import { PayslipV2PayPeriod } from "./payslipV2PayPeriod.js"; /** diff --git a/src/product/fr/payslip/payslipV2Employee.ts b/src/product/fr/payslip/payslipV2Employee.ts index 3c0faf61..12fe4384 100644 --- a/src/product/fr/payslip/payslipV2Employee.ts +++ b/src/product/fr/payslip/payslipV2Employee.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employee. diff --git a/src/product/fr/payslip/payslipV2Employer.ts b/src/product/fr/payslip/payslipV2Employer.ts index a499595b..de778ac2 100644 --- a/src/product/fr/payslip/payslipV2Employer.ts +++ b/src/product/fr/payslip/payslipV2Employer.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employer. diff --git a/src/product/fr/payslip/payslipV2Employment.ts b/src/product/fr/payslip/payslipV2Employment.ts index 14dacdc3..fd2a656a 100644 --- a/src/product/fr/payslip/payslipV2Employment.ts +++ b/src/product/fr/payslip/payslipV2Employment.ts @@ -1,7 +1,6 @@ - -import { floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employment. diff --git a/src/product/fr/payslip/payslipV2PayDetail.ts b/src/product/fr/payslip/payslipV2PayDetail.ts index c5486b94..6012131b 100644 --- a/src/product/fr/payslip/payslipV2PayDetail.ts +++ b/src/product/fr/payslip/payslipV2PayDetail.ts @@ -1,7 +1,6 @@ - -import { floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Detailed information about the pay. diff --git a/src/product/fr/payslip/payslipV2PayPeriod.ts b/src/product/fr/payslip/payslipV2PayPeriod.ts index a1d82acf..1e1eb093 100644 --- a/src/product/fr/payslip/payslipV2PayPeriod.ts +++ b/src/product/fr/payslip/payslipV2PayPeriod.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the pay period. diff --git a/src/product/fr/payslip/payslipV2Pto.ts b/src/product/fr/payslip/payslipV2Pto.ts index bd604f97..b6a41d2c 100644 --- a/src/product/fr/payslip/payslipV2Pto.ts +++ b/src/product/fr/payslip/payslipV2Pto.ts @@ -1,7 +1,6 @@ - -import { floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about paid time off. diff --git a/src/product/fr/payslip/payslipV2SalaryDetail.ts b/src/product/fr/payslip/payslipV2SalaryDetail.ts index 630bca80..c15a29eb 100644 --- a/src/product/fr/payslip/payslipV2SalaryDetail.ts +++ b/src/product/fr/payslip/payslipV2SalaryDetail.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Detailed information about the earnings. diff --git a/src/product/fr/payslip/payslipV3.ts b/src/product/fr/payslip/payslipV3.ts index 17f317b6..04bc2af0 100644 --- a/src/product/fr/payslip/payslipV3.ts +++ b/src/product/fr/payslip/payslipV3.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { PayslipV3Document } from "./payslipV3Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { PayslipV3Document } from "./payslipV3Document.js"; /** * Payslip API version 3 inference prediction. diff --git a/src/product/fr/payslip/payslipV3BankAccountDetail.ts b/src/product/fr/payslip/payslipV3BankAccountDetail.ts index 3ec0f2b1..e79fa690 100644 --- a/src/product/fr/payslip/payslipV3BankAccountDetail.ts +++ b/src/product/fr/payslip/payslipV3BankAccountDetail.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employee's bank account. diff --git a/src/product/fr/payslip/payslipV3Document.ts b/src/product/fr/payslip/payslipV3Document.ts index 671da64f..cae6d91c 100644 --- a/src/product/fr/payslip/payslipV3Document.ts +++ b/src/product/fr/payslip/payslipV3Document.ts @@ -2,15 +2,15 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../../parsing/common"; -import { PayslipV3PayPeriod } from "./payslipV3PayPeriod"; -import { PayslipV3Employee } from "./payslipV3Employee"; -import { PayslipV3Employer } from "./payslipV3Employer"; -import { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail"; -import { PayslipV3Employment } from "./payslipV3Employment"; -import { PayslipV3SalaryDetail } from "./payslipV3SalaryDetail"; -import { PayslipV3PayDetail } from "./payslipV3PayDetail"; -import { PayslipV3PaidTimeOff } from "./payslipV3PaidTimeOff"; +} from "@/parsing/common/index.js"; +import { PayslipV3PayPeriod } from "./payslipV3PayPeriod.js"; +import { PayslipV3Employee } from "./payslipV3Employee.js"; +import { PayslipV3Employer } from "./payslipV3Employer.js"; +import { PayslipV3BankAccountDetail } from "./payslipV3BankAccountDetail.js"; +import { PayslipV3Employment } from "./payslipV3Employment.js"; +import { PayslipV3SalaryDetail } from "./payslipV3SalaryDetail.js"; +import { PayslipV3PayDetail } from "./payslipV3PayDetail.js"; +import { PayslipV3PaidTimeOff } from "./payslipV3PaidTimeOff.js"; /** diff --git a/src/product/fr/payslip/payslipV3Employee.ts b/src/product/fr/payslip/payslipV3Employee.ts index b93f3c7a..7037503d 100644 --- a/src/product/fr/payslip/payslipV3Employee.ts +++ b/src/product/fr/payslip/payslipV3Employee.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employee. diff --git a/src/product/fr/payslip/payslipV3Employer.ts b/src/product/fr/payslip/payslipV3Employer.ts index 118dc30c..8d5e551d 100644 --- a/src/product/fr/payslip/payslipV3Employer.ts +++ b/src/product/fr/payslip/payslipV3Employer.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employer. diff --git a/src/product/fr/payslip/payslipV3Employment.ts b/src/product/fr/payslip/payslipV3Employment.ts index 7b2bf817..09230310 100644 --- a/src/product/fr/payslip/payslipV3Employment.ts +++ b/src/product/fr/payslip/payslipV3Employment.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the employment. diff --git a/src/product/fr/payslip/payslipV3PaidTimeOff.ts b/src/product/fr/payslip/payslipV3PaidTimeOff.ts index c8fd1bc2..82a49910 100644 --- a/src/product/fr/payslip/payslipV3PaidTimeOff.ts +++ b/src/product/fr/payslip/payslipV3PaidTimeOff.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about paid time off. diff --git a/src/product/fr/payslip/payslipV3PayDetail.ts b/src/product/fr/payslip/payslipV3PayDetail.ts index 1dfb45f8..1e3f5777 100644 --- a/src/product/fr/payslip/payslipV3PayDetail.ts +++ b/src/product/fr/payslip/payslipV3PayDetail.ts @@ -1,7 +1,6 @@ - -import { floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Detailed information about the pay. diff --git a/src/product/fr/payslip/payslipV3PayPeriod.ts b/src/product/fr/payslip/payslipV3PayPeriod.ts index 418308d2..0feb3465 100644 --- a/src/product/fr/payslip/payslipV3PayPeriod.ts +++ b/src/product/fr/payslip/payslipV3PayPeriod.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Information about the pay period. diff --git a/src/product/fr/payslip/payslipV3SalaryDetail.ts b/src/product/fr/payslip/payslipV3SalaryDetail.ts index 2194467d..37927c77 100644 --- a/src/product/fr/payslip/payslipV3SalaryDetail.ts +++ b/src/product/fr/payslip/payslipV3SalaryDetail.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * Detailed information about the earnings. diff --git a/src/product/generated/generatedV1.ts b/src/product/generated/generatedV1.ts index daa99c95..0af4a461 100644 --- a/src/product/generated/generatedV1.ts +++ b/src/product/generated/generatedV1.ts @@ -1,6 +1,6 @@ -import { Inference, Page, StringDict } from "../../../src/parsing/common"; -import { GeneratedV1Document } from "./generatedV1Document"; -import { GeneratedV1Page } from "./generatedV1Page"; +import { Inference, Page, StringDict } from "@/parsing/common/index.js"; +import { GeneratedV1Document } from "./generatedV1Document.js"; +import { GeneratedV1Page } from "./generatedV1Page.js"; /** * Generated API V1 inference results. diff --git a/src/product/generated/generatedV1Document.ts b/src/product/generated/generatedV1Document.ts index 11477eb4..80a00bff 100644 --- a/src/product/generated/generatedV1Document.ts +++ b/src/product/generated/generatedV1Document.ts @@ -1,7 +1,7 @@ -import { StringDict } from "../../../src/parsing/common"; -import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "../../../src/parsing/generated"; -import { StringField } from "../../../src/parsing/standard"; -import { GeneratedV1Prediction } from "./generatedV1Prediction"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "@/parsing/generated/index.js"; +import { StringField } from "@/parsing/standard/index.js"; +import { GeneratedV1Prediction } from "./generatedV1Prediction.js"; /** * Generated V1 document prediction results. diff --git a/src/product/generated/generatedV1Page.ts b/src/product/generated/generatedV1Page.ts index e99aff5f..77c1ad0a 100644 --- a/src/product/generated/generatedV1Page.ts +++ b/src/product/generated/generatedV1Page.ts @@ -1,7 +1,7 @@ -import { StringDict } from "../../../src/parsing/common"; -import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "../../../src/parsing/generated"; -import { StringField } from "../../../src/parsing/standard"; -import { GeneratedV1Prediction } from "./generatedV1Prediction"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "@/parsing/generated/index.js"; +import { StringField } from "@/parsing/standard/index.js"; +import { GeneratedV1Prediction } from "./generatedV1Prediction.js"; /** * Generated V1 page prediction results. diff --git a/src/product/generated/generatedV1Prediction.ts b/src/product/generated/generatedV1Prediction.ts index 701e87be..876f5df7 100644 --- a/src/product/generated/generatedV1Prediction.ts +++ b/src/product/generated/generatedV1Prediction.ts @@ -1,6 +1,6 @@ -import { Prediction, cleanOutString } from "../../../src/parsing/common"; -import { GeneratedListField, GeneratedObjectField } from "../../../src/parsing/generated"; -import { StringField } from "../../../src/parsing/standard"; +import { Prediction, cleanOutString } from "@/parsing/common/index.js"; +import { GeneratedListField, GeneratedObjectField } from "@/parsing/generated/index.js"; +import { StringField } from "@/parsing/standard/index.js"; export class GeneratedV1Prediction implements Prediction { diff --git a/src/product/generated/index.ts b/src/product/generated/index.ts new file mode 100644 index 00000000..b90e4ba8 --- /dev/null +++ b/src/product/generated/index.ts @@ -0,0 +1,4 @@ +export { GeneratedV1 } from "./generatedV1.js"; +export { GeneratedV1Document } from "./generatedV1Document.js"; +export { GeneratedV1Page } from "./generatedV1Page.js"; +export { GeneratedV1Prediction } from "./generatedV1Prediction.js"; diff --git a/src/product/generated/internal.ts b/src/product/generated/internal.ts deleted file mode 100644 index cacc7d5a..00000000 --- a/src/product/generated/internal.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { GeneratedV1 } from "./generatedV1"; -export { GeneratedV1Document } from "./generatedV1Document"; -export { GeneratedV1Page } from "./generatedV1Page"; -export { GeneratedV1Prediction } from "./generatedV1Prediction"; diff --git a/src/product/ind/index.ts b/src/product/ind/index.ts index 0be5c632..3249f812 100644 --- a/src/product/ind/index.ts +++ b/src/product/ind/index.ts @@ -1 +1 @@ -export { IndianPassportV1 } from "./indianPassport/indianPassportV1"; +export { IndianPassportV1 } from "./indianPassport/index.js"; diff --git a/src/product/ind/indianPassport/index.ts b/src/product/ind/indianPassport/index.ts index 5267a54b..cafb0465 100644 --- a/src/product/ind/indianPassport/index.ts +++ b/src/product/ind/indianPassport/index.ts @@ -1 +1,2 @@ -export { IndianPassportV1 } from "./indianPassportV1"; +export { IndianPassportV1 } from "./indianPassportV1.js"; +export { IndianPassportV1Document } from "./indianPassportV1Document.js"; diff --git a/src/product/ind/indianPassport/indianPassportV1.ts b/src/product/ind/indianPassport/indianPassportV1.ts index fe377f8c..1bba02fb 100644 --- a/src/product/ind/indianPassport/indianPassportV1.ts +++ b/src/product/ind/indianPassport/indianPassportV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { IndianPassportV1Document } from "./indianPassportV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { IndianPassportV1Document } from "./indianPassportV1Document.js"; /** * Passport - India API version 1 inference prediction. diff --git a/src/product/ind/indianPassport/indianPassportV1Document.ts b/src/product/ind/indianPassport/indianPassportV1Document.ts index c71ac7a6..97f9ca5a 100644 --- a/src/product/ind/indianPassport/indianPassportV1Document.ts +++ b/src/product/ind/indianPassport/indianPassportV1Document.ts @@ -2,12 +2,12 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; +} from "@/parsing/common/index.js"; import { ClassificationField, DateField, StringField, -} from "../../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * Passport - India API version 1.2 document data. diff --git a/src/product/ind/indianPassport/internal.ts b/src/product/ind/indianPassport/internal.ts deleted file mode 100644 index f9473599..00000000 --- a/src/product/ind/indianPassport/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { IndianPassportV1 } from "./indianPassportV1"; -export { IndianPassportV1Document } from "./indianPassportV1Document"; diff --git a/src/product/ind/internal.ts b/src/product/ind/internal.ts index fb8c2c7e..2dc538de 100644 --- a/src/product/ind/internal.ts +++ b/src/product/ind/internal.ts @@ -1 +1 @@ -export * as indianPassport from "./indianPassport/internal"; +export * as indianPassport from "./indianPassport/index.js"; diff --git a/src/product/index.ts b/src/product/index.ts index 286822f0..faf6b179 100644 --- a/src/product/index.ts +++ b/src/product/index.ts @@ -1,20 +1,15 @@ -export * as fr from "./fr"; -export * as ind from "./ind"; -export * as us from "./us"; -export { BarcodeReaderV1 } from "./barcodeReader/barcodeReaderV1"; -export { BillOfLadingV1 } from "./billOfLading/billOfLadingV1"; -export { BusinessCardV1 } from "./businessCard/businessCardV1"; -export { CropperV1 } from "./cropper/cropperV1"; -export { CustomV1 } from "./custom/customV1"; -export { DeliveryNoteV1 } from "./deliveryNote/deliveryNoteV1"; -export { DriverLicenseV1 } from "./driverLicense/driverLicenseV1"; -export { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1"; -export { GeneratedV1 } from "./generated/generatedV1"; -export { InternationalIdV2 } from "./internationalId/internationalIdV2"; -export { InvoiceSplitterV1 } from "./invoiceSplitter/invoiceSplitterV1"; -export { InvoiceV4 } from "./invoice/invoiceV4"; -export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetector/multiReceiptsDetectorV1"; -export { NutritionFactsLabelV1 } from "./nutritionFactsLabel/nutritionFactsLabelV1"; -export { PassportV1 } from "./passport/passportV1"; -export { ReceiptV5 } from "./receipt/receiptV5"; -export { ResumeV1 } from "./resume/resumeV1"; +export * as fr from "./fr/index.js"; +export * as ind from "./ind/index.js"; +export * as us from "./us/index.js"; +export { BarcodeReaderV1 } from "./barcodeReader/index.js"; +export { CropperV1 } from "./cropper/index.js"; +export { DriverLicenseV1 } from "./driverLicense/index.js"; +export { FinancialDocumentV1 } from "./financialDocument/index.js"; +export { GeneratedV1 } from "./generated/index.js"; +export { InternationalIdV2 } from "./internationalId/index.js"; +export { InvoiceSplitterV1 } from "./invoiceSplitter/index.js"; +export { InvoiceV4 } from "./invoice/index.js"; +export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetector/index.js"; +export { PassportV1 } from "./passport/index.js"; +export { ReceiptV5 } from "./receipt/index.js"; +export { ResumeV1 } from "./resume/index.js"; diff --git a/src/product/internal.ts b/src/product/internal.ts index 2e181bc3..2112bb85 100644 --- a/src/product/internal.ts +++ b/src/product/internal.ts @@ -1,20 +1,15 @@ -export * as barcodeReader from "./barcodeReader/internal"; -export * as billOfLading from "./billOfLading/internal"; -export * as businessCard from "./businessCard/internal"; -export * as cropper from "./cropper/internal"; -export * as custom from "./custom/internal"; -export * as deliveryNote from "./deliveryNote/internal"; -export * as driverLicense from "./driverLicense/internal"; -export * as financialDocument from "./financialDocument/internal"; -export * as fr from "./fr/internal"; -export * as generated from "./generated/internal"; -export * as ind from "./ind/internal"; -export * as internationalId from "./internationalId/internal"; -export * as invoice from "./invoice/internal"; -export * as invoiceSplitter from "./invoiceSplitter/internal"; -export * as multiReceiptsDetector from "./multiReceiptsDetector/internal"; -export * as nutritionFactsLabel from "./nutritionFactsLabel/internal"; -export * as passport from "./passport/internal"; -export * as receipt from "./receipt/internal"; -export * as resume from "./resume/internal"; -export * as us from "./us/internal"; +export * as barcodeReader from "./barcodeReader/index.js"; +export * as cropper from "./cropper/index.js"; +export * as driverLicense from "./driverLicense/index.js"; +export * as financialDocument from "./financialDocument/index.js"; +export * as fr from "./fr/index.js"; +export * as generated from "./generated/index.js"; +export * as ind from "./ind/index.js"; +export * as internationalId from "./internationalId/index.js"; +export * as invoice from "./invoice/index.js"; +export * as invoiceSplitter from "./invoiceSplitter/index.js"; +export * as multiReceiptsDetector from "./multiReceiptsDetector/index.js"; +export * as passport from "./passport/index.js"; +export * as receipt from "./receipt/index.js"; +export * as resume from "./resume/index.js"; +export * as us from "./us/index.js"; diff --git a/src/product/internationalId/index.ts b/src/product/internationalId/index.ts index 40a70d3b..50fa6434 100644 --- a/src/product/internationalId/index.ts +++ b/src/product/internationalId/index.ts @@ -1 +1,2 @@ -export { InternationalIdV2 } from "./internationalIdV2"; +export { InternationalIdV2 } from "./internationalIdV2.js"; +export { InternationalIdV2Document } from "./internationalIdV2Document.js"; diff --git a/src/product/internationalId/internal.ts b/src/product/internationalId/internal.ts deleted file mode 100644 index 0e8a70ee..00000000 --- a/src/product/internationalId/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { InternationalIdV2 } from "./internationalIdV2"; -export { InternationalIdV2Document } from "./internationalIdV2Document"; diff --git a/src/product/internationalId/internationalIdV2.ts b/src/product/internationalId/internationalIdV2.ts index 2225971e..a3941911 100644 --- a/src/product/internationalId/internationalIdV2.ts +++ b/src/product/internationalId/internationalIdV2.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { InternationalIdV2Document } from "./internationalIdV2Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { InternationalIdV2Document } from "./internationalIdV2Document.js"; /** * International ID API version 2 inference prediction. diff --git a/src/product/internationalId/internationalIdV2Document.ts b/src/product/internationalId/internationalIdV2Document.ts index 4cb541e6..f9791400 100644 --- a/src/product/internationalId/internationalIdV2Document.ts +++ b/src/product/internationalId/internationalIdV2Document.ts @@ -2,12 +2,12 @@ import { Prediction, StringDict, cleanOutString, -} from "../../parsing/common"; +} from "@/parsing/common/index.js"; import { ClassificationField, DateField, StringField, -} from "../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * International ID API version 2.2 document data. diff --git a/src/product/invoice/index.ts b/src/product/invoice/index.ts index 69cff0b0..32f41de9 100644 --- a/src/product/invoice/index.ts +++ b/src/product/invoice/index.ts @@ -1 +1,3 @@ -export { InvoiceV4 } from "./invoiceV4"; +export { InvoiceV4 } from "./invoiceV4.js"; +export { InvoiceV4Document } from "./invoiceV4Document.js"; +export { InvoiceV4LineItem } from "./invoiceV4LineItem.js"; diff --git a/src/product/invoice/internal.ts b/src/product/invoice/internal.ts deleted file mode 100644 index 3138e93f..00000000 --- a/src/product/invoice/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { InvoiceV4 } from "./invoiceV4"; -export { InvoiceV4Document } from "./invoiceV4Document"; -export { InvoiceV4LineItem } from "./invoiceV4LineItem"; diff --git a/src/product/invoice/invoiceV4.ts b/src/product/invoice/invoiceV4.ts index 2c396fbf..fd5e6c39 100644 --- a/src/product/invoice/invoiceV4.ts +++ b/src/product/invoice/invoiceV4.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { InvoiceV4Document } from "./invoiceV4Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { InvoiceV4Document } from "./invoiceV4Document.js"; /** * Invoice API version 4 inference prediction. diff --git a/src/product/invoice/invoiceV4Document.ts b/src/product/invoice/invoiceV4Document.ts index 745a703d..55b7e4e8 100644 --- a/src/product/invoice/invoiceV4Document.ts +++ b/src/product/invoice/invoiceV4Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { InvoiceV4LineItem } from "./invoiceV4LineItem"; +} from "@/parsing/common/index.js"; +import { InvoiceV4LineItem } from "./invoiceV4LineItem.js"; import { AddressField, AmountField, @@ -14,7 +14,7 @@ import { PaymentDetailsField, StringField, Taxes, -} from "../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * Invoice API version 4.11 document data. diff --git a/src/product/invoice/invoiceV4LineItem.ts b/src/product/invoice/invoiceV4LineItem.ts index ebfa4a9b..5cebf2a6 100644 --- a/src/product/invoice/invoiceV4LineItem.ts +++ b/src/product/invoice/invoiceV4LineItem.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * List of all the line items present on the invoice. diff --git a/src/product/invoiceSplitter/index.ts b/src/product/invoiceSplitter/index.ts index e7e1db9f..f4782577 100644 --- a/src/product/invoiceSplitter/index.ts +++ b/src/product/invoiceSplitter/index.ts @@ -1 +1,3 @@ -export { InvoiceSplitterV1 } from "./invoiceSplitterV1"; +export { InvoiceSplitterV1 } from "./invoiceSplitterV1.js"; +export { InvoiceSplitterV1Document } from "./invoiceSplitterV1Document.js"; +export { InvoiceSplitterV1InvoicePageGroup } from "./invoiceSplitterV1InvoicePageGroup.js"; diff --git a/src/product/invoiceSplitter/internal.ts b/src/product/invoiceSplitter/internal.ts deleted file mode 100644 index c3bdb5f6..00000000 --- a/src/product/invoiceSplitter/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { InvoiceSplitterV1 } from "./invoiceSplitterV1"; -export { InvoiceSplitterV1Document } from "./invoiceSplitterV1Document"; -export { InvoiceSplitterV1InvoicePageGroup } from "./invoiceSplitterV1InvoicePageGroup"; diff --git a/src/product/invoiceSplitter/invoiceSplitterV1.ts b/src/product/invoiceSplitter/invoiceSplitterV1.ts index 8d242e2b..60e09985 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1.ts +++ b/src/product/invoiceSplitter/invoiceSplitterV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { InvoiceSplitterV1Document } from "./invoiceSplitterV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { InvoiceSplitterV1Document } from "./invoiceSplitterV1Document.js"; /** * Invoice Splitter API version 1 inference prediction. diff --git a/src/product/invoiceSplitter/invoiceSplitterV1Document.ts b/src/product/invoiceSplitter/invoiceSplitterV1Document.ts index fdc50e94..d9374c82 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1Document.ts +++ b/src/product/invoiceSplitter/invoiceSplitterV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { InvoiceSplitterV1InvoicePageGroup } from "./invoiceSplitterV1InvoicePageGroup"; +} from "@/parsing/common/index.js"; +import { InvoiceSplitterV1InvoicePageGroup } from "./invoiceSplitterV1InvoicePageGroup.js"; /** diff --git a/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts b/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts index ad99026b..4eb1de28 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts +++ b/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * List of page groups. Each group represents a single invoice within a multi-invoice document. diff --git a/src/product/multiReceiptsDetector/index.ts b/src/product/multiReceiptsDetector/index.ts index 9f3e8d86..5a44ecb6 100644 --- a/src/product/multiReceiptsDetector/index.ts +++ b/src/product/multiReceiptsDetector/index.ts @@ -1 +1,2 @@ -export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetectorV1"; +export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetectorV1.js"; +export { MultiReceiptsDetectorV1Document } from "./multiReceiptsDetectorV1Document.js"; diff --git a/src/product/multiReceiptsDetector/internal.ts b/src/product/multiReceiptsDetector/internal.ts deleted file mode 100644 index 1eea01bb..00000000 --- a/src/product/multiReceiptsDetector/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetectorV1"; -export { MultiReceiptsDetectorV1Document } from "./multiReceiptsDetectorV1Document"; diff --git a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts b/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts index eb935c8f..28e39d03 100644 --- a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts +++ b/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { MultiReceiptsDetectorV1Document } from "./multiReceiptsDetectorV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { MultiReceiptsDetectorV1Document } from "./multiReceiptsDetectorV1Document.js"; /** * Multi Receipts Detector API version 1 inference prediction. diff --git a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts b/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts index d54709b7..402bb9fc 100644 --- a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts +++ b/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../parsing/common"; -import { PositionField } from "../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { PositionField } from "@/parsing/standard/index.js"; /** * Multi Receipts Detector API version 1.1 document data. diff --git a/src/product/nutritionFactsLabel/index.ts b/src/product/nutritionFactsLabel/index.ts deleted file mode 100644 index 7be4db39..00000000 --- a/src/product/nutritionFactsLabel/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { NutritionFactsLabelV1 } from "./nutritionFactsLabelV1"; diff --git a/src/product/nutritionFactsLabel/internal.ts b/src/product/nutritionFactsLabel/internal.ts deleted file mode 100644 index 1c18c00f..00000000 --- a/src/product/nutritionFactsLabel/internal.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { NutritionFactsLabelV1 } from "./nutritionFactsLabelV1"; -export { NutritionFactsLabelV1AddedSugar } from "./nutritionFactsLabelV1AddedSugar"; -export { NutritionFactsLabelV1Calorie } from "./nutritionFactsLabelV1Calorie"; -export { NutritionFactsLabelV1Cholesterol } from "./nutritionFactsLabelV1Cholesterol"; -export { NutritionFactsLabelV1DietaryFiber } from "./nutritionFactsLabelV1DietaryFiber"; -export { NutritionFactsLabelV1Document } from "./nutritionFactsLabelV1Document"; -export { NutritionFactsLabelV1Nutrient } from "./nutritionFactsLabelV1Nutrient"; -export { NutritionFactsLabelV1Protein } from "./nutritionFactsLabelV1Protein"; -export { NutritionFactsLabelV1SaturatedFat } from "./nutritionFactsLabelV1SaturatedFat"; -export { NutritionFactsLabelV1ServingSize } from "./nutritionFactsLabelV1ServingSize"; -export { NutritionFactsLabelV1Sodium } from "./nutritionFactsLabelV1Sodium"; -export { NutritionFactsLabelV1TotalCarbohydrate } from "./nutritionFactsLabelV1TotalCarbohydrate"; -export { NutritionFactsLabelV1TotalFat } from "./nutritionFactsLabelV1TotalFat"; -export { NutritionFactsLabelV1TotalSugar } from "./nutritionFactsLabelV1TotalSugar"; -export { NutritionFactsLabelV1TransFat } from "./nutritionFactsLabelV1TransFat"; diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1.ts deleted file mode 100644 index 38b20fc5..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { NutritionFactsLabelV1Document } from "./nutritionFactsLabelV1Document"; - -/** - * Nutrition Facts Label API version 1 inference prediction. - */ -export class NutritionFactsLabelV1 extends Inference { - /** The endpoint's name. */ - endpointName = "nutrition_facts"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: NutritionFactsLabelV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new NutritionFactsLabelV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - NutritionFactsLabelV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts deleted file mode 100644 index 1a915c83..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of added sugars in the product. - */ -export class NutritionFactsLabelV1AddedSugar { - /** DVs are the recommended amounts of added sugars to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of added sugars per 100g of the product. */ - per100G: number | null; - /** The amount of added sugars per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts deleted file mode 100644 index e9d800c7..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of calories in the product. - */ -export class NutritionFactsLabelV1Calorie { - /** DVs are the recommended amounts of calories to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of calories per 100g of the product. */ - per100G: number | null; - /** The amount of calories per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts deleted file mode 100644 index 3dac2631..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of cholesterol in the product. - */ -export class NutritionFactsLabelV1Cholesterol { - /** DVs are the recommended amounts of cholesterol to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of cholesterol per 100g of the product. */ - per100G: number | null; - /** The amount of cholesterol per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts deleted file mode 100644 index 0c2318be..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of dietary fiber in the product. - */ -export class NutritionFactsLabelV1DietaryFiber { - /** DVs are the recommended amounts of dietary fiber to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of dietary fiber per 100g of the product. */ - per100G: number | null; - /** The amount of dietary fiber per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.ts deleted file mode 100644 index d6a04204..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { NutritionFactsLabelV1ServingSize } from "./nutritionFactsLabelV1ServingSize"; -import { NutritionFactsLabelV1Calorie } from "./nutritionFactsLabelV1Calorie"; -import { NutritionFactsLabelV1TotalFat } from "./nutritionFactsLabelV1TotalFat"; -import { NutritionFactsLabelV1SaturatedFat } from "./nutritionFactsLabelV1SaturatedFat"; -import { NutritionFactsLabelV1TransFat } from "./nutritionFactsLabelV1TransFat"; -import { NutritionFactsLabelV1Cholesterol } from "./nutritionFactsLabelV1Cholesterol"; -import { NutritionFactsLabelV1TotalCarbohydrate } from "./nutritionFactsLabelV1TotalCarbohydrate"; -import { NutritionFactsLabelV1DietaryFiber } from "./nutritionFactsLabelV1DietaryFiber"; -import { NutritionFactsLabelV1TotalSugar } from "./nutritionFactsLabelV1TotalSugar"; -import { NutritionFactsLabelV1AddedSugar } from "./nutritionFactsLabelV1AddedSugar"; -import { NutritionFactsLabelV1Protein } from "./nutritionFactsLabelV1Protein"; -import { NutritionFactsLabelV1Sodium } from "./nutritionFactsLabelV1Sodium"; -import { NutritionFactsLabelV1Nutrient } from "./nutritionFactsLabelV1Nutrient"; -import { AmountField } from "../../parsing/standard"; - -/** - * Nutrition Facts Label API version 1.0 document data. - */ -export class NutritionFactsLabelV1Document implements Prediction { - /** The amount of added sugars in the product. */ - addedSugars: NutritionFactsLabelV1AddedSugar; - /** The amount of calories in the product. */ - calories: NutritionFactsLabelV1Calorie; - /** The amount of cholesterol in the product. */ - cholesterol: NutritionFactsLabelV1Cholesterol; - /** The amount of dietary fiber in the product. */ - dietaryFiber: NutritionFactsLabelV1DietaryFiber; - /** The amount of nutrients in the product. */ - nutrients: NutritionFactsLabelV1Nutrient[] = []; - /** The amount of protein in the product. */ - protein: NutritionFactsLabelV1Protein; - /** The amount of saturated fat in the product. */ - saturatedFat: NutritionFactsLabelV1SaturatedFat; - /** The number of servings in each box of the product. */ - servingPerBox: AmountField; - /** The size of a single serving of the product. */ - servingSize: NutritionFactsLabelV1ServingSize; - /** The amount of sodium in the product. */ - sodium: NutritionFactsLabelV1Sodium; - /** The total amount of carbohydrates in the product. */ - totalCarbohydrate: NutritionFactsLabelV1TotalCarbohydrate; - /** The total amount of fat in the product. */ - totalFat: NutritionFactsLabelV1TotalFat; - /** The total amount of sugars in the product. */ - totalSugars: NutritionFactsLabelV1TotalSugar; - /** The amount of trans fat in the product. */ - transFat: NutritionFactsLabelV1TransFat; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.addedSugars = new NutritionFactsLabelV1AddedSugar({ - prediction: rawPrediction["added_sugars"], - pageId: pageId, - }); - this.calories = new NutritionFactsLabelV1Calorie({ - prediction: rawPrediction["calories"], - pageId: pageId, - }); - this.cholesterol = new NutritionFactsLabelV1Cholesterol({ - prediction: rawPrediction["cholesterol"], - pageId: pageId, - }); - this.dietaryFiber = new NutritionFactsLabelV1DietaryFiber({ - prediction: rawPrediction["dietary_fiber"], - pageId: pageId, - }); - rawPrediction["nutrients"] && - rawPrediction["nutrients"].map( - (itemPrediction: StringDict) => - this.nutrients.push( - new NutritionFactsLabelV1Nutrient({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.protein = new NutritionFactsLabelV1Protein({ - prediction: rawPrediction["protein"], - pageId: pageId, - }); - this.saturatedFat = new NutritionFactsLabelV1SaturatedFat({ - prediction: rawPrediction["saturated_fat"], - pageId: pageId, - }); - this.servingPerBox = new AmountField({ - prediction: rawPrediction["serving_per_box"], - pageId: pageId, - }); - this.servingSize = new NutritionFactsLabelV1ServingSize({ - prediction: rawPrediction["serving_size"], - pageId: pageId, - }); - this.sodium = new NutritionFactsLabelV1Sodium({ - prediction: rawPrediction["sodium"], - pageId: pageId, - }); - this.totalCarbohydrate = new NutritionFactsLabelV1TotalCarbohydrate({ - prediction: rawPrediction["total_carbohydrate"], - pageId: pageId, - }); - this.totalFat = new NutritionFactsLabelV1TotalFat({ - prediction: rawPrediction["total_fat"], - pageId: pageId, - }); - this.totalSugars = new NutritionFactsLabelV1TotalSugar({ - prediction: rawPrediction["total_sugars"], - pageId: pageId, - }); - this.transFat = new NutritionFactsLabelV1TransFat({ - prediction: rawPrediction["trans_fat"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - let nutrientsSummary:string = ""; - if (this.nutrients && this.nutrients.length > 0) { - const nutrientsColSizes:number[] = [13, 22, 10, 13, 6]; - nutrientsSummary += "\n" + lineSeparator(nutrientsColSizes, "-") + "\n "; - nutrientsSummary += "| Daily Value "; - nutrientsSummary += "| Name "; - nutrientsSummary += "| Per 100g "; - nutrientsSummary += "| Per Serving "; - nutrientsSummary += "| Unit "; - nutrientsSummary += "|\n" + lineSeparator(nutrientsColSizes, "="); - nutrientsSummary += this.nutrients.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(nutrientsColSizes, "-") - ).join(""); - } - const outStr = `:Serving per Box: ${this.servingPerBox} -:Serving Size: ${this.servingSize.toFieldList()} -:Calories: ${this.calories.toFieldList()} -:Total Fat: ${this.totalFat.toFieldList()} -:Saturated Fat: ${this.saturatedFat.toFieldList()} -:Trans Fat: ${this.transFat.toFieldList()} -:Cholesterol: ${this.cholesterol.toFieldList()} -:Total Carbohydrate: ${this.totalCarbohydrate.toFieldList()} -:Dietary Fiber: ${this.dietaryFiber.toFieldList()} -:Total Sugars: ${this.totalSugars.toFieldList()} -:Added Sugars: ${this.addedSugars.toFieldList()} -:Protein: ${this.protein.toFieldList()} -:sodium: ${this.sodium.toFieldList()} -:nutrients: ${nutrientsSummary}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts deleted file mode 100644 index fb0522e8..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { cleanSpecialChars, floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of nutrients in the product. - */ -export class NutritionFactsLabelV1Nutrient { - /** DVs are the recommended amounts of nutrients to consume or not to exceed each day. */ - dailyValue: number | null; - /** The name of nutrients of the product. */ - name: string | null; - /** The amount of nutrients per 100g of the product. */ - per100G: number | null; - /** The amount of nutrients per serving of the product. */ - perServing: number | null; - /** The unit of measurement for the amount of nutrients. */ - unit: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - this.name = prediction["name"]; - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.unit = prediction["unit"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - name: this.name ? - this.name.length <= 20 ? - cleanSpecialChars(this.name) : - cleanSpecialChars(this.name).slice(0, 17) + "..." : - "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - unit: this.unit ? - this.unit.length <= 4 ? - cleanSpecialChars(this.unit) : - cleanSpecialChars(this.unit).slice(0, 1) + "..." : - "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Name: " + - printable.name + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing + - ", Unit: " + - printable.unit - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.dailyValue.padEnd(11) + - " | " + - printable.name.padEnd(20) + - " | " + - printable.per100G.padEnd(8) + - " | " + - printable.perServing.padEnd(11) + - " | " + - printable.unit.padEnd(4) + - " |" - ); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts deleted file mode 100644 index 4420d7b3..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of protein in the product. - */ -export class NutritionFactsLabelV1Protein { - /** DVs are the recommended amounts of protein to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of protein per 100g of the product. */ - per100G: number | null; - /** The amount of protein per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts deleted file mode 100644 index c2e18d05..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of saturated fat in the product. - */ -export class NutritionFactsLabelV1SaturatedFat { - /** DVs are the recommended amounts of saturated fat to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of saturated fat per 100g of the product. */ - per100G: number | null; - /** The amount of saturated fat per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts deleted file mode 100644 index bcd7dbc6..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.ts +++ /dev/null @@ -1,74 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The size of a single serving of the product. - */ -export class NutritionFactsLabelV1ServingSize { - /** The amount of a single serving. */ - amount: number | null; - /** The unit for the amount of a single serving. */ - unit: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["amount"] !== undefined && - prediction["amount"] !== null && - !isNaN(prediction["amount"]) - ) { - this.amount = +parseFloat(prediction["amount"]); - } else { - this.amount = null; - } - this.unit = prediction["unit"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - amount: this.amount !== undefined ? floatToString(this.amount) : "", - unit: this.unit ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Amount: " + - printable.amount + - ", Unit: " + - printable.unit - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Amount: ${printable.amount} - :Unit: ${printable.unit}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts deleted file mode 100644 index 81416e35..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.ts +++ /dev/null @@ -1,106 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of sodium in the product. - */ -export class NutritionFactsLabelV1Sodium { - /** DVs are the recommended amounts of sodium to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of sodium per 100g of the product. */ - per100G: number | null; - /** The amount of sodium per serving of the product. */ - perServing: number | null; - /** The unit of measurement for the amount of sodium. */ - unit: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.unit = prediction["unit"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - unit: this.unit ?? "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing + - ", Unit: " + - printable.unit - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing} - :Unit: ${printable.unit}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts deleted file mode 100644 index cbf2358f..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The total amount of carbohydrates in the product. - */ -export class NutritionFactsLabelV1TotalCarbohydrate { - /** DVs are the recommended amounts of total carbohydrates to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of total carbohydrates per 100g of the product. */ - per100G: number | null; - /** The amount of total carbohydrates per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts deleted file mode 100644 index e805f594..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The total amount of fat in the product. - */ -export class NutritionFactsLabelV1TotalFat { - /** DVs are the recommended amounts of total fat to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of total fat per 100g of the product. */ - per100G: number | null; - /** The amount of total fat per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts deleted file mode 100644 index 9aacdf54..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The total amount of sugars in the product. - */ -export class NutritionFactsLabelV1TotalSugar { - /** DVs are the recommended amounts of total sugars to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of total sugars per 100g of the product. */ - per100G: number | null; - /** The amount of total sugars per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts b/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts deleted file mode 100644 index ddbcc297..00000000 --- a/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.ts +++ /dev/null @@ -1,99 +0,0 @@ - -import { floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; - -/** - * The amount of trans fat in the product. - */ -export class NutritionFactsLabelV1TransFat { - /** DVs are the recommended amounts of trans fat to consume or not to exceed each day. */ - dailyValue: number | null; - /** The amount of trans fat per 100g of the product. */ - per100G: number | null; - /** The amount of trans fat per serving of the product. */ - perServing: number | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["daily_value"] !== undefined && - prediction["daily_value"] !== null && - !isNaN(prediction["daily_value"]) - ) { - this.dailyValue = +parseFloat(prediction["daily_value"]); - } else { - this.dailyValue = null; - } - if ( - prediction["per_100g"] !== undefined && - prediction["per_100g"] !== null && - !isNaN(prediction["per_100g"]) - ) { - this.per100G = +parseFloat(prediction["per_100g"]); - } else { - this.per100G = null; - } - if ( - prediction["per_serving"] !== undefined && - prediction["per_serving"] !== null && - !isNaN(prediction["per_serving"]) - ) { - this.perServing = +parseFloat(prediction["per_serving"]); - } else { - this.perServing = null; - } - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - dailyValue: - this.dailyValue !== undefined ? floatToString(this.dailyValue) : "", - per100G: this.per100G !== undefined ? floatToString(this.per100G) : "", - perServing: - this.perServing !== undefined ? floatToString(this.perServing) : "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Daily Value: " + - printable.dailyValue + - ", Per 100g: " + - printable.per100G + - ", Per Serving: " + - printable.perServing - ); - } - - /** - * Output in a format suitable for inclusion in a field list. - */ - toFieldList(): string { - const printable = this.#printableValues(); - return ` - :Daily Value: ${printable.dailyValue} - :Per 100g: ${printable.per100G} - :Per Serving: ${printable.perServing}`.trimEnd(); - } -} diff --git a/src/product/passport/index.ts b/src/product/passport/index.ts index b3104823..b07d1625 100644 --- a/src/product/passport/index.ts +++ b/src/product/passport/index.ts @@ -1 +1,2 @@ -export { PassportV1 } from "./passportV1"; +export { PassportV1 } from "./passportV1.js"; +export { PassportV1Document } from "./passportV1Document.js"; diff --git a/src/product/passport/internal.ts b/src/product/passport/internal.ts deleted file mode 100644 index 8b8e4c6e..00000000 --- a/src/product/passport/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { PassportV1 } from "./passportV1"; -export { PassportV1Document } from "./passportV1Document"; diff --git a/src/product/passport/passportV1.ts b/src/product/passport/passportV1.ts index 67ac75a2..d8df9b93 100644 --- a/src/product/passport/passportV1.ts +++ b/src/product/passport/passportV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { PassportV1Document } from "./passportV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { PassportV1Document } from "./passportV1Document.js"; /** * Passport API version 1 inference prediction. diff --git a/src/product/passport/passportV1Document.ts b/src/product/passport/passportV1Document.ts index 2abc757b..88781bf1 100644 --- a/src/product/passport/passportV1Document.ts +++ b/src/product/passport/passportV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "../../parsing/common"; -import { DateField, StringField } from "../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { DateField, StringField } from "@/parsing/standard/index.js"; /** * Passport API version 1.1 document data. diff --git a/src/product/receipt/index.ts b/src/product/receipt/index.ts index c4b30f52..006d625c 100644 --- a/src/product/receipt/index.ts +++ b/src/product/receipt/index.ts @@ -1 +1,3 @@ -export { ReceiptV5 } from "./receiptV5"; +export { ReceiptV5 } from "./receiptV5.js"; +export { ReceiptV5Document } from "./receiptV5Document.js"; +export { ReceiptV5LineItem } from "./receiptV5LineItem.js"; diff --git a/src/product/receipt/internal.ts b/src/product/receipt/internal.ts deleted file mode 100644 index 4b94bbda..00000000 --- a/src/product/receipt/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { ReceiptV5 } from "./receiptV5"; -export { ReceiptV5Document } from "./receiptV5Document"; -export { ReceiptV5LineItem } from "./receiptV5LineItem"; diff --git a/src/product/receipt/receiptV5.ts b/src/product/receipt/receiptV5.ts index ae77f519..be42ddd9 100644 --- a/src/product/receipt/receiptV5.ts +++ b/src/product/receipt/receiptV5.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { ReceiptV5Document } from "./receiptV5Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { ReceiptV5Document } from "./receiptV5Document.js"; /** * Receipt API version 5 inference prediction. diff --git a/src/product/receipt/receiptV5Document.ts b/src/product/receipt/receiptV5Document.ts index 40fca42e..457912ea 100644 --- a/src/product/receipt/receiptV5Document.ts +++ b/src/product/receipt/receiptV5Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { ReceiptV5LineItem } from "./receiptV5LineItem"; +} from "@/parsing/common/index.js"; +import { ReceiptV5LineItem } from "./receiptV5LineItem.js"; import { AmountField, ClassificationField, @@ -12,7 +12,7 @@ import { LocaleField, StringField, Taxes, -} from "../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * Receipt API version 5.4 document data. diff --git a/src/product/receipt/receiptV5LineItem.ts b/src/product/receipt/receiptV5LineItem.ts index 7cb6e5c6..1598740a 100644 --- a/src/product/receipt/receiptV5LineItem.ts +++ b/src/product/receipt/receiptV5LineItem.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars, floatToString } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * List of all line items on the receipt. diff --git a/src/product/resume/index.ts b/src/product/resume/index.ts index 6f8b1d4d..63567319 100644 --- a/src/product/resume/index.ts +++ b/src/product/resume/index.ts @@ -1 +1,7 @@ -export { ResumeV1 } from "./resumeV1"; +export { ResumeV1 } from "./resumeV1.js"; +export { ResumeV1Certificate } from "./resumeV1Certificate.js"; +export { ResumeV1Document } from "./resumeV1Document.js"; +export { ResumeV1Education } from "./resumeV1Education.js"; +export { ResumeV1Language } from "./resumeV1Language.js"; +export { ResumeV1ProfessionalExperience } from "./resumeV1ProfessionalExperience.js"; +export { ResumeV1SocialNetworksUrl } from "./resumeV1SocialNetworksUrl.js"; diff --git a/src/product/resume/internal.ts b/src/product/resume/internal.ts deleted file mode 100644 index ee280953..00000000 --- a/src/product/resume/internal.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { ResumeV1 } from "./resumeV1"; -export { ResumeV1Certificate } from "./resumeV1Certificate"; -export { ResumeV1Document } from "./resumeV1Document"; -export { ResumeV1Education } from "./resumeV1Education"; -export { ResumeV1Language } from "./resumeV1Language"; -export { ResumeV1ProfessionalExperience } from "./resumeV1ProfessionalExperience"; -export { ResumeV1SocialNetworksUrl } from "./resumeV1SocialNetworksUrl"; diff --git a/src/product/resume/resumeV1.ts b/src/product/resume/resumeV1.ts index 04b190e1..2ae4b196 100644 --- a/src/product/resume/resumeV1.ts +++ b/src/product/resume/resumeV1.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../parsing/common"; -import { ResumeV1Document } from "./resumeV1Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { ResumeV1Document } from "./resumeV1Document.js"; /** * Resume API version 1 inference prediction. diff --git a/src/product/resume/resumeV1Certificate.ts b/src/product/resume/resumeV1Certificate.ts index b501ecf4..e5b65870 100644 --- a/src/product/resume/resumeV1Certificate.ts +++ b/src/product/resume/resumeV1Certificate.ts @@ -1,7 +1,6 @@ - -import { cleanSpecialChars } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The list of certificates obtained by the candidate. diff --git a/src/product/resume/resumeV1Document.ts b/src/product/resume/resumeV1Document.ts index 3f0766cb..61675aa4 100644 --- a/src/product/resume/resumeV1Document.ts +++ b/src/product/resume/resumeV1Document.ts @@ -2,13 +2,13 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../parsing/common"; -import { ResumeV1SocialNetworksUrl } from "./resumeV1SocialNetworksUrl"; -import { ResumeV1Language } from "./resumeV1Language"; -import { ResumeV1Education } from "./resumeV1Education"; -import { ResumeV1ProfessionalExperience } from "./resumeV1ProfessionalExperience"; -import { ResumeV1Certificate } from "./resumeV1Certificate"; -import { ClassificationField, StringField } from "../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { ResumeV1SocialNetworksUrl } from "./resumeV1SocialNetworksUrl.js"; +import { ResumeV1Language } from "./resumeV1Language.js"; +import { ResumeV1Education } from "./resumeV1Education.js"; +import { ResumeV1ProfessionalExperience } from "./resumeV1ProfessionalExperience.js"; +import { ResumeV1Certificate } from "./resumeV1Certificate.js"; +import { ClassificationField, StringField } from "@/parsing/standard/index.js"; /** * Resume API version 1.2 document data. diff --git a/src/product/resume/resumeV1Education.ts b/src/product/resume/resumeV1Education.ts index 9c7a0bca..4b04a164 100644 --- a/src/product/resume/resumeV1Education.ts +++ b/src/product/resume/resumeV1Education.ts @@ -1,7 +1,7 @@ -import { cleanSpecialChars } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The list of the candidate's educational background. diff --git a/src/product/resume/resumeV1Language.ts b/src/product/resume/resumeV1Language.ts index e008c9e6..121ce1e3 100644 --- a/src/product/resume/resumeV1Language.ts +++ b/src/product/resume/resumeV1Language.ts @@ -1,7 +1,7 @@ -import { cleanSpecialChars } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The list of languages that the candidate is proficient in. diff --git a/src/product/resume/resumeV1ProfessionalExperience.ts b/src/product/resume/resumeV1ProfessionalExperience.ts index 2d62f819..0538c0ad 100644 --- a/src/product/resume/resumeV1ProfessionalExperience.ts +++ b/src/product/resume/resumeV1ProfessionalExperience.ts @@ -1,7 +1,7 @@ -import { cleanSpecialChars } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The list of the candidate's professional experiences. diff --git a/src/product/resume/resumeV1SocialNetworksUrl.ts b/src/product/resume/resumeV1SocialNetworksUrl.ts index bca348ff..58d3795d 100644 --- a/src/product/resume/resumeV1SocialNetworksUrl.ts +++ b/src/product/resume/resumeV1SocialNetworksUrl.ts @@ -1,7 +1,7 @@ -import { cleanSpecialChars } from "../../parsing/common"; -import { StringDict } from "../../parsing/common"; -import { Polygon } from "../../geometry"; +import { cleanSpecialChars } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The list of social network profiles of the candidate. diff --git a/src/product/us/bankCheck/bankCheckV1.ts b/src/product/us/bankCheck/bankCheckV1.ts index b4529035..242e4eb3 100644 --- a/src/product/us/bankCheck/bankCheckV1.ts +++ b/src/product/us/bankCheck/bankCheckV1.ts @@ -1,6 +1,6 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { BankCheckV1Document } from "./bankCheckV1Document"; -import { BankCheckV1Page } from "./bankCheckV1Page"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { BankCheckV1Document } from "./bankCheckV1Document.js"; +import { BankCheckV1Page } from "./bankCheckV1Page.js"; /** * Bank Check API version 1 inference prediction. diff --git a/src/product/us/bankCheck/bankCheckV1Document.ts b/src/product/us/bankCheck/bankCheckV1Document.ts index 60c7291c..63483b0f 100644 --- a/src/product/us/bankCheck/bankCheckV1Document.ts +++ b/src/product/us/bankCheck/bankCheckV1Document.ts @@ -2,12 +2,12 @@ import { Prediction, StringDict, cleanOutString, -} from "../../../parsing/common"; +} from "@/parsing/common/index.js"; import { AmountField, DateField, StringField, -} from "../../../parsing/standard"; +} from "@/parsing/standard/index.js"; /** * Bank Check API version 1.1 document data. diff --git a/src/product/us/bankCheck/bankCheckV1Page.ts b/src/product/us/bankCheck/bankCheckV1Page.ts index 521636f4..e39de604 100644 --- a/src/product/us/bankCheck/bankCheckV1Page.ts +++ b/src/product/us/bankCheck/bankCheckV1Page.ts @@ -1,7 +1,6 @@ -import { StringDict, cleanOutString } from "../../../parsing/common"; -import { PositionField } from "../../../parsing/standard"; - -import { BankCheckV1Document } from "./bankCheckV1Document"; +import { StringDict, cleanOutString } from "@/parsing/common/index.js"; +import { PositionField } from "@/parsing/standard/index.js"; +import { BankCheckV1Document } from "./bankCheckV1Document.js"; /** * Bank Check API version 1.1 page data. diff --git a/src/product/us/bankCheck/index.ts b/src/product/us/bankCheck/index.ts index c865a399..094ec007 100644 --- a/src/product/us/bankCheck/index.ts +++ b/src/product/us/bankCheck/index.ts @@ -1 +1,3 @@ -export { BankCheckV1 } from "./bankCheckV1"; +export { BankCheckV1 } from "./bankCheckV1.js"; +export { BankCheckV1Document } from "./bankCheckV1Document.js"; +export { BankCheckV1Page } from "./bankCheckV1Page.js"; diff --git a/src/product/us/bankCheck/internal.ts b/src/product/us/bankCheck/internal.ts deleted file mode 100644 index 834f393d..00000000 --- a/src/product/us/bankCheck/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { BankCheckV1 } from "./bankCheckV1"; -export { BankCheckV1Document } from "./bankCheckV1Document"; -export { BankCheckV1Page } from "./bankCheckV1Page"; diff --git a/src/product/us/healthcareCard/healthcareCardV1.ts b/src/product/us/healthcareCard/healthcareCardV1.ts deleted file mode 100644 index 0fb72755..00000000 --- a/src/product/us/healthcareCard/healthcareCardV1.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { HealthcareCardV1Document } from "./healthcareCardV1Document"; - -/** - * Healthcare Card API version 1 inference prediction. - */ -export class HealthcareCardV1 extends Inference { - /** The endpoint's name. */ - endpointName = "us_healthcare_cards"; - /** The endpoint's version. */ - endpointVersion = "1"; - /** The document-level prediction. */ - prediction: HealthcareCardV1Document; - /** The document's pages. */ - pages: Page[] = []; - - constructor(rawPrediction: StringDict) { - super(rawPrediction); - this.prediction = new HealthcareCardV1Document(rawPrediction["prediction"]); - rawPrediction["pages"].forEach( - (page: StringDict) => { - if (page.prediction !== undefined && page.prediction !== null && - Object.keys(page.prediction).length > 0) { - this.pages.push(new Page( - HealthcareCardV1Document, - page, - page["id"], - page["orientation"] - )); - } - } - ); - } -} diff --git a/src/product/us/healthcareCard/healthcareCardV1Copay.ts b/src/product/us/healthcareCard/healthcareCardV1Copay.ts deleted file mode 100644 index b2492a0e..00000000 --- a/src/product/us/healthcareCard/healthcareCardV1Copay.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { cleanSpecialChars, floatToString } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; - -/** - * Copayments for covered services. - */ -export class HealthcareCardV1Copay { - /** The price of the service. */ - serviceFees: number | null; - /** The name of the service. */ - serviceName: string | null; - /** Confidence score */ - confidence: number = 0.0; - /** The document page on which the information was found. */ - pageId: number; - /** - * Contains the relative vertices coordinates (points) of a polygon containing - * the field in the document. - */ - polygon: Polygon = new Polygon(); - - constructor({ prediction = {} }: StringDict) { - if ( - prediction["service_fees"] !== undefined && - prediction["service_fees"] !== null && - !isNaN(prediction["service_fees"]) - ) { - this.serviceFees = +parseFloat(prediction["service_fees"]); - } else { - this.serviceFees = null; - } - this.serviceName = prediction["service_name"]; - this.pageId = prediction["page_id"]; - this.confidence = prediction["confidence"] ? prediction.confidence : 0.0; - if (prediction["polygon"]) { - this.polygon = prediction.polygon; - } - } - - /** - * Collection of fields as representable strings. - */ - #printableValues() { - return { - serviceFees: - this.serviceFees !== undefined ? floatToString(this.serviceFees) : "", - serviceName: this.serviceName ? - this.serviceName.length <= 20 ? - cleanSpecialChars(this.serviceName) : - cleanSpecialChars(this.serviceName).slice(0, 17) + "..." : - "", - }; - } - - /** - * Default string representation. - */ - toString(): string { - const printable = this.#printableValues(); - return ( - "Service Fees: " + - printable.serviceFees + - ", Service Name: " + - printable.serviceName - ); - } - - /** - * Output in a format suitable for inclusion in an rST table. - */ - toTableLine(): string { - const printable = this.#printableValues(); - return ( - "| " + - printable.serviceFees.padEnd(12) + - " | " + - printable.serviceName.padEnd(20) + - " |" - ); - } -} diff --git a/src/product/us/healthcareCard/healthcareCardV1Document.ts b/src/product/us/healthcareCard/healthcareCardV1Document.ts deleted file mode 100644 index 919a8cd5..00000000 --- a/src/product/us/healthcareCard/healthcareCardV1Document.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { - Prediction, - StringDict, - cleanOutString,lineSeparator, -} from "../../../parsing/common"; -import { HealthcareCardV1Copay } from "./healthcareCardV1Copay"; -import { DateField, StringField } from "../../../parsing/standard"; - -/** - * Healthcare Card API version 1.3 document data. - */ -export class HealthcareCardV1Document implements Prediction { - /** The name of the company that provides the healthcare plan. */ - companyName: StringField; - /** Copayments for covered services. */ - copays: HealthcareCardV1Copay[] = []; - /** The list of dependents covered by the healthcare plan. */ - dependents: StringField[] = []; - /** The date when the member enrolled in the healthcare plan. */ - enrollmentDate: DateField; - /** The group number associated with the healthcare plan. */ - groupNumber: StringField; - /** The organization that issued the healthcare plan. */ - issuer80840: StringField; - /** The unique identifier for the member in the healthcare system. */ - memberId: StringField; - /** The name of the member covered by the healthcare plan. */ - memberName: StringField; - /** The unique identifier for the payer in the healthcare system. */ - payerId: StringField; - /** The name of the healthcare plan. */ - planName: StringField; - /** The BIN number for prescription drug coverage. */ - rxBin: StringField; - /** The group number for prescription drug coverage. */ - rxGrp: StringField; - /** The ID number for prescription drug coverage. */ - rxId: StringField; - /** The PCN number for prescription drug coverage. */ - rxPcn: StringField; - - constructor(rawPrediction: StringDict, pageId?: number) { - this.companyName = new StringField({ - prediction: rawPrediction["company_name"], - pageId: pageId, - }); - rawPrediction["copays"] && - rawPrediction["copays"].map( - (itemPrediction: StringDict) => - this.copays.push( - new HealthcareCardV1Copay({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - rawPrediction["dependents"] && - rawPrediction["dependents"].map( - (itemPrediction: StringDict) => - this.dependents.push( - new StringField({ - prediction: itemPrediction, - pageId: pageId, - }) - ) - ); - this.enrollmentDate = new DateField({ - prediction: rawPrediction["enrollment_date"], - pageId: pageId, - }); - this.groupNumber = new StringField({ - prediction: rawPrediction["group_number"], - pageId: pageId, - }); - this.issuer80840 = new StringField({ - prediction: rawPrediction["issuer_80840"], - pageId: pageId, - }); - this.memberId = new StringField({ - prediction: rawPrediction["member_id"], - pageId: pageId, - }); - this.memberName = new StringField({ - prediction: rawPrediction["member_name"], - pageId: pageId, - }); - this.payerId = new StringField({ - prediction: rawPrediction["payer_id"], - pageId: pageId, - }); - this.planName = new StringField({ - prediction: rawPrediction["plan_name"], - pageId: pageId, - }); - this.rxBin = new StringField({ - prediction: rawPrediction["rx_bin"], - pageId: pageId, - }); - this.rxGrp = new StringField({ - prediction: rawPrediction["rx_grp"], - pageId: pageId, - }); - this.rxId = new StringField({ - prediction: rawPrediction["rx_id"], - pageId: pageId, - }); - this.rxPcn = new StringField({ - prediction: rawPrediction["rx_pcn"], - pageId: pageId, - }); - } - - /** - * Default string representation. - */ - toString(): string { - const dependents = this.dependents.join("\n "); - let copaysSummary:string = ""; - if (this.copays && this.copays.length > 0) { - const copaysColSizes:number[] = [14, 22]; - copaysSummary += "\n" + lineSeparator(copaysColSizes, "-") + "\n "; - copaysSummary += "| Service Fees "; - copaysSummary += "| Service Name "; - copaysSummary += "|\n" + lineSeparator(copaysColSizes, "="); - copaysSummary += this.copays.map( - (item) => - "\n " + item.toTableLine() + "\n" + lineSeparator(copaysColSizes, "-") - ).join(""); - } - const outStr = `:Company Name: ${this.companyName} -:Plan Name: ${this.planName} -:Member Name: ${this.memberName} -:Member ID: ${this.memberId} -:Issuer 80840: ${this.issuer80840} -:Dependents: ${dependents} -:Group Number: ${this.groupNumber} -:Payer ID: ${this.payerId} -:RX BIN: ${this.rxBin} -:RX ID: ${this.rxId} -:RX GRP: ${this.rxGrp} -:RX PCN: ${this.rxPcn} -:Copays: ${copaysSummary} -:Enrollment Date: ${this.enrollmentDate}`.trimEnd(); - return cleanOutString(outStr); - } -} diff --git a/src/product/us/healthcareCard/index.ts b/src/product/us/healthcareCard/index.ts deleted file mode 100644 index 56b18900..00000000 --- a/src/product/us/healthcareCard/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { HealthcareCardV1 } from "./healthcareCardV1"; diff --git a/src/product/us/healthcareCard/internal.ts b/src/product/us/healthcareCard/internal.ts deleted file mode 100644 index a3be3a17..00000000 --- a/src/product/us/healthcareCard/internal.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { HealthcareCardV1 } from "./healthcareCardV1"; -export { HealthcareCardV1Copay } from "./healthcareCardV1Copay"; -export { HealthcareCardV1Document } from "./healthcareCardV1Document"; diff --git a/src/product/us/index.ts b/src/product/us/index.ts index 82ca9107..ac5e7b47 100644 --- a/src/product/us/index.ts +++ b/src/product/us/index.ts @@ -1,3 +1,2 @@ -export { BankCheckV1 } from "./bankCheck/bankCheckV1"; -export { HealthcareCardV1 } from "./healthcareCard/healthcareCardV1"; -export { UsMailV3 } from "./usMail/usMailV3"; +export { BankCheckV1 } from "./bankCheck/index.js"; +export { UsMailV3 } from "./usMail/index.js"; diff --git a/src/product/us/internal.ts b/src/product/us/internal.ts index 849fc79c..786879e8 100644 --- a/src/product/us/internal.ts +++ b/src/product/us/internal.ts @@ -1,3 +1,2 @@ -export * as bankCheck from "./bankCheck/internal"; -export * as healthcareCard from "./healthcareCard/internal"; -export * as usMail from "./usMail/internal"; +export * as bankCheck from "./bankCheck/index.js"; +export * as usMail from "./usMail/index.js"; diff --git a/src/product/us/usMail/index.ts b/src/product/us/usMail/index.ts index 0917b8ea..6ce0b54c 100644 --- a/src/product/us/usMail/index.ts +++ b/src/product/us/usMail/index.ts @@ -1 +1,4 @@ -export { UsMailV3 } from "./usMailV3"; +export { UsMailV3 } from "./usMailV3.js"; +export { UsMailV3Document } from "./usMailV3Document.js"; +export { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress.js"; +export { UsMailV3SenderAddress } from "./usMailV3SenderAddress.js"; diff --git a/src/product/us/usMail/internal.ts b/src/product/us/usMail/internal.ts deleted file mode 100644 index 9bc5cfe0..00000000 --- a/src/product/us/usMail/internal.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { UsMailV3 } from "./usMailV3"; -export { UsMailV3Document } from "./usMailV3Document"; -export { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress"; -export { UsMailV3SenderAddress } from "./usMailV3SenderAddress"; diff --git a/src/product/us/usMail/usMailV3.ts b/src/product/us/usMail/usMailV3.ts index 3e5d35c9..a4f637b8 100644 --- a/src/product/us/usMail/usMailV3.ts +++ b/src/product/us/usMail/usMailV3.ts @@ -1,5 +1,5 @@ -import { Inference, StringDict, Page } from "../../../parsing/common"; -import { UsMailV3Document } from "./usMailV3Document"; +import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { UsMailV3Document } from "./usMailV3Document.js"; /** * US Mail API version 3 inference prediction. diff --git a/src/product/us/usMail/usMailV3Document.ts b/src/product/us/usMail/usMailV3Document.ts index bf552637..13dc36f9 100644 --- a/src/product/us/usMail/usMailV3Document.ts +++ b/src/product/us/usMail/usMailV3Document.ts @@ -2,10 +2,10 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "../../../parsing/common"; -import { UsMailV3SenderAddress } from "./usMailV3SenderAddress"; -import { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress"; -import { BooleanField, StringField } from "../../../parsing/standard"; +} from "@/parsing/common/index.js"; +import { UsMailV3SenderAddress } from "./usMailV3SenderAddress.js"; +import { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress.js"; +import { BooleanField, StringField } from "@/parsing/standard/index.js"; /** * US Mail API version 3.0 document data. diff --git a/src/product/us/usMail/usMailV3RecipientAddress.ts b/src/product/us/usMail/usMailV3RecipientAddress.ts index 32b6aee0..85e370a8 100644 --- a/src/product/us/usMail/usMailV3RecipientAddress.ts +++ b/src/product/us/usMail/usMailV3RecipientAddress.ts @@ -1,7 +1,7 @@ -import { cleanSpecialChars } from "../../../parsing/common"; -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { cleanSpecialChars } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The addresses of the recipients. diff --git a/src/product/us/usMail/usMailV3SenderAddress.ts b/src/product/us/usMail/usMailV3SenderAddress.ts index 9567a1eb..204e74e3 100644 --- a/src/product/us/usMail/usMailV3SenderAddress.ts +++ b/src/product/us/usMail/usMailV3SenderAddress.ts @@ -1,5 +1,5 @@ -import { StringDict } from "../../../parsing/common"; -import { Polygon } from "../../../geometry"; +import { StringDict } from "@/parsing/common/stringDict.js"; +import { Polygon } from "@/geometry/index.js"; /** * The address of the sender. diff --git a/tests/geometry.spec.ts b/tests/geometry.spec.ts index 1a25eff8..2d85e5fe 100644 --- a/tests/geometry.spec.ts +++ b/tests/geometry.spec.ts @@ -1,4 +1,4 @@ -import * as geometry from "../src/geometry"; +import * as geometry from "@/geometry/index.js"; import { expect } from "chai"; describe("Geometry functions", () => { diff --git a/tests/index.ts b/tests/index.ts index 20f6f125..2d161c7d 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -1,6 +1,9 @@ -import path from "node:path"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; +import path from "path"; -export const RESOURCE_PATH = path.join(__dirname, "data"); +const currentDirName = dirname(fileURLToPath(import.meta.url)); +export const RESOURCE_PATH = path.join(currentDirName, "data"); export const V1_RESOURCE_PATH = path.join(RESOURCE_PATH, "v1"); export const V1_PRODUCT_PATH = path.join(V1_RESOURCE_PATH, "products"); diff --git a/tests/input/pageOperations.spec.ts b/tests/input/pageOperations.spec.ts index d8839a07..4aec3c3f 100644 --- a/tests/input/pageOperations.spec.ts +++ b/tests/input/pageOperations.spec.ts @@ -2,11 +2,11 @@ import { PathInput, PageOptionsOperation, INPUT_TYPE_PATH, -} from "../../src/input"; +} from "@/input/index.js"; import * as fs from "fs"; import * as path from "path"; import { expect } from "chai"; -import { RESOURCE_PATH } from "../index"; +import { RESOURCE_PATH } from "../index.js"; describe("High level multi-page operations", () => { it("should cut a PDF", async () => { diff --git a/tests/v1/input/sources.integration.ts b/tests/input/sources.integration.ts similarity index 94% rename from tests/v1/input/sources.integration.ts rename to tests/input/sources.integration.ts index 5bdf6c86..6b751956 100644 --- a/tests/v1/input/sources.integration.ts +++ b/tests/input/sources.integration.ts @@ -1,11 +1,11 @@ -import * as mindee from "../../../src"; -import { InvoiceV4 } from "../../../src/product"; +import * as mindee from "@/index.js"; +import { InvoiceV4 } from "@/product/index.js"; import { expect } from "chai"; import { promises as fs } from "fs"; import { createReadStream } from "node:fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../index"; -import { PathInput, Base64Input, BufferInput, BytesInput, UrlInput } from "../../../src"; +import { V1_PRODUCT_PATH } from "../index.js"; +import { PathInput, Base64Input, BufferInput, BytesInput, UrlInput } from "@/index.js"; describe("MindeeV1 - File Input Integration Tests", async () => { let client: mindee.Client; diff --git a/tests/input/sources.spec.ts b/tests/input/sources.spec.ts index 39458629..c6349782 100644 --- a/tests/input/sources.spec.ts +++ b/tests/input/sources.spec.ts @@ -1,26 +1,26 @@ +import { Readable } from "stream"; import { Base64Input, BufferInput, BytesInput, + PathInput, + StreamInput, INPUT_TYPE_BASE64, INPUT_TYPE_BUFFER, INPUT_TYPE_BYTES, INPUT_TYPE_PATH, INPUT_TYPE_STREAM, - PathInput, - StreamInput, -} from "../../src/input"; +} from "@/input/index.js"; import * as fs from "fs"; import * as path from "path"; import { expect } from "chai"; import sharp from "sharp"; import { Buffer } from "node:buffer"; -import { compressImage } from "../../src/imageOperations"; -import { compressPdf } from "../../src/pdf"; -import { extractTextFromPdf } from "../../src/pdf/pdfUtils"; -import { logger } from "../../src/logger"; -import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../index"; -import { Readable } from "stream"; +import { compressImage } from "@/imageOperations/index.js"; +import { compressPdf } from "@/pdf/index.js"; +import { extractTextFromPdf } from "@/pdf/pdfUtils.js"; +import { logger } from "@/logger.js"; +import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../index.js"; describe("Test different types of input", () => { const outputPath = path.join(RESOURCE_PATH, "output"); diff --git a/tests/v1/input/urlInputSource.integration.ts b/tests/input/urlInputSource.integration.ts similarity index 78% rename from tests/v1/input/urlInputSource.integration.ts rename to tests/input/urlInputSource.integration.ts index 431be394..c43013b3 100644 --- a/tests/v1/input/urlInputSource.integration.ts +++ b/tests/input/urlInputSource.integration.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; -import { UrlInput } from "../../../src"; -import { Client } from "../../../src"; -import { InvoiceV4 } from "../../../src/product"; +import { UrlInput } from "@/index.js"; +import { Client } from "@/index.js"; +import { InvoiceV4 } from "@/product/index.js"; describe("MindeeV1 - URL Input Integration Test", async () => { - it("should retrieve and parse a remote file", async () => { + it("should retrieve and parse a remote file with redirection", async () => { const apiKey = process.env.MINDEE_API_KEY; if (!apiKey) { throw new Error("MINDEE_API_KEY environment variable is not set"); diff --git a/tests/input/urlInputSource.spec.ts b/tests/input/urlInputSource.spec.ts index d474ab8c..bc02d410 100644 --- a/tests/input/urlInputSource.spec.ts +++ b/tests/input/urlInputSource.spec.ts @@ -1,21 +1,26 @@ -import { BytesInput, UrlInput } from "../../src"; -import { LocalInputSource } from "../../src/input"; +import { BytesInput, UrlInput } from "@/index.js"; +import { LocalInputSource } from "@/input/index.js"; import { expect } from "chai"; -import nock from "nock"; +import { MockAgent, setGlobalDispatcher } from "undici"; + +const mockAgent = new MockAgent(); +setGlobalDispatcher(mockAgent); +const mockPool = mockAgent.get("https://dummy-host"); describe("Test URL input source", () => { describe("initializing", () => { it("should accept a URL", async () => { const input = new UrlInput({ url: "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/ReceiptSwiss.jpg/576px-ReceiptSwiss.jpg", + dispatcher: mockAgent, }); await input.init(); expect(input.fileObject).to.be.a("string"); }); it("should throw an error for non-HTTPS URL", async () => { - const url = "http://example.com/file.pdf"; - const urlSource = new UrlInput({ url }); + const url = "http://dummy-host/file.pdf"; + const urlSource = new UrlInput({ url, dispatcher: mockAgent }); try { await urlSource.init(); @@ -28,24 +33,16 @@ describe("Test URL input source", () => { describe("asLocalInputSource", () => { - beforeEach(() => { - nock.disableNetConnect(); - }); - - afterEach(() => { - nock.cleanAll(); - nock.enableNetConnect(); - }); it("should download file and return LocalInputSource", async () => { - const url = "https://example.com/file.pdf"; + const url = "https://dummy-host/file.pdf"; const fileContent = Buffer.from("dummy PDF content"); - nock("https://example.com") - .get("/file.pdf") + mockPool + .intercept({ path: "/file.pdf", method: "GET" }) .reply(200, fileContent); - const urlInput = new UrlInput({ url }); + const urlInput = new UrlInput({ url, dispatcher: mockAgent }); await urlInput.init(); const localInput = await urlInput.asLocalInputSource(); await localInput.init(); @@ -56,19 +53,25 @@ describe("Test URL input source", () => { }); it("should handle redirects", async () => { - const originalUrl = "https://example.com/original.pdf"; - const redirectUrl = "https://example.com/redirected.pdf"; + const originalUrl = "https://dummy-host/original.pdf"; + const redirectUrl = "https://dummy-host/redirected.pdf"; const fileContent = Buffer.from("redirected PDF content"); - nock("https://example.com") - .get("/original.pdf") - .reply(302, "", { location: redirectUrl }); // Not sure about that one. + mockPool + .intercept({ path: "/original.pdf", method: "GET" }) + .reply( + 302, + "", + { + headers: { location: redirectUrl } + } + ); - nock("https://example.com") - .get("/redirected.pdf") + mockPool + .intercept({ path: "/redirected.pdf", method: "GET" }) .reply(200, fileContent); - const urlInput = new UrlInput({ url: originalUrl }); + const urlInput = new UrlInput({ url: originalUrl, dispatcher: mockAgent }); const localInput = await urlInput.asLocalInputSource(); await localInput.init(); @@ -78,13 +81,13 @@ describe("Test URL input source", () => { }); it("should throw an error for HTTP error responses", async () => { - const url = "https://example.com/not-found.pdf"; + const url = "https://dummy-host/not-found.pdf"; - nock("https://example.com") - .get("/not-found.pdf") - .reply(404); + mockPool + .intercept({ path: "/not-found.pdf", method: "GET" }) + .reply(404, ""); - const urlInput = new UrlInput({ url }); + const urlInput = new UrlInput({ url, dispatcher: mockAgent }); try { await urlInput.asLocalInputSource(); @@ -96,14 +99,14 @@ describe("Test URL input source", () => { }); it("should use provided filename", async () => { - const url = "https://example.com/file.pdf"; + const url = "https://dummy-host/file.pdf"; const fileContent = Buffer.from("dummy PDF content"); - nock("https://example.com") - .get("/file.pdf") + mockPool + .intercept({ path: "/file.pdf", method: "GET" }) .reply(200, fileContent); - const urlInput = new UrlInput({ url }); + const urlInput = new UrlInput({ url, dispatcher: mockAgent }); const localInput = await urlInput.asLocalInputSource({ filename: "custom.pdf" }); await localInput.init(); @@ -111,12 +114,12 @@ describe("Test URL input source", () => { }); it("should throw an error for invalid filename", async () => { - nock("https://example.com") - .get("/file") + mockPool + .intercept({ path: "/file.pdf", method: "GET" }) .reply(200, "toto"); - const url = "https://example.com/file"; - const urlInput = new UrlInput({ url }); + const url = "https://dummy-host/file.pdf"; + const urlInput = new UrlInput({ url, dispatcher: mockAgent }); try { const localInput = await urlInput.asLocalInputSource({ filename: "invalid" }); diff --git a/tests/pdf/pdfOperation.spec.ts b/tests/pdf/pdfOperation.spec.ts index 16cb9966..c632ee2f 100644 --- a/tests/pdf/pdfOperation.spec.ts +++ b/tests/pdf/pdfOperation.spec.ts @@ -1,10 +1,10 @@ -import * as pdf from "../../src/pdf"; +import * as pdf from "@/pdf/index.js"; import * as path from "path"; import * as fs from "fs"; import { expect } from "chai"; -import { PageOptions, PageOptionsOperation } from "../../src"; -import { PathInput } from "../../src"; -import { RESOURCE_PATH } from "../index"; +import { PageOptions, PageOptionsOperation } from "@/index.js"; +import { PathInput } from "@/index.js"; +import { RESOURCE_PATH } from "../index.js"; describe("Test pdf operation", () => { it("should cut a PDF to get 2 pages", async () => { diff --git a/tests/pdf/pdfTypes.spec.ts b/tests/pdf/pdfTypes.spec.ts index 64ddc6c9..dac586fb 100644 --- a/tests/pdf/pdfTypes.spec.ts +++ b/tests/pdf/pdfTypes.spec.ts @@ -1,17 +1,12 @@ -import * as mindee from "../../src"; import path from "path"; import { expect } from "chai"; -import * as pdf from "../../src/pdf"; -import { PageOptions } from "../../src/input"; -import {PageOptionsOperation, PathInput} from "../../src"; -import * as fs from "node:fs"; -import { RESOURCE_PATH } from "../index"; +import * as pdf from "@/pdf/index.js"; +import { PageOptions } from "@/input/index.js"; +import { PageOptionsOperation, PathInput } from "@/index.js"; +import { RESOURCE_PATH } from "../index.js"; describe("Test pdf lib", () => { - let client: mindee.Client; - beforeEach(async () => { - client = new mindee.Client(); - }); + it("should open a simple XFA form PDF.", async () => { const inputDoc = new PathInput( { inputPath: path.join(RESOURCE_PATH, "file_types/pdf/XfaForm.pdf") } diff --git a/tests/v1/api/asyncResponse.spec.ts b/tests/v1/api/asyncResponse.spec.ts index 9055791e..139b977a 100644 --- a/tests/v1/api/asyncResponse.spec.ts +++ b/tests/v1/api/asyncResponse.spec.ts @@ -1,11 +1,11 @@ import { expect } from "chai"; -import { AsyncPredictResponse } from "../../../src"; +import { AsyncPredictResponse } from "@/index.js"; import { promises as fs } from "fs"; import * as path from "path"; -import { StringDict } from "../../../src/parsing/common"; -import { InvoiceSplitterV1 } from "../../../src/product"; -import { cleanRequestData, isValidAsyncResponse } from "../../../src/http"; -import { RESOURCE_PATH } from "../../index"; +import { StringDict } from "@/parsing/common/index.js"; +import { InvoiceSplitterV1 } from "@/product/index.js"; +import { cleanRequestData, isValidAsyncResponse } from "@/http/index.js"; +import { RESOURCE_PATH } from "../../index.js"; describe("MindeeV1 - Asynchronous API predict response", () => { it("should parse a successful enqueue", async () => { diff --git a/tests/v1/api/endpoint.spec.ts b/tests/v1/api/endpoint.spec.ts index ab473cf0..31bf9740 100644 --- a/tests/v1/api/endpoint.spec.ts +++ b/tests/v1/api/endpoint.spec.ts @@ -1,91 +1,118 @@ -import nock from "nock"; +import * as fs from "node:fs"; import * as path from "path"; import { expect } from "chai"; -import * as mindee from "../../../src"; -import { RESOURCE_PATH, V1_RESOURCE_PATH } from "../../index"; +import { MockAgent, setGlobalDispatcher } from "undici"; +import { Client, PathInput, product } from "@/index.js"; +import { RESOURCE_PATH, V1_RESOURCE_PATH } from "../../index.js"; +import assert from "node:assert/strict"; +import { + MindeeHttp400Error, MindeeHttp401Error, MindeeHttp429Error, MindeeHttp500Error +} from "@/http/index.js"; + +const mockAgent = new MockAgent(); +setGlobalDispatcher(mockAgent); +const mockPool = mockAgent.get("https://v1-endpoint-host"); + +function setInterceptor(httpCode: number, httpResultFile: string) { + const filePath = path.resolve(path.join(V1_RESOURCE_PATH, httpResultFile)); + mockPool + .intercept({ path: /.*/, method: "POST" }) + .reply( + httpCode, + fs.readFileSync(filePath, "utf8"), + { + // eslint-disable-next-line @typescript-eslint/naming-convention + headers: { "content-type": "application/json" } + } + ); +} describe("MindeeV1 - HTTP calls", () => { - before(function() { - process.env.MINDEE_API_HOST = "local.mindee.net"; + const doc = new PathInput({ + inputPath: path.join(RESOURCE_PATH, "file_types/pdf/blank_1.pdf") }); - after(function() { - delete process.env.MINDEE_API_HOST; + beforeEach(async function() { + process.env.MINDEE_API_HOST = "v1-endpoint-host"; }); - async function sendRequest(httpCode: number, httpResultFile: string) { - const owner = "mindee"; - const urlName = "invoices"; - const version = "4"; - - nock("https://local.mindee.net") - .post(`/v1/products/${owner}/${urlName}/v${version}/predict`) - .replyWithFile(httpCode, path.resolve(httpResultFile)); - - const mindeeClient = new mindee.Client({ apiKey: "my-api-key", debug: true }); - const doc = new mindee.PathInput({ - inputPath: path.join(RESOURCE_PATH, "file_types/pdf/blank_1.pdf") - }); - return await mindeeClient.parse(mindee.product.InvoiceV4, doc); - } + afterEach(async function() { + delete process.env.MINDEE_API_HOST; + }); it("should fail on 400 response with object", async () => { - try { - await sendRequest(400, path.join(V1_RESOURCE_PATH, "errors/error_400_with_object_in_detail.json")); - } catch (error: any) { - expect(error.name).to.be.equals("MindeeHttp400Error"); - expect(error.code).to.be.equals(400); - expect(error.message).to.be.undefined; - expect(error.details).to.deep.equal({ document: ["error message"] }); - } + setInterceptor(400, "errors/error_400_with_object_in_detail.json"); + const client = new Client({ apiKey: "my-api-key", debug: true, dispatcher: mockAgent }); + await assert.rejects( + client.parse(product.InvoiceV4, doc), + (error: any) => { + expect(error).to.be.instanceOf(MindeeHttp400Error); + expect(error.code).to.be.equals(400); + expect(error.message).to.be.undefined; + expect(error.details).to.deep.equal({ document: ["error message"] }); + return true; + }); }); it("should fail on 401 response", async () => { - try { - await sendRequest(401, path.join(V1_RESOURCE_PATH, "errors/error_401_no_token.json")); - } catch (error: any) { - expect(error.name).to.be.equals("MindeeHttp401Error"); - expect(error.code).to.be.equals(401); - expect(error.message).to.be.equals("Authorization required"); - expect(error.details).to.be.equals("No token provided"); - } + setInterceptor(401, "errors/error_401_no_token.json"); + const client = new Client({ apiKey: "my-api-key", debug: true, dispatcher: mockAgent }); + await assert.rejects( + client.parse(product.InvoiceV4, doc), + (error: any) => { + expect(error).to.be.instanceOf(MindeeHttp401Error); + expect(error.code).to.be.equals(401); + expect(error.message).to.be.equals("Authorization required"); + expect(error.details).to.be.equals("No token provided"); + return true; + }); }); it("should fail on 429 response", async () => { - try { - await sendRequest(429, path.join(V1_RESOURCE_PATH, "errors/error_429_too_many_requests.json")); - } catch (error: any) { - expect(error.name).to.be.equals("MindeeHttp429Error"); - expect(error.code).to.be.equals(429); - expect(error.message).to.be.equals("Too many requests"); - expect(error.details).to.be.equals("Too Many Requests."); - } + setInterceptor(429, "errors/error_429_too_many_requests.json"); + const client = new Client({ apiKey: "my-api-key", debug: true, dispatcher: mockAgent }); + await assert.rejects( + client.parse(product.InvoiceV4, doc), + (error: any) => { + expect(error).to.be.instanceOf(MindeeHttp429Error); + expect(error.code).to.be.equals(429); + expect(error.message).to.be.equals("Too many requests"); + expect(error.details).to.be.equals("Too Many Requests."); + return true; + }); }); + it("should fail on 500 response", async () => { - try { - await sendRequest(500, path.join(V1_RESOURCE_PATH, "errors/error_500_inference_fail.json")); - } catch (error: any) { - expect(error.name).to.be.equals("MindeeHttp500Error"); - expect(error.code).to.be.equals(500); - expect(error.details).to.be.equals("Can not run prediction: "); - expect(error.message).to.be.equals("Inference failed"); - } + setInterceptor(500, "errors/error_500_inference_fail.json"); + const client = new Client({ apiKey: "my-api-key", debug: true, dispatcher: mockAgent }); + await assert.rejects( + client.parse(product.InvoiceV4, doc), + (error: any) => { + expect(error).to.be.instanceOf(MindeeHttp500Error); + expect(error.code).to.be.equals(500); + expect(error.message).to.be.equals("Inference failed"); + expect(error.details).to.be.equals("Can not run prediction: "); + return true; + }); }); it("should fail on HTML response", async () => { - try { - await sendRequest(500, path.join(V1_RESOURCE_PATH, "errors/error_50x.html")); - } catch (error: any) { - expect(error.name).to.be.equals("MindeeHttp500Error"); - expect(error.code).to.be.equals(500); - } + setInterceptor(500, "errors/error_50x.html"); + const client = new Client({ apiKey: "my-api-key", debug: true, dispatcher: mockAgent }); + await assert.rejects( + client.parse(product.InvoiceV4, doc), + (error: any) => { + expect(error).to.be.instanceOf(MindeeHttp500Error); + expect(error.code).to.be.equals(500); + return true; + }); }); }); describe ("Endpoint parameters" , () => { it ("should initialize default parameters properly", async () => { - const mindeeClient = new mindee.Client({ apiKey: "dummy-api-key" }); - const customEndpoint = mindeeClient.createEndpoint( + const client = new Client({ apiKey: "dummy-api-key", debug: true }); + const customEndpoint = client.createEndpoint( "dummy-endpoint", "dummy-account" ); @@ -96,17 +123,18 @@ describe ("Endpoint parameters" , () => { }); it ("should initialize environment parameters properly", async () => { - process.env.MINDEE_API_HOST = "dummy-host"; + process.env.MINDEE_API_HOST = "v1-endpoint-host"; process.env.MINDEE_API_KEY = "dummy-key"; process.env.MINDEE_REQUEST_TIMEOUT = "30"; - const mindeeClient = new mindee.Client(); - const customEndpoint = mindeeClient.createEndpoint( + + const client = new Client({ debug: true }); + const customEndpoint = client.createEndpoint( "dummy-endpoint", "dummy-account" ); expect(customEndpoint.version).to.equal("1"); expect(customEndpoint.settings.timeout).to.equal(30); - expect(customEndpoint.settings.hostname).to.equal("dummy-host"); + expect(customEndpoint.settings.hostname).to.equal("v1-endpoint-host"); expect(customEndpoint.settings.apiKey).to.equal("dummy-key"); delete process.env.MINDEE_API_HOST; diff --git a/tests/v1/api/feedbackResponse.spec.ts b/tests/v1/api/feedbackResponse.spec.ts index bfa57fbb..f5339c68 100644 --- a/tests/v1/api/feedbackResponse.spec.ts +++ b/tests/v1/api/feedbackResponse.spec.ts @@ -1,8 +1,8 @@ import path from "path"; import { expect } from "chai"; import { promises as fs } from "fs"; -import { FeedbackResponse } from "../../../src/parsing/common"; -import { V1_PRODUCT_PATH } from "../../index"; +import { FeedbackResponse } from "@/parsing/common/index.js"; +import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - Feedback response", () => { it("should load an empty feedback response", async () => { diff --git a/tests/v1/api/response.spec.ts b/tests/v1/api/response.spec.ts index bc960f59..12c397d4 100644 --- a/tests/v1/api/response.spec.ts +++ b/tests/v1/api/response.spec.ts @@ -1,9 +1,9 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; -import { PredictResponse } from "../../../src"; -import { CustomV1, InvoiceV4, ReceiptV5 } from "../../../src/product"; -import { V1_PRODUCT_PATH } from "../../index"; +import { PredictResponse } from "@/index.js"; +import { InvoiceV4, ReceiptV5 } from "@/product/index.js"; +import { V1_PRODUCT_PATH } from "../../index.js"; const dataPath = { receiptV5: path.join(V1_PRODUCT_PATH, "expense_receipts/response_v5/complete.json"), @@ -38,16 +38,4 @@ describe("MindeeV1 - Synchronous API predict response", () => { }); }); - it("should build a Custom Doc response", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.customV1)); - const httpResponse = JSON.parse(jsonData.toString()); - const response = new PredictResponse(CustomV1, httpResponse); - expect(response.document.inference.prediction).to.not.be.undefined; - expect(response.document.inference.pages.length).to.be.equals(2); - expect(response.document.nPages).to.be.equals(2); - response.document.inference.pages.forEach((page, idx) => { - expect(page.id).to.be.equals(idx); - expect(page.toString()).to.not.be.undefined; - }); - }); }); diff --git a/tests/index.spec.ts b/tests/v1/clientInit.spec.ts similarity index 54% rename from tests/index.spec.ts rename to tests/v1/clientInit.spec.ts index 09eef040..5ac815d0 100644 --- a/tests/index.spec.ts +++ b/tests/v1/clientInit.spec.ts @@ -1,10 +1,14 @@ -import { Client } from "../src"; +import { Client } from "@/client.js"; import { expect } from "chai"; +import assert from "node:assert/strict"; describe("Test client initialization", () => { - it("should create an empty client", () => { - const client = new Client({}); - expect(client).to.exist; + it("should not create an empty client", () => { + assert.throws( + () => { + new Client({}); + } + ); }); it("should create a client with an API key", () => { @@ -13,7 +17,7 @@ describe("Test client initialization", () => { }); it("should create a client in debug mode", () => { - const client = new Client({ debug: true }); + const client = new Client({ apiKey: "invalid-api-key", debug: true }); expect(client).to.exist; }); }); diff --git a/tests/v1/extras/extras.integration.ts b/tests/v1/extras/extras.integration.ts index 2f4dcc22..f58ad306 100644 --- a/tests/v1/extras/extras.integration.ts +++ b/tests/v1/extras/extras.integration.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; -import * as mindee from "../../../src"; +import * as mindee from "@/index.js"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../index"; +import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - Extras Integration Tests", async () => { @@ -20,7 +20,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { mindee.product.InvoiceV4, sample, { cropper: true } ); expect(response.document.inference.pages[0]?.extras?.cropper).to.exist; - }).timeout(60000); + }).timeout(70000); it("should send full text OCR extra", async () => { const sample = new mindee.PathInput({ @@ -32,7 +32,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { ); expect(response.document?.extras?.fullTextOcr).to.exist; - }).timeout(60000); + }).timeout(70000); it("should send OCR words synchronously", async () => { const sample = new mindee.PathInput({ @@ -45,7 +45,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { expect(response.document?.ocr).to.exist; expect(response.document?.ocr?.toString()).to.not.be.empty; - }).timeout(65000); + }).timeout(70000); it("should send OCR words asynchronously", async () => { const sample = new mindee.PathInput({ @@ -58,5 +58,5 @@ describe("MindeeV1 - Extras Integration Tests", async () => { expect(response.document?.ocr).to.exist; expect(response.document?.ocr?.toString()).to.not.be.empty; - }).timeout(65000); + }).timeout(70000); }); diff --git a/tests/v1/extras/fullTextOcr.spec.ts b/tests/v1/extras/fullTextOcr.spec.ts index 115c4777..d20ae737 100644 --- a/tests/v1/extras/fullTextOcr.spec.ts +++ b/tests/v1/extras/fullTextOcr.spec.ts @@ -1,9 +1,9 @@ import { promises as fs } from "fs"; import path from "path"; import { expect } from "chai"; -import { AsyncPredictResponse } from "../../../src"; -import { InternationalIdV2 } from "../../../src/product"; -import { RESOURCE_PATH } from "../../index"; +import { AsyncPredictResponse } from "@/index.js"; +import { InternationalIdV2 } from "@/product/index.js"; +import { RESOURCE_PATH } from "../../index.js"; const fullTextOcrDir = path.join(RESOURCE_PATH, "v1/extras/full_text_ocr"); diff --git a/tests/v1/extras/ocr.spec.ts b/tests/v1/extras/ocr.spec.ts index 95a3c6ba..96970240 100644 --- a/tests/v1/extras/ocr.spec.ts +++ b/tests/v1/extras/ocr.spec.ts @@ -1,9 +1,9 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; -import { ReceiptV5 } from "../../../src/product"; -import { Document } from "../../../src"; -import { RESOURCE_PATH } from "../../index"; +import { ReceiptV5 } from "@/product/index.js"; +import { Document } from "@/index.js"; +import { RESOURCE_PATH } from "../../index.js"; const dataPath = { complete: path.join(RESOURCE_PATH, "v1/extras/ocr/complete.json"), diff --git a/tests/imageOperations/invoiceSplitterExtractor.spec.ts b/tests/v1/imageOperations/invoiceSplitterExtractor.spec.ts similarity index 86% rename from tests/imageOperations/invoiceSplitterExtractor.spec.ts rename to tests/v1/imageOperations/invoiceSplitterExtractor.spec.ts index 4d2eaddd..ed20a3d9 100644 --- a/tests/imageOperations/invoiceSplitterExtractor.spec.ts +++ b/tests/v1/imageOperations/invoiceSplitterExtractor.spec.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import path from "path"; -import { InvoiceSplitterV1 } from "../../src/product"; -import { extractInvoices } from "../../src/imageOperations"; -import { PathInput } from "../../src"; -import { V1_PRODUCT_PATH } from "../index"; +import { InvoiceSplitterV1 } from "@/product/index.js"; +import { extractInvoices } from "@/imageOperations/index.js"; +import { PathInput } from "@/index.js"; +import { V1_PRODUCT_PATH } from "../../index.js"; const dataPath = { complete: path.join(V1_PRODUCT_PATH, "invoice_splitter/response_v1/complete.json"), diff --git a/tests/v1/api/invoiceSplitterReconstruction.spec.ts b/tests/v1/imageOperations/invoiceSplitterReconstruction.spec.ts similarity index 88% rename from tests/v1/api/invoiceSplitterReconstruction.spec.ts rename to tests/v1/imageOperations/invoiceSplitterReconstruction.spec.ts index 7d9425da..68c26083 100644 --- a/tests/v1/api/invoiceSplitterReconstruction.spec.ts +++ b/tests/v1/imageOperations/invoiceSplitterReconstruction.spec.ts @@ -1,11 +1,11 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import * as path from "path"; -import { Document } from "../../../src"; -import { InvoiceSplitterV1 } from "../../../src/product"; -import { extractInvoices } from "../../../src/imageOperations"; -import { PathInput } from "../../../src"; -import { V1_PRODUCT_PATH } from "../../index"; +import { Document } from "@/index.js"; +import { InvoiceSplitterV1 } from "@/product/index.js"; +import { extractInvoices } from "@/imageOperations/index.js"; +import { PathInput } from "@/index.js"; +import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - A Multipage Invoice Document", () => { diff --git a/tests/imageOperations/multiReceiptsExtractor.spec.ts b/tests/v1/imageOperations/multiReceiptsExtractor.spec.ts similarity index 92% rename from tests/imageOperations/multiReceiptsExtractor.spec.ts rename to tests/v1/imageOperations/multiReceiptsExtractor.spec.ts index ea8c65b6..46c61a8f 100644 --- a/tests/imageOperations/multiReceiptsExtractor.spec.ts +++ b/tests/v1/imageOperations/multiReceiptsExtractor.spec.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import path from "path"; -import { MultiReceiptsDetectorV1 } from "../../src/product"; -import { extractReceipts } from "../../src/imageOperations"; -import { PathInput } from "../../src"; -import { V1_PRODUCT_PATH } from "../index"; +import { MultiReceiptsDetectorV1 } from "@/product/index.js"; +import { extractReceipts } from "@/imageOperations/index.js"; +import { PathInput } from "@/index.js"; +import { V1_PRODUCT_PATH } from "../../index.js"; const dataPath = { complete: path.join(V1_PRODUCT_PATH, "multi_receipts_detector/response_v1/complete.json"), diff --git a/tests/v1/api/multiReceiptsReconstruction.integration.ts b/tests/v1/imageOperations/multiReceiptsReconstruction.integration.ts similarity index 96% rename from tests/v1/api/multiReceiptsReconstruction.integration.ts rename to tests/v1/imageOperations/multiReceiptsReconstruction.integration.ts index 871313c0..5e15b07c 100644 --- a/tests/v1/api/multiReceiptsReconstruction.integration.ts +++ b/tests/v1/imageOperations/multiReceiptsReconstruction.integration.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import * as path from "path"; -import { Client, PathInput } from "../../../src"; -import { MultiReceiptsDetectorV1, ReceiptV5 } from "../../../src/product"; -import { extractReceipts } from "../../../src/imageOperations"; -import { V1_PRODUCT_PATH } from "../../index"; -import { LocalInputSource } from "../../../src/input"; +import { Client, PathInput } from "@/index.js"; +import { MultiReceiptsDetectorV1, ReceiptV5 } from "@/product/index.js"; +import { extractReceipts } from "@/imageOperations/index.js"; +import { V1_PRODUCT_PATH } from "../../index.js"; +import { LocalInputSource } from "@/input/index.js"; import { setTimeout } from "node:timers/promises"; const apiKey = process.env.MINDEE_API_KEY; diff --git a/tests/v1/api/multiReceiptsReconstruction.spec.ts b/tests/v1/imageOperations/multiReceiptsReconstruction.spec.ts similarity index 92% rename from tests/v1/api/multiReceiptsReconstruction.spec.ts rename to tests/v1/imageOperations/multiReceiptsReconstruction.spec.ts index b7b98963..3890fffc 100644 --- a/tests/v1/api/multiReceiptsReconstruction.spec.ts +++ b/tests/v1/imageOperations/multiReceiptsReconstruction.spec.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import * as path from "path"; -import { Document, PathInput } from "../../../src"; -import { MultiReceiptsDetectorV1 } from "../../../src/product"; -import { extractReceipts } from "../../../src/imageOperations"; -import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../../index"; +import { Document, PathInput } from "@/index.js"; +import { MultiReceiptsDetectorV1 } from "@/product/index.js"; +import { extractReceipts } from "@/imageOperations/index.js"; +import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../../index.js"; const rotations = [ { angle: 0, suffix: "" }, diff --git a/tests/v1/input/localResponse.spec.ts b/tests/v1/input/localResponse.spec.ts index 742c28b9..a7e74b43 100644 --- a/tests/v1/input/localResponse.spec.ts +++ b/tests/v1/input/localResponse.spec.ts @@ -1,9 +1,9 @@ import * as fs from "node:fs/promises"; import { expect } from "chai"; -import { Client, PredictResponse, AsyncPredictResponse, LocalResponse } from "../../../src"; -import { InternationalIdV2, InvoiceV4, MultiReceiptsDetectorV1 } from "../../../src/product"; +import { Client, PredictResponse, AsyncPredictResponse, LocalResponse } from "@/index.js"; +import { InternationalIdV2, InvoiceV4, MultiReceiptsDetectorV1 } from "@/product/index.js"; import path from "path"; -import { V1_RESOURCE_PATH, V1_PRODUCT_PATH } from "../../index"; +import { V1_RESOURCE_PATH, V1_PRODUCT_PATH } from "../../index.js"; const signature: string = "5ed1673e34421217a5dbfcad905ee62261a3dd66c442f3edd19302072bbf70d0"; const dummySecretKey: string = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH"; diff --git a/tests/v1/parsing/standard/amount.spec.ts b/tests/v1/parsing/standard/amount.spec.ts index b21452cb..b9e36e16 100644 --- a/tests/v1/parsing/standard/amount.spec.ts +++ b/tests/v1/parsing/standard/amount.spec.ts @@ -1,4 +1,4 @@ -import { AmountField } from "../../../../src/parsing/standard"; +import { AmountField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test AmountField field", () => { diff --git a/tests/v1/parsing/standard/classification.spec.ts b/tests/v1/parsing/standard/classification.spec.ts index f0073a4b..d8ae02b8 100644 --- a/tests/v1/parsing/standard/classification.spec.ts +++ b/tests/v1/parsing/standard/classification.spec.ts @@ -1,4 +1,4 @@ -import { ClassificationField } from "../../../../src/parsing/standard"; +import { ClassificationField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Classification field", () => { diff --git a/tests/v1/parsing/standard/date.spec.ts b/tests/v1/parsing/standard/date.spec.ts index ef120f24..20519b2f 100644 --- a/tests/v1/parsing/standard/date.spec.ts +++ b/tests/v1/parsing/standard/date.spec.ts @@ -1,4 +1,4 @@ -import { DateField } from "../../../../src/parsing/standard"; +import { DateField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Date field", () => { diff --git a/tests/v1/parsing/standard/field.spec.ts b/tests/v1/parsing/standard/field.spec.ts index e68cd2fd..01c36a10 100644 --- a/tests/v1/parsing/standard/field.spec.ts +++ b/tests/v1/parsing/standard/field.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { Field } from "../../../../src/parsing/standard"; +import { Field } from "@/parsing/standard/index.js"; describe("Test different inits of Field", () => { it("Should create a Field", () => { diff --git a/tests/v1/parsing/standard/locale.spec.ts b/tests/v1/parsing/standard/locale.spec.ts index 0aa8d786..fbde7c86 100644 --- a/tests/v1/parsing/standard/locale.spec.ts +++ b/tests/v1/parsing/standard/locale.spec.ts @@ -1,4 +1,4 @@ -import { LocaleField } from "../../../../src/parsing/standard"; +import { LocaleField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test LocaleField field", () => { diff --git a/tests/v1/parsing/standard/orientation.spec.ts b/tests/v1/parsing/standard/orientation.spec.ts index 97d95a4a..45ef4c20 100644 --- a/tests/v1/parsing/standard/orientation.spec.ts +++ b/tests/v1/parsing/standard/orientation.spec.ts @@ -1,4 +1,4 @@ -import { OrientationField } from "../../../../src/parsing/common"; +import { OrientationField } from "@/parsing/common/index.js"; import { expect } from "chai"; describe("Test Orientation field", () => { diff --git a/tests/v1/parsing/standard/paymentDetails.spec.ts b/tests/v1/parsing/standard/paymentDetails.spec.ts index 0f2e723b..b2f4c9e8 100644 --- a/tests/v1/parsing/standard/paymentDetails.spec.ts +++ b/tests/v1/parsing/standard/paymentDetails.spec.ts @@ -1,4 +1,4 @@ -import { PaymentDetailsField } from "../../../../src/parsing/standard"; +import { PaymentDetailsField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test PaymentDetailsField field", () => { diff --git a/tests/v1/parsing/standard/position.spec.ts b/tests/v1/parsing/standard/position.spec.ts index eee66913..8e8a4c0b 100644 --- a/tests/v1/parsing/standard/position.spec.ts +++ b/tests/v1/parsing/standard/position.spec.ts @@ -1,4 +1,4 @@ -import { PositionField } from "../../../../src/parsing/standard"; +import { PositionField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Position field", () => { diff --git a/tests/v1/parsing/standard/tax.spec.ts b/tests/v1/parsing/standard/tax.spec.ts index 62e9c703..fb52d9ba 100644 --- a/tests/v1/parsing/standard/tax.spec.ts +++ b/tests/v1/parsing/standard/tax.spec.ts @@ -1,4 +1,4 @@ -import { TaxField } from "../../../../src/parsing/standard"; +import { TaxField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Tax field", () => { diff --git a/tests/v1/parsing/standard/text.spec.ts b/tests/v1/parsing/standard/text.spec.ts index 23c62d8e..9eaf260c 100644 --- a/tests/v1/parsing/standard/text.spec.ts +++ b/tests/v1/parsing/standard/text.spec.ts @@ -1,4 +1,4 @@ -import { StringField } from "../../../../src/parsing/standard"; +import { StringField } from "@/parsing/standard/index.js"; import { expect } from "chai"; describe("Test String field", () => { diff --git a/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts b/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts index 3aff7da7..cdbc159e 100644 --- a/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts +++ b/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/billOfLading/billOfLadingV1.spec.ts b/tests/v1/product/billOfLading/billOfLadingV1.spec.ts deleted file mode 100644 index 1934d741..00000000 --- a/tests/v1/product/billOfLading/billOfLadingV1.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; -import { expect } from "chai"; -import * as mindee from "../../../../src"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "bill_of_lading/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "bill_of_lading/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "bill_of_lading/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "bill_of_lading/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - BillOfLadingV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.BillOfLadingV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.billOfLadingNumber.value).to.be.undefined; - expect(docPrediction.shipper.address).to.be.null; - expect(docPrediction.shipper.email).to.be.null; - expect(docPrediction.shipper.name).to.be.null; - expect(docPrediction.shipper.phone).to.be.null; - expect(docPrediction.consignee.address).to.be.null; - expect(docPrediction.consignee.email).to.be.null; - expect(docPrediction.consignee.name).to.be.null; - expect(docPrediction.consignee.phone).to.be.null; - expect(docPrediction.notifyParty.address).to.be.null; - expect(docPrediction.notifyParty.email).to.be.null; - expect(docPrediction.notifyParty.name).to.be.null; - expect(docPrediction.notifyParty.phone).to.be.null; - expect(docPrediction.carrier.name).to.be.null; - expect(docPrediction.carrier.professionalNumber).to.be.null; - expect(docPrediction.carrier.scac).to.be.null; - expect(docPrediction.carrierItems.length).to.be.equals(0); - expect(docPrediction.portOfLoading.value).to.be.undefined; - expect(docPrediction.portOfDischarge.value).to.be.undefined; - expect(docPrediction.placeOfDelivery.value).to.be.undefined; - expect(docPrediction.dateOfIssue.value).to.be.undefined; - expect(docPrediction.departureDate.value).to.be.undefined; - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.BillOfLadingV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/businessCard/businessCardV1.spec.ts b/tests/v1/product/businessCard/businessCardV1.spec.ts deleted file mode 100644 index 04e4c054..00000000 --- a/tests/v1/product/businessCard/businessCardV1.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; -import { expect } from "chai"; -import * as mindee from "../../../../src"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "business_card/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "business_card/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "business_card/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "business_card/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - BusinessCardV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.BusinessCardV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.firstname.value).to.be.undefined; - expect(docPrediction.lastname.value).to.be.undefined; - expect(docPrediction.jobTitle.value).to.be.undefined; - expect(docPrediction.company.value).to.be.undefined; - expect(docPrediction.email.value).to.be.undefined; - expect(docPrediction.phoneNumber.value).to.be.undefined; - expect(docPrediction.mobileNumber.value).to.be.undefined; - expect(docPrediction.faxNumber.value).to.be.undefined; - expect(docPrediction.address.value).to.be.undefined; - expect(docPrediction.website.value).to.be.undefined; - expect(docPrediction.socialMedia.length).to.be.equals(0); - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.BusinessCardV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/cropper/cropperV1.spec.ts b/tests/v1/product/cropper/cropperV1.spec.ts index d606b458..46be40d1 100644 --- a/tests/v1/product/cropper/cropperV1.spec.ts +++ b/tests/v1/product/cropper/cropperV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/custom/customDocument.spec.ts b/tests/v1/product/custom/customDocument.spec.ts deleted file mode 100644 index 8de7b43d..00000000 --- a/tests/v1/product/custom/customDocument.spec.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { promises as fs } from "fs"; -import * as path from "path"; -import { expect } from "chai"; -import * as mindee from "../../../../src"; -import { CustomV1Document } from "../../../../src/product/custom/customV1Document"; -import { Page } from "../../../../src"; -import { CropperExtra } from "../../../../src/parsing/common/extras"; -import { CustomV1 } from "../../../../src/product"; -import { V1_PRODUCT_PATH } from "../../../index"; - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "custom/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "custom/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "custom/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "custom/response_v1/summary_page0.rst"), - page1String: path.join(V1_PRODUCT_PATH, "custom/response_v1/summary_page1.rst"), -}; - -const dataPathV2 = { - complete: path.join(V1_PRODUCT_PATH, "custom/response_v2/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "custom/response_v2/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "custom/response_v2/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "custom/response_v2/summary_page0.rst"), - page1String: path.join(V1_PRODUCT_PATH, "custom/response_v2/summary_page1.rst"), -}; - -describe("Custom Document Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonDataNA = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonDataNA.toString()); - const doc = new CustomV1(response.document.inference); - expect(doc.product.name).to.be.equals("ianare/field_test"); - expect(doc.prediction.fields.size).to.be.equals(10); - expect(doc.prediction.classifications.size).to.be.equals(1); - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(CustomV1, response.document); - const docInference = doc.inference.prediction as CustomV1Document; - const stringAll = docInference.fields.get("string_all"); - expect(stringAll).to.have.property("values"); - expect(stringAll?.contentsString("-")).to.equals("Mindee-is-awesome"); - expect(stringAll?.contentsList()).to.have.members([ - "Mindee", - "is", - "awesome", - ]); - expect(docInference.classifications.get("doc_type")).to.have.property("value"); - expect(docInference.fields.size).to.be.equals(10); - expect(docInference.classifications.size).to.be.equals(1); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); - - it("should load a complete page 0 prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(CustomV1, response.document); - const page0: Page = doc.inference?.pages[0] as Page; - expect(page0.orientation?.value).to.be.equals(0); - expect((page0?.extras && page0?.extras["cropper"] as CropperExtra)?.cropping.length).to.be.equals(1); - const pageString = await fs.readFile(path.join(dataPath.page0String)); - expect(page0.toString()).to.be.equals(pageString.toString()); - }); - - it("should load a complete page 1 prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(CustomV1, response.document); - const page1: Page = doc.inference?.pages[1] as Page; - expect(page1.orientation?.value).to.be.equals(0); - const pageString = await fs.readFile(path.join(dataPath.page1String)); - expect(page1.toString()).to.be.equals(pageString.toString()); - }); -}); - - -describe("Newer Custom Document Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonDataNA = await fs.readFile(path.resolve(dataPathV2.complete)); - const response = JSON.parse(jsonDataNA.toString()); - const doc = new CustomV1(response.document.inference); - expect(doc.product.name).to.be.equals("ianare/field_test"); - expect(doc.prediction.fields.size).to.be.equals(10); - expect(doc.prediction.classifications.size).to.be.equals(1); - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPathV2.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(CustomV1, response.document); - const docInference = doc.inference.prediction as CustomV1Document; - const stringAll = docInference.fields.get("string_all"); - expect(stringAll).to.have.property("values"); - expect(stringAll?.contentsString("-")).to.equals("Mindee-is-awesome"); - expect(stringAll?.contentsList()).to.have.members([ - "Mindee", - "is", - "awesome", - ]); - expect(docInference.classifications.get("doc_type")).to.have.property("value"); - expect(docInference.fields.size).to.be.equals(10); - expect(docInference.classifications.size).to.be.equals(1); - const docString = await fs.readFile(path.join(dataPathV2.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); - - it("should load a complete page 0 prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPathV2.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(CustomV1, response.document); - const page0: Page = doc.inference?.pages[0] as Page; - expect(page0.orientation?.value).to.be.equals(0); - expect((page0?.extras && page0?.extras["cropper"] as CropperExtra)?.cropping.length).to.be.equals(1); - const pageString = await fs.readFile(path.join(dataPathV2.page0String)); - expect(page0.toString()).to.be.equals(pageString.toString()); - }); - - it("should load a complete page 1 prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPathV2.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(CustomV1, response.document); - const page1: Page = doc.inference?.pages[1] as Page; - expect(page1.orientation?.value).to.be.equals(0); - const pageString = await fs.readFile(path.join(dataPathV2.page1String)); - expect(page1.toString()).to.be.equals(pageString.toString()); - }); -}); diff --git a/tests/v1/product/custom/lineItems.spec.ts b/tests/v1/product/custom/lineItems.spec.ts deleted file mode 100644 index c9b8b209..00000000 --- a/tests/v1/product/custom/lineItems.spec.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { promises as fs } from "fs"; -import { expect } from "chai"; -import { CustomV1 } from "../../../../src/product"; -import { CustomLine } from "../../../../src/parsing/custom"; -import { V1_PRODUCT_PATH } from "../../../index"; -import path from "node:path"; - -const dataPath = { - singleTable01: - path.join(V1_PRODUCT_PATH, "custom/response_v1/line_items/single_table_01.json"), -}; -const dataPathV2 = { - singleTable01: - path.join(V1_PRODUCT_PATH, "custom/response_v2/line_items/single_table_01.json"), -}; - -describe("Custom Document Line Items", async () => { - function testLineItems(lineItems: CustomLine[]) { - expect(lineItems).to.not.null; - expect(lineItems.length).to.be.eq(3); - const firstLine: CustomLine = lineItems[0]; - expect(firstLine.bbox.xMin).to.be.eq(0.059); - expect(firstLine.bbox.yMin).to.be.eq(0.351); - expect(firstLine.bbox.xMax).to.be.eq(0.3); - expect(firstLine.bbox.yMax).to.be.eq(0.36); - expect(firstLine.fields.size).to.be.eq(4); - expect(firstLine.fields.has("beneficiary_birth_date")).to.be.true; - expect(firstLine.fields.has("beneficiary_number")).to.be.true; - expect(firstLine.fields.has("beneficiary_name")).to.be.true; - expect(firstLine.fields.has("beneficiary_rank")).to.be.true; - expect( - lineItems[1].fields.get("beneficiary_number")?.confidence - ).to.be.eq(0.5); - expect( - lineItems[1].fields.get("beneficiary_birth_date")?.content - ).to.be.eq("2010-07-18"); - expect(lineItems[2].fields.size).to.be.eq(4); - expect(lineItems[2].fields.get("beneficiary_rank")?.content).to.be.eq( - "3" - ); - } - - it("with valid custom document V1 must build 3 lines", async () => { - const jsonData = await fs.readFile(dataPath.singleTable01); - const response = JSON.parse(jsonData.toString()); - const doc: CustomV1 = new CustomV1({ - prediction: response.document.inference.prediction, - pages: response.document.inference.pages - }); - const anchorNames: string[] = ["beneficiary_name"]; - const fieldNamesToLineItems: string[] = [ - "beneficiary_birth_date", - "beneficiary_number", - "beneficiary_name", - "beneficiary_rank", - ]; - - const docLineItems: CustomLine[] = doc.prediction.columnsToLineItems( - anchorNames, - fieldNamesToLineItems, - 0.011 - ); - testLineItems(docLineItems); - - const pageLineItems: CustomLine[] = doc.pages[0].prediction.columnsToLineItems( - anchorNames, - fieldNamesToLineItems, - 0.011 - ); - testLineItems(pageLineItems); - }); -}); - -describe("Newer Custom Document Line Items", async () => { - function testLineItems(lineItems: CustomLine[]) { - expect(lineItems).to.not.null; - expect(lineItems.length).to.be.eq(3); - const firstLine: CustomLine = lineItems[0]; - expect(firstLine.bbox.xMin).to.be.eq(0.059); - expect(firstLine.bbox.yMin).to.be.eq(0.351); - expect(firstLine.bbox.xMax).to.be.eq(0.3); - expect(firstLine.bbox.yMax).to.be.eq(0.36); - expect(firstLine.fields.size).to.be.eq(4); - expect(firstLine.fields.has("beneficiary_birth_date")).to.be.true; - expect(firstLine.fields.has("beneficiary_number")).to.be.true; - expect(firstLine.fields.has("beneficiary_name")).to.be.true; - expect(firstLine.fields.has("beneficiary_rank")).to.be.true; - expect( - lineItems[1].fields.get("beneficiary_number")?.confidence - ).to.be.eq(0.5); - expect( - lineItems[1].fields.get("beneficiary_birth_date")?.content - ).to.be.eq("2010-07-18"); - expect(lineItems[2].fields.size).to.be.eq(4); - expect(lineItems[2].fields.get("beneficiary_rank")?.content).to.be.eq( - "3" - ); - } - - it("with valid custom document V1 must build 3 lines", async () => { - const jsonData = await fs.readFile(dataPathV2.singleTable01); - const response = JSON.parse(jsonData.toString()); - const doc: CustomV1 = new CustomV1({ - prediction: response.document.inference.prediction, - pages: response.document.inference.pages - }); - const anchorNames: string[] = ["beneficiary_name"]; - const fieldNamesToLineItems: string[] = [ - "beneficiary_birth_date", - "beneficiary_number", - "beneficiary_name", - "beneficiary_rank", - ]; - - const docLineItems: CustomLine[] = doc.prediction.columnsToLineItems( - anchorNames, - fieldNamesToLineItems, - 0.011 - ); - testLineItems(docLineItems); - - const pageLineItems: CustomLine[] = doc.pages[0].prediction.columnsToLineItems( - anchorNames, - fieldNamesToLineItems, - 0.011 - ); - testLineItems(pageLineItems); - }); -}); diff --git a/tests/v1/product/deliveryNote/deliveryNoteV1.spec.ts b/tests/v1/product/deliveryNote/deliveryNoteV1.spec.ts deleted file mode 100644 index 4291a0ac..00000000 --- a/tests/v1/product/deliveryNote/deliveryNoteV1.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; -import { expect } from "chai"; -import * as mindee from "../../../../src"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "delivery_notes/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "delivery_notes/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "delivery_notes/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "delivery_notes/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - DeliveryNoteV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.DeliveryNoteV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.deliveryDate.value).to.be.undefined; - expect(docPrediction.deliveryNumber.value).to.be.undefined; - expect(docPrediction.supplierName.value).to.be.undefined; - expect(docPrediction.supplierAddress.value).to.be.undefined; - expect(docPrediction.customerName.value).to.be.undefined; - expect(docPrediction.customerAddress.value).to.be.undefined; - expect(docPrediction.totalAmount.value).to.be.undefined; - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.DeliveryNoteV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/driverLicense/driverLicenseV1.spec.ts b/tests/v1/product/driverLicense/driverLicenseV1.spec.ts index 46205bc3..9de62754 100644 --- a/tests/v1/product/driverLicense/driverLicenseV1.spec.ts +++ b/tests/v1/product/driverLicense/driverLicenseV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/financialDocument/financialDocumentV1.spec.ts b/tests/v1/product/financialDocument/financialDocumentV1.spec.ts index 0abeed70..7af1f694 100644 --- a/tests/v1/product/financialDocument/financialDocumentV1.spec.ts +++ b/tests/v1/product/financialDocument/financialDocumentV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; -import * as mindee from "../../../../src"; -import { V1_PRODUCT_PATH } from "../../../index"; +import * as mindee from "@/index.js"; +import { V1_PRODUCT_PATH } from "../../../index.js"; const dataPath = { receiptComplete: path.join( diff --git a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts index 3e531615..50b859cc 100644 --- a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts +++ b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts index 1c68c183..7acfa6b1 100644 --- a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts +++ b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/energyBill/energyBillV1.spec.ts b/tests/v1/product/fr/energyBill/energyBillV1.spec.ts index 1c1c03c3..2147658b 100644 --- a/tests/v1/product/fr/energyBill/energyBillV1.spec.ts +++ b/tests/v1/product/fr/energyBill/energyBillV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/healthCard/healthCardV1.spec.ts b/tests/v1/product/fr/healthCard/healthCardV1.spec.ts index ef03a6a0..9185db9a 100644 --- a/tests/v1/product/fr/healthCard/healthCardV1.spec.ts +++ b/tests/v1/product/fr/healthCard/healthCardV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/idCard/idCardV1.spec.ts b/tests/v1/product/fr/idCard/idCardV1.spec.ts index 4c3b1443..c1bb3755 100644 --- a/tests/v1/product/fr/idCard/idCardV1.spec.ts +++ b/tests/v1/product/fr/idCard/idCardV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/idCard/idCardV2.spec.ts b/tests/v1/product/fr/idCard/idCardV2.spec.ts index 37e1d280..f53de20e 100644 --- a/tests/v1/product/fr/idCard/idCardV2.spec.ts +++ b/tests/v1/product/fr/idCard/idCardV2.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/payslip/payslipV2.spec.ts b/tests/v1/product/fr/payslip/payslipV2.spec.ts index ef7c0576..cd07cd3a 100644 --- a/tests/v1/product/fr/payslip/payslipV2.spec.ts +++ b/tests/v1/product/fr/payslip/payslipV2.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/fr/payslip/payslipV3.spec.ts b/tests/v1/product/fr/payslip/payslipV3.spec.ts index 2ee0fb82..22da5181 100644 --- a/tests/v1/product/fr/payslip/payslipV3.spec.ts +++ b/tests/v1/product/fr/payslip/payslipV3.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/generated/generatedList.spec.ts b/tests/v1/product/generated/generatedList.spec.ts index b8ce62f8..a93262a9 100644 --- a/tests/v1/product/generated/generatedList.spec.ts +++ b/tests/v1/product/generated/generatedList.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { GeneratedListField } from "../../../../src/parsing/generated"; +import { GeneratedListField } from "@/parsing/generated"; describe("Generated List Field Objects", async () => { it("should properly format floats.", async () => { diff --git a/tests/v1/product/generated/generatedObject.spec.ts b/tests/v1/product/generated/generatedObject.spec.ts index 7b9b06ec..7d5aecda 100644 --- a/tests/v1/product/generated/generatedObject.spec.ts +++ b/tests/v1/product/generated/generatedObject.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { GeneratedObjectField } from "../../../../src/parsing/generated"; +import { GeneratedObjectField } from "@/parsing/generated"; describe("Generated Object Field", async () => { it("should properly format booleans.", async () => { diff --git a/tests/v1/product/generated/generatedV1.spec.ts b/tests/v1/product/generated/generatedV1.spec.ts index 62a0a58b..834c7778 100644 --- a/tests/v1/product/generated/generatedV1.spec.ts +++ b/tests/v1/product/generated/generatedV1.spec.ts @@ -1,13 +1,13 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; -import * as mindee from "../../../../src"; -import { Page } from "../../../../src"; -import { GeneratedV1 } from "../../../../src/product"; -import { GeneratedListField, GeneratedObjectField } from "../../../../src/parsing/generated"; -import { GeneratedV1Page } from "../../../../src/product/generated/generatedV1Page"; -import { StringField } from "../../../../src/parsing/standard"; -import { V1_PRODUCT_PATH } from "../../../index"; +import * as mindee from "@/index.js"; +import { Page } from "@/index.js"; +import { GeneratedV1 } from "@/product/index.js"; +import { GeneratedListField, GeneratedObjectField } from "@/parsing/generated"; +import { GeneratedV1Page } from "@/product/generated/generatedV1Page"; +import { StringField } from "@/parsing/standard/index.js"; +import { V1_PRODUCT_PATH } from "../../../index.js"; const dataPathInternationalId = { complete: path.join(V1_PRODUCT_PATH, "generated/response_v1/complete_international_id_v1.json"), diff --git a/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts b/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts index 0cd5be98..8d68d075 100644 --- a/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts +++ b/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/internationalId/internationalIdV2.spec.ts b/tests/v1/product/internationalId/internationalIdV2.spec.ts index 921f778b..67790b13 100644 --- a/tests/v1/product/internationalId/internationalIdV2.spec.ts +++ b/tests/v1/product/internationalId/internationalIdV2.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/invoice/invoiceV4.spec.ts b/tests/v1/product/invoice/invoiceV4.spec.ts index 534c65f3..ab27ee89 100644 --- a/tests/v1/product/invoice/invoiceV4.spec.ts +++ b/tests/v1/product/invoice/invoiceV4.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts b/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts index 54f105a3..64fdb566 100644 --- a/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts +++ b/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts @@ -1,10 +1,10 @@ -import * as mindee from "../../../../src"; -import { InvoiceSplitterV1 } from "../../../../src/product"; +import * as mindee from "@/index.js"; +import { InvoiceSplitterV1 } from "@/product/index.js"; import { expect } from "chai"; import { levenshteinRatio } from "../../../testingUtilities"; import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; describe("MindeeV1 - InvoiceSplitterV1 Integration Tests", async () => { let client: mindee.Client; diff --git a/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts b/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts index 42edc446..9baefa27 100644 --- a/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts +++ b/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts b/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts index 43f18e15..b742ceb1 100644 --- a/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts +++ b/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/nutritionFactsLabel/nutritionFactsLabelV1.spec.ts b/tests/v1/product/nutritionFactsLabel/nutritionFactsLabelV1.spec.ts deleted file mode 100644 index 3cb5a832..00000000 --- a/tests/v1/product/nutritionFactsLabel/nutritionFactsLabelV1.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; -import { expect } from "chai"; -import * as mindee from "../../../../src"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "nutrition_facts/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "nutrition_facts/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "nutrition_facts/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "nutrition_facts/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - NutritionFactsLabelV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.NutritionFactsLabelV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.servingPerBox.value).to.be.undefined; - expect(docPrediction.servingSize.amount).to.be.null; - expect(docPrediction.servingSize.unit).to.be.null; - expect(docPrediction.calories.dailyValue).to.be.null; - expect(docPrediction.calories.per100G).to.be.null; - expect(docPrediction.calories.perServing).to.be.null; - expect(docPrediction.totalFat.dailyValue).to.be.null; - expect(docPrediction.totalFat.per100G).to.be.null; - expect(docPrediction.totalFat.perServing).to.be.null; - expect(docPrediction.saturatedFat.dailyValue).to.be.null; - expect(docPrediction.saturatedFat.per100G).to.be.null; - expect(docPrediction.saturatedFat.perServing).to.be.null; - expect(docPrediction.transFat.dailyValue).to.be.null; - expect(docPrediction.transFat.per100G).to.be.null; - expect(docPrediction.transFat.perServing).to.be.null; - expect(docPrediction.cholesterol.dailyValue).to.be.null; - expect(docPrediction.cholesterol.per100G).to.be.null; - expect(docPrediction.cholesterol.perServing).to.be.null; - expect(docPrediction.totalCarbohydrate.dailyValue).to.be.null; - expect(docPrediction.totalCarbohydrate.per100G).to.be.null; - expect(docPrediction.totalCarbohydrate.perServing).to.be.null; - expect(docPrediction.dietaryFiber.dailyValue).to.be.null; - expect(docPrediction.dietaryFiber.per100G).to.be.null; - expect(docPrediction.dietaryFiber.perServing).to.be.null; - expect(docPrediction.totalSugars.dailyValue).to.be.null; - expect(docPrediction.totalSugars.per100G).to.be.null; - expect(docPrediction.totalSugars.perServing).to.be.null; - expect(docPrediction.addedSugars.dailyValue).to.be.null; - expect(docPrediction.addedSugars.per100G).to.be.null; - expect(docPrediction.addedSugars.perServing).to.be.null; - expect(docPrediction.protein.dailyValue).to.be.null; - expect(docPrediction.protein.per100G).to.be.null; - expect(docPrediction.protein.perServing).to.be.null; - expect(docPrediction.sodium.dailyValue).to.be.null; - expect(docPrediction.sodium.per100G).to.be.null; - expect(docPrediction.sodium.perServing).to.be.null; - expect(docPrediction.sodium.unit).to.be.null; - expect(docPrediction.nutrients.length).to.be.equals(0); - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.NutritionFactsLabelV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/passport/passportV1.spec.ts b/tests/v1/product/passport/passportV1.spec.ts index b9356f99..c609e2ac 100644 --- a/tests/v1/product/passport/passportV1.spec.ts +++ b/tests/v1/product/passport/passportV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/receipt/receiptV5.spec.ts b/tests/v1/product/receipt/receiptV5.spec.ts index 00196591..ff6b90bb 100644 --- a/tests/v1/product/receipt/receiptV5.spec.ts +++ b/tests/v1/product/receipt/receiptV5.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/resume/resumeV1.spec.ts b/tests/v1/product/resume/resumeV1.spec.ts index eefe0696..229a0dfa 100644 --- a/tests/v1/product/resume/resumeV1.spec.ts +++ b/tests/v1/product/resume/resumeV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../index"; +import { V1_PRODUCT_PATH } from "../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts b/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts index 7ae7d6d9..1536dd92 100644 --- a/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts +++ b/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/product/us/healthcareCard/healthcareCardV1.spec.ts b/tests/v1/product/us/healthcareCard/healthcareCardV1.spec.ts deleted file mode 100644 index 72c4c878..00000000 --- a/tests/v1/product/us/healthcareCard/healthcareCardV1.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { promises as fs } from "fs"; -import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; -import { expect } from "chai"; -import * as mindee from "../../../../../src"; - - -const dataPath = { - complete: path.join(V1_PRODUCT_PATH, "us_healthcare_cards/response_v1/complete.json"), - empty: path.join(V1_PRODUCT_PATH, "us_healthcare_cards/response_v1/empty.json"), - docString: path.join(V1_PRODUCT_PATH, "us_healthcare_cards/response_v1/summary_full.rst"), - page0String: path.join(V1_PRODUCT_PATH, "us_healthcare_cards/response_v1/summary_page0.rst"), -}; - -describe("MindeeV1 - HealthcareCardV1 Object initialization", async () => { - it("should load an empty document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.empty)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.HealthcareCardV1, response.document); - const docPrediction = doc.inference.prediction; - expect(docPrediction.companyName.value).to.be.undefined; - expect(docPrediction.planName.value).to.be.undefined; - expect(docPrediction.memberName.value).to.be.undefined; - expect(docPrediction.memberId.value).to.be.undefined; - expect(docPrediction.issuer80840.value).to.be.undefined; - expect(docPrediction.dependents.length).to.be.equals(0); - expect(docPrediction.groupNumber.value).to.be.undefined; - expect(docPrediction.payerId.value).to.be.undefined; - expect(docPrediction.rxBin.value).to.be.undefined; - expect(docPrediction.rxId.value).to.be.undefined; - expect(docPrediction.rxGrp.value).to.be.undefined; - expect(docPrediction.rxPcn.value).to.be.undefined; - expect(docPrediction.copays.length).to.be.equals(0); - expect(docPrediction.enrollmentDate.value).to.be.undefined; - }); - - it("should load a complete document prediction", async () => { - const jsonData = await fs.readFile(path.resolve(dataPath.complete)); - const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.HealthcareCardV1, response.document); - const docString = await fs.readFile(path.join(dataPath.docString)); - expect(doc.toString()).to.be.equals(docString.toString()); - }); -}); diff --git a/tests/v1/product/us/usMail/usMailV3.spec.ts b/tests/v1/product/us/usMail/usMailV3.spec.ts index e1773db5..cac767ed 100644 --- a/tests/v1/product/us/usMail/usMailV3.spec.ts +++ b/tests/v1/product/us/usMail/usMailV3.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../../../index"; +import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; -import * as mindee from "../../../../../src"; +import * as mindee from "@/index.js"; const dataPath = { diff --git a/tests/v1/workflows/workflow.integration.ts b/tests/v1/workflows/workflow.integration.ts index 0912425e..319da6e5 100644 --- a/tests/v1/workflows/workflow.integration.ts +++ b/tests/v1/workflows/workflow.integration.ts @@ -1,12 +1,12 @@ -import * as mindee from "../../../src"; -import { ExecutionPriority } from "../../../src/parsing/common"; +import * as mindee from "@/index.js"; +import { ExecutionPriority } from "@/parsing/common/index.js"; import { expect } from "chai"; -import { LocalInputSource } from "../../../src/input"; -import { OptionalAsyncOptions } from "../../../src/client"; -import { FinancialDocumentV1 } from "../../../src/product"; -import { RAGExtra } from "../../../src/parsing/common/extras/ragExtra"; +import { LocalInputSource } from "@/input/index.js"; +import { OptionalAsyncOptions } from "@/client.js"; +import { FinancialDocumentV1 } from "@/product/index.js"; +import { RAGExtra } from "@/parsing/common/extras/ragExtra.js"; import path from "path"; -import { V1_PRODUCT_PATH } from "../../index"; +import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - Workflow calls", () => { let client: mindee.Client; diff --git a/tests/v1/workflows/workflow.spec.ts b/tests/v1/workflows/workflow.spec.ts index de698df8..83d62eb2 100644 --- a/tests/v1/workflows/workflow.spec.ts +++ b/tests/v1/workflows/workflow.spec.ts @@ -1,25 +1,45 @@ import { expect } from "chai"; -import nock from "nock"; +import { MockAgent, setGlobalDispatcher } from "undici"; import { promises as fs } from "fs"; import path from "path"; -import { GeneratedV1 } from "../../../src/product"; -import { WorkflowResponse } from "../../../src/parsing/common/workflowResponse"; -import { V1_RESOURCE_PATH } from "../../index"; +import { RESOURCE_PATH, V1_RESOURCE_PATH } from "../../index.js"; +import { Client, PathInput } from "@/index.js"; + +const mockAgent = new MockAgent(); +setGlobalDispatcher(mockAgent); +const mockPool = mockAgent.get("https://v1-workflow-host"); + +async function setInterceptor(httpCode: number, jsonFilePath: string) { + const mockResponse = JSON.parse(await fs.readFile(jsonFilePath, "utf-8")); + mockPool + .intercept({ path: /v1\/workflows\/.*/, method: "POST" }) + .reply(httpCode, mockResponse); +} + +async function executeWorkflow(doc: PathInput, workflowId: string) { + const client = new Client({ apiKey: "my-api-key", debug: true, dispatcher: mockAgent }); + return await client.executeWorkflow(doc, workflowId); +} describe("MindeeV1 - Workflow executions", () => { - it("should deserialize response correctly when sending a document to an execution", async () => { - const jsonFilePath = path.join(V1_RESOURCE_PATH, "workflows", "success.json"); - const mockResponse = JSON.parse(await fs.readFile(jsonFilePath, "utf-8")); + const doc = new PathInput({ + inputPath: path.join(RESOURCE_PATH, "file_types/pdf/blank_1.pdf") + }); - nock("https://api.mindee.net") - .post("/v1/workflows/execute") - .reply(202, mockResponse); + beforeEach(function() { + process.env.MINDEE_API_HOST = "v1-workflow-host"; + }); - const mockedExecution = new WorkflowResponse( - GeneratedV1, - mockResponse - ); + afterEach(function() { + delete process.env.MINDEE_API_HOST; + }); + it("should deserialize response correctly when sending a document to an execution", async () => { + const jsonFilePath = path.join(V1_RESOURCE_PATH, "workflows", "success.json"); + await setInterceptor(202, jsonFilePath); + const mockedExecution = await executeWorkflow( + doc, "07ebf237-ff27-4eee-b6a2-425df4a5cca6" + ); expect(mockedExecution).to.not.be.null; expect(mockedExecution.apiRequest).to.not.be.null; expect(mockedExecution.execution.batchName).to.be.null; @@ -40,17 +60,10 @@ describe("MindeeV1 - Workflow executions", () => { it("should deserialize response correctly when sending a document to an execution with priority and alias", async () => { const jsonFilePath = path.join(V1_RESOURCE_PATH, "workflows", "success_low_priority.json"); - const mockResponse = JSON.parse(await fs.readFile(jsonFilePath, "utf-8")); - - nock("https://api.mindee.net") - .post("/v1/workflows/execute") - .reply(200, mockResponse); - - const mockedExecution = new WorkflowResponse( - GeneratedV1, - mockResponse + await setInterceptor(200, jsonFilePath); + const mockedExecution = await executeWorkflow( + doc, "07ebf237-ff27-4eee-b6a2-425df4a5cca6" ); - expect(mockedExecution).to.not.be.null; expect(mockedExecution.apiRequest).to.not.be.null; expect(mockedExecution.execution.batchName).to.be.null; diff --git a/tests/v2/clientV2.integration.ts b/tests/v2/clientV2.integration.ts index 4583d90d..59867519 100644 --- a/tests/v2/clientV2.integration.ts +++ b/tests/v2/clientV2.integration.ts @@ -8,12 +8,12 @@ import { UrlInput, Base64Input, InferenceResponse, -} from "../../src"; -import { Inference } from "../../src/parsing/v2"; -import { SimpleField } from "../../src/parsing/v2/field"; -import { MindeeHttpErrorV2 } from "../../src/errors/mindeeError"; +} from "@/index.js"; +import { Inference } from "@/parsing/v2/index.js"; +import { SimpleField } from "@/parsing/v2/field/index.js"; +import { MindeeHttpErrorV2 } from "@/errors/mindeeError.js"; import * as fs from "node:fs"; -import { RESOURCE_PATH, V2_PRODUCT_PATH, V2_RESOURCE_PATH } from "../index"; +import { RESOURCE_PATH, V2_PRODUCT_PATH, V2_RESOURCE_PATH } from "../index.js"; function check422(err: unknown) { expect(err).to.be.instanceOf(MindeeHttpErrorV2); @@ -63,7 +63,7 @@ describe("MindeeV2 – Client Integration Tests", () => { const apiKey = process.env["MINDEE_V2_API_KEY"] ?? ""; modelId = process.env["MINDEE_V2_FINDOC_MODEL_ID"] ?? ""; - client = new ClientV2({ apiKey }); + client = new ClientV2({ apiKey: apiKey, debug: true }); }); before(async () => { dataSchemaReplace = fs.readFileSync(dataSchemaReplacePath).toString(); diff --git a/tests/v2/clientV2.spec.ts b/tests/v2/clientV2.spec.ts index 552784bc..95363b36 100644 --- a/tests/v2/clientV2.spec.ts +++ b/tests/v2/clientV2.spec.ts @@ -1,11 +1,14 @@ -/* eslint-disable @typescript-eslint/naming-convention,camelcase */ import { expect } from "chai"; -import nock from "nock"; +import { MockAgent, setGlobalDispatcher } from "undici"; import path from "node:path"; -import { ClientV2, LocalResponse, PathInput, InferenceResponse } from "../../src"; -import { MindeeHttpErrorV2 } from "../../src/errors/mindeeError"; +import { ClientV2, LocalResponse, PathInput, InferenceResponse } from "@/index.js"; +import { MindeeHttpErrorV2 } from "@/errors/mindeeError.js"; import assert from "node:assert/strict"; -import { RESOURCE_PATH, V2_RESOURCE_PATH } from "../index"; +import { RESOURCE_PATH, V2_RESOURCE_PATH } from "../index.js"; + +const mockAgent = new MockAgent(); +setGlobalDispatcher(mockAgent); +const mockPool = mockAgent.get("https://v2-client-host"); /** * Injects a minimal set of environment variables so that the SDK behaves @@ -13,18 +16,19 @@ import { RESOURCE_PATH, V2_RESOURCE_PATH } from "../index"; */ function dummyEnvvars(): void { process.env.MINDEE_V2_API_KEY = "dummy"; - process.env.MINDEE_V2_API_HOST = "dummy-url"; + process.env.MINDEE_V2_API_HOST = "v2-client-host"; } function setNockInterceptors(): void { - nock("https://dummy-url") - .persist() - .post(/.*/) - .reply(400, { status: 400, detail: "forced failure from test" }); - - nock("https://dummy-url") - .persist() - .get(/.*/) + mockPool + .intercept({ path: /.*/, method: "POST" }) + .reply( + 400, + { status: 400, detail: "forced failure from test", title: "Bad Request", code: "400-001" } + ); + + mockPool + .intercept({ path: /.*/, method: "GET" }) .reply(200, { job: { id: "12345678-1234-1234-1234-123456789ABC", @@ -46,12 +50,10 @@ const fileTypesDir = path.join(RESOURCE_PATH, "file_types"); describe("MindeeV2 - ClientV2", () => { before(() => { - setNockInterceptors(); dummyEnvvars(); }); after(() => { - nock.cleanAll(); delete process.env.MINDEE_V2_API_KEY; delete process.env.MINDEE_V2_API_HOST; }); @@ -60,28 +62,33 @@ describe("MindeeV2 - ClientV2", () => { let client: ClientV2; beforeEach(() => { - client = new ClientV2({ apiKey: "dummy" }); + setNockInterceptors(); + client = new ClientV2({ apiKey: "dummy", debug: true, dispatcher: mockAgent }); }); it("inherits base URL, token & headers from the env / options", () => { const api = (client as any).mindeeApi; expect(api.settings.apiKey).to.equal("dummy"); - expect(api.settings.hostname).to.equal("dummy-url"); + expect(api.settings.hostname).to.equal("v2-client-host"); expect(api.settings.baseHeaders.Authorization).to.equal("dummy"); expect(api.settings.baseHeaders["User-Agent"]).to.match(/mindee/i); }); - it("enqueue(path) rejects with MindeeHttpErrorV2 on 4xx", async () => { + it("enqueue(path) rejects with MindeeHttpErrorV2 on 400", async () => { const filePath = path.join(fileTypesDir, "receipt.jpg"); const inputDoc = new PathInput({ inputPath: filePath }); await assert.rejects( client.enqueueInference(inputDoc, { modelId: "dummy-model", textContext: "hello" }), - MindeeHttpErrorV2 + (error: any) => { + assert.strictEqual(error instanceof MindeeHttpErrorV2, true); + assert.strictEqual(error.status, 400); + return true; + } ); }); - it("enqueueAndParse(path) rejects with MindeeHttpErrorV2 on 4xx", async () => { + it("enqueueAndParse(path) rejects with MindeeHttpErrorV2 on 400", async () => { const filePath = path.join(fileTypesDir, "receipt.jpg"); const inputDoc = new PathInput({ inputPath: filePath }); await assert.rejects( @@ -89,7 +96,11 @@ describe("MindeeV2 - ClientV2", () => { inputDoc, { modelId: "dummy-model", rag: false } ), - MindeeHttpErrorV2 + (error: any) => { + assert.strictEqual(error instanceof MindeeHttpErrorV2, true); + assert.strictEqual(error.status, 400); + return true; + } ); }); @@ -118,15 +129,15 @@ describe("MindeeV2 - ClientV2", () => { "default_sample.jpg" ), }); - try { - await client.enqueueInference(input, { modelId: "dummy-model" }); - expect.fail("enqueue() should have thrown"); - } catch (err) { - expect(err).to.be.instanceOf(MindeeHttpErrorV2); - const httpErr = err as MindeeHttpErrorV2; - expect(httpErr.status).to.equal(400); - expect(httpErr.detail).to.equal("forced failure from test"); - } + await assert.rejects( + client.enqueueInference(input, { modelId: "dummy-model" }), + (error: any) => { + expect(error).to.be.instanceOf(MindeeHttpErrorV2); + expect(error.status).to.equal(400); + expect(error.detail).to.equal("forced failure from test"); + return true; + } + ); }); it("parseQueued(jobId) returns a fully-formed JobResponse", async () => { diff --git a/tests/v2/input/inferenceParameter.spec.ts b/tests/v2/input/inferenceParameter.spec.ts index 51a48171..72325c8f 100644 --- a/tests/v2/input/inferenceParameter.spec.ts +++ b/tests/v2/input/inferenceParameter.spec.ts @@ -1,9 +1,9 @@ -import { StringDict } from "../../../src/parsing/common"; +import { StringDict } from "@/parsing/common/index.js"; import path from "path"; -import { V2_RESOURCE_PATH } from "../../index"; -import { InferenceParameters } from "../../../src"; +import { V2_RESOURCE_PATH } from "../../index.js"; +import { InferenceParameters } from "@/index.js"; import { expect } from "chai"; -import { DataSchema } from "../../../src/input"; +import { DataSchema } from "@/input/index.js"; import { promises as fs } from "fs"; let expectedDataSchemaDict: StringDict; diff --git a/tests/v2/input/localResponse.spec.ts b/tests/v2/input/localResponse.spec.ts index 89eae6d1..c8fe35a0 100644 --- a/tests/v2/input/localResponse.spec.ts +++ b/tests/v2/input/localResponse.spec.ts @@ -1,9 +1,9 @@ import * as fs from "node:fs/promises"; import { expect } from "chai"; -import { InferenceResponse, LocalResponse } from "../../../src"; +import { InferenceResponse, LocalResponse } from "@/index.js"; import path from "path"; -import { V2_RESOURCE_PATH } from "../../index"; +import { V2_RESOURCE_PATH } from "../../index.js"; import { Buffer } from "node:buffer"; const signature: string = "1df388c992d87897fe61dfc56c444c58fc3c7369c31e2b5fd20d867695e93e85"; diff --git a/tests/v2/parsing/inference.spec.ts b/tests/v2/parsing/inference.spec.ts index 080610cf..3523780d 100644 --- a/tests/v2/parsing/inference.spec.ts +++ b/tests/v2/parsing/inference.spec.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import path from "node:path"; -import { LocalResponse, InferenceResponse, RawText, RagMetadata } from "../../../src"; -import { FieldConfidence, ListField, ObjectField, SimpleField } from "../../../src/parsing/v2/field"; +import { LocalResponse, InferenceResponse, RawText, RagMetadata } from "@/index.js"; +import { FieldConfidence, ListField, ObjectField, SimpleField } from "@/parsing/v2/field/index.js"; import { promises as fs } from "node:fs"; -import { Polygon } from "../../../src/geometry"; -import { V2_RESOURCE_PATH } from "../../index"; +import { Polygon } from "@/geometry/index.js"; +import { V2_RESOURCE_PATH } from "../../index.js"; const findocPath = path.join(V2_RESOURCE_PATH, "products", "financial_document"); const inferencePath = path.join(V2_RESOURCE_PATH, "inference"); diff --git a/tests/v2/parsing/job.spec.ts b/tests/v2/parsing/job.spec.ts index 675c0e92..9e65874b 100644 --- a/tests/v2/parsing/job.spec.ts +++ b/tests/v2/parsing/job.spec.ts @@ -1,8 +1,8 @@ -import { JobResponse, LocalResponse } from "../../../src"; +import { JobResponse, LocalResponse } from "@/index.js"; import path from "node:path"; -import { V2_RESOURCE_PATH } from "../../index"; +import { V2_RESOURCE_PATH } from "../../index.js"; import { expect } from "chai"; -import { ErrorResponse } from "../../../src/parsing/v2"; +import { ErrorResponse } from "@/parsing/v2/index.js"; const jobPath = path.join(V2_RESOURCE_PATH, "job"); diff --git a/tsconfig.json b/tsconfig.json index 2b4a5b3c..caabb86d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,27 @@ { "compilerOptions": { - "lib": ["ES2020"], - "module": "commonjs", - "target": "ES2020", - - "strict": true, + "baseUrl": "./", + "declaration": true, "esModuleInterop": true, - "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "moduleResolution": "node", - - "resolveJsonModule": true, - "declaration": true, + "isolatedModules": true, + "lib": [ + "ES2020" + ], + "module": "Node18", + "moduleResolution": "Node16", + "newLine": "lf", "outDir": "dist", - "baseUrl": "./", + "paths": { + "@/*": [ + "src/*" + ] + }, + "resolveJsonModule": true, + "skipLibCheck": true, "sourceMap": false, - "newLine": "lf", + "strict": true, + "target": "ES2020", }, "include": ["./src/**/*", "./bin/**/*", "LICENSE"], "exclude": ["./node_modules/", "./dist/", "./tests/"] From be40d85f9735492da7b1bfa59302b8c8c7e21fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Tue, 13 Jan 2026 10:21:51 +0100 Subject: [PATCH 2/6] :boom: complete rework of directory structure (#415) --- bin/mindeeV1.ts | 4 +- bin/mindeeV2.ts | 4 +- docs/code_samples/bank_account_details_v1.txt | 6 +- docs/code_samples/bank_account_details_v2.txt | 6 +- docs/code_samples/bank_check_v1.txt | 6 +- docs/code_samples/barcode_reader_v1.txt | 6 +- docs/code_samples/carte_grise_v1.txt | 6 +- docs/code_samples/cropper_v1.txt | 6 +- docs/code_samples/default.txt | 6 +- docs/code_samples/default_async.txt | 6 +- docs/code_samples/default_v2.txt | 4 +- docs/code_samples/driver_license_v1_async.txt | 6 +- .../code_samples/energy_bill_fra_v1_async.txt | 6 +- docs/code_samples/expense_receipts_v5.txt | 6 +- .../expense_receipts_v5_async.txt | 6 +- docs/code_samples/financial_document_v1.txt | 6 +- .../financial_document_v1_async.txt | 6 +- .../french_healthcard_v1_async.txt | 6 +- docs/code_samples/idcard_fr_v1.txt | 6 +- docs/code_samples/idcard_fr_v2.txt | 6 +- docs/code_samples/ind_passport_v1_async.txt | 6 +- .../international_id_v2_async.txt | 6 +- .../invoice_splitter_v1_async.txt | 6 +- docs/code_samples/invoices_v4.txt | 6 +- docs/code_samples/invoices_v4_async.txt | 6 +- .../multi_receipts_detector_v1.txt | 6 +- docs/code_samples/passport_v1.txt | 6 +- docs/code_samples/payslip_fra_v2_async.txt | 6 +- docs/code_samples/payslip_fra_v3_async.txt | 6 +- docs/code_samples/resume_v1_async.txt | 6 +- docs/code_samples/us_mail_v3_async.txt | 6 +- docs/code_samples/workflow_execution.txt | 4 +- docs/code_samples/workflow_ots_rag.txt | 6 +- docs/code_samples/workflow_polling.txt | 6 +- src/errors/index.ts | 7 +- src/errors/mindeeError.ts | 30 ++--- src/http/apiCore.ts | 4 +- src/http/index.ts | 23 +--- .../common => image}/extractedImage.ts | 6 +- .../imageCompressor.ts | 0 .../common => image}/imageExtractor.ts | 0 .../common => image}/index.ts | 1 + src/index.ts | 42 +++---- src/input/{sources => }/base64Input.ts | 0 src/input/{sources => }/bufferInput.ts | 0 src/input/{sources => }/bytesInput.ts | 0 src/input/index.ts | 20 +++- src/input/{sources => }/inputSource.ts | 0 src/input/{sources => }/localInputSource.ts | 5 +- src/input/pageOptions.ts | 6 +- src/input/{sources => }/pathInput.ts | 0 src/input/sources/index.ts | 15 --- src/input/{sources => }/streamInput.ts | 0 src/input/{sources => }/urlInput.ts | 0 src/parsing/{common => }/dateParser.ts | 0 src/parsing/index.ts | 6 +- .../localResponseBase.ts} | 27 +---- src/parsing/{common => }/stringDict.ts | 0 src/pdf/pdfCompressor.ts | 2 +- src/pdf/pdfOperation.ts | 6 +- src/product/fr/internal.ts | 5 - src/product/ind/index.ts | 1 - src/product/ind/internal.ts | 1 - src/product/internal.ts | 15 --- src/product/us/index.ts | 2 - src/product/us/internal.ts | 2 - src/{cliV1.ts => v1/cli.ts} | 22 ++-- src/{ => v1}/client.ts | 62 ++++------ .../extraction}/index.ts | 2 - .../extractedInvoiceSplitterImage.ts | 2 +- .../invoiceSplitterExtractor/index.ts | 0 .../invoiceSplitterExtractor.ts | 2 +- .../extractedMultiReceiptImage.ts | 2 +- .../multiReceiptsExtractor/index.ts | 0 .../multiReceiptsExtractor.ts | 6 +- .../http/apiSettingsV1.ts} | 10 +- src/{ => v1}/http/endpoint.ts | 40 +++---- src/{http/error.ts => v1/http/errors.ts} | 26 ++-- src/{ => v1}/http/httpParams.ts | 2 +- src/v1/http/index.ts | 19 +++ src/{ => v1}/http/responseValidation.ts | 8 +- src/{ => v1}/http/workflowEndpoint.ts | 18 +-- src/v1/index.ts | 19 +++ src/{ => v1}/parsing/common/apiRequest.ts | 2 +- src/{ => v1}/parsing/common/apiResponse.ts | 2 +- .../parsing/common/asyncPredictResponse.ts | 2 +- src/{ => v1}/parsing/common/document.ts | 2 +- src/{ => v1}/parsing/common/execution.ts | 6 +- src/{ => v1}/parsing/common/executionFile.ts | 2 +- .../parsing/common/executionPriority.ts | 0 .../parsing/common/extras/cropperExtra.ts | 4 +- src/{ => v1}/parsing/common/extras/extras.ts | 0 .../parsing/common/extras/fullTextOcrExtra.ts | 2 +- src/{ => v1}/parsing/common/extras/index.ts | 0 .../parsing/common/extras/ragExtra.ts | 2 +- .../common/feedback/feedbackResponse.ts | 2 +- src/{ => v1}/parsing/common/index.ts | 4 +- src/{ => v1}/parsing/common/inference.ts | 5 +- src/{ => v1}/parsing/common/mvisionV1.ts | 4 +- src/{ => v1}/parsing/common/ocr.ts | 2 +- src/{ => v1}/parsing/common/ocrPage.ts | 4 +- src/{ => v1}/parsing/common/orientation.ts | 2 +- src/{ => v1}/parsing/common/page.ts | 2 +- .../parsing/common/predictResponse.ts | 2 +- src/{ => v1}/parsing/common/prediction.ts | 0 src/{ => v1}/parsing/common/product.ts | 0 src/{ => v1}/parsing/common/summaryHelper.ts | 0 .../parsing/common/workflowResponse.ts | 2 +- .../parsing/generated/generatedList.ts | 4 +- .../parsing/generated/generatedObject.ts | 4 +- src/{ => v1}/parsing/generated/index.ts | 0 src/v1/parsing/index.ts | 4 + src/v1/parsing/localResponse.ts | 32 +++++ src/{ => v1}/parsing/standard/addressField.ts | 0 src/{ => v1}/parsing/standard/amount.ts | 2 +- src/{ => v1}/parsing/standard/base.ts | 2 +- src/{ => v1}/parsing/standard/boolean.ts | 2 +- .../parsing/standard/classification.ts | 0 .../parsing/standard/companyRegistration.ts | 2 +- src/{ => v1}/parsing/standard/date.ts | 0 src/{ => v1}/parsing/standard/field.ts | 0 src/{ => v1}/parsing/standard/index.ts | 0 src/{ => v1}/parsing/standard/locale.ts | 0 .../parsing/standard/paymentDetails.ts | 2 +- src/{ => v1}/parsing/standard/position.ts | 2 +- src/{ => v1}/parsing/standard/tax.ts | 2 +- src/{ => v1}/parsing/standard/text.ts | 2 +- src/{ => v1}/parsing/standard/word.ts | 0 .../product/barcodeReader/barcodeReaderV1.ts | 2 +- .../barcodeReader/barcodeReaderV1Document.ts | 4 +- src/{ => v1}/product/barcodeReader/index.ts | 0 src/{ => v1/product}/cliProducts.ts | 4 +- src/{ => v1}/product/cropper/cropperV1.ts | 2 +- .../product/cropper/cropperV1Document.ts | 2 +- src/{ => v1}/product/cropper/cropperV1Page.ts | 4 +- src/{ => v1}/product/cropper/index.ts | 0 .../product/driverLicense/driverLicenseV1.ts | 2 +- .../driverLicense/driverLicenseV1Document.ts | 4 +- src/{ => v1}/product/driverLicense/index.ts | 0 .../financialDocument/financialDocumentV1.ts | 2 +- .../financialDocumentV1Document.ts | 4 +- .../financialDocumentV1LineItem.ts | 4 +- .../product/financialDocument/index.ts | 0 .../bankAccountDetailsV1.ts | 2 +- .../bankAccountDetailsV1Document.ts | 4 +- .../bankAccountDetailsV2.ts | 2 +- .../bankAccountDetailsV2Bban.ts | 2 +- .../bankAccountDetailsV2Document.ts | 4 +- .../product/fr/bankAccountDetails/index.ts | 0 .../product/fr/carteGrise/carteGriseV1.ts | 2 +- .../fr/carteGrise/carteGriseV1Document.ts | 4 +- src/{ => v1}/product/fr/carteGrise/index.ts | 0 .../product/fr/energyBill/energyBillV1.ts | 2 +- .../fr/energyBill/energyBillV1Document.ts | 4 +- .../energyBill/energyBillV1EnergyConsumer.ts | 2 +- .../energyBill/energyBillV1EnergySupplier.ts | 2 +- .../fr/energyBill/energyBillV1EnergyUsage.ts | 4 +- .../fr/energyBill/energyBillV1MeterDetail.ts | 2 +- .../fr/energyBill/energyBillV1Subscription.ts | 4 +- .../energyBillV1TaxesAndContribution.ts | 4 +- src/{ => v1}/product/fr/energyBill/index.ts | 0 .../product/fr/healthCard/healthCardV1.ts | 2 +- .../fr/healthCard/healthCardV1Document.ts | 4 +- src/{ => v1}/product/fr/healthCard/index.ts | 0 src/{ => v1}/product/fr/idCard/idCardV1.ts | 2 +- .../product/fr/idCard/idCardV1Document.ts | 4 +- .../product/fr/idCard/idCardV1Page.ts | 4 +- src/{ => v1}/product/fr/idCard/idCardV2.ts | 2 +- .../product/fr/idCard/idCardV2Document.ts | 4 +- .../product/fr/idCard/idCardV2Page.ts | 4 +- src/{ => v1}/product/fr/idCard/index.ts | 0 src/{ => v1}/product/fr/index.ts | 7 ++ src/{ => v1}/product/fr/payslip/index.ts | 0 src/{ => v1}/product/fr/payslip/payslipV2.ts | 2 +- .../fr/payslip/payslipV2BankAccountDetail.ts | 2 +- .../product/fr/payslip/payslipV2Document.ts | 2 +- .../product/fr/payslip/payslipV2Employee.ts | 2 +- .../product/fr/payslip/payslipV2Employer.ts | 2 +- .../product/fr/payslip/payslipV2Employment.ts | 4 +- .../product/fr/payslip/payslipV2PayDetail.ts | 4 +- .../product/fr/payslip/payslipV2PayPeriod.ts | 2 +- .../product/fr/payslip/payslipV2Pto.ts | 4 +- .../fr/payslip/payslipV2SalaryDetail.ts | 4 +- src/{ => v1}/product/fr/payslip/payslipV3.ts | 2 +- .../fr/payslip/payslipV3BankAccountDetail.ts | 2 +- .../product/fr/payslip/payslipV3Document.ts | 2 +- .../product/fr/payslip/payslipV3Employee.ts | 2 +- .../product/fr/payslip/payslipV3Employer.ts | 2 +- .../product/fr/payslip/payslipV3Employment.ts | 2 +- .../fr/payslip/payslipV3PaidTimeOff.ts | 4 +- .../product/fr/payslip/payslipV3PayDetail.ts | 4 +- .../product/fr/payslip/payslipV3PayPeriod.ts | 2 +- .../fr/payslip/payslipV3SalaryDetail.ts | 4 +- src/{ => v1}/product/generated/generatedV1.ts | 2 +- .../product/generated/generatedV1Document.ts | 6 +- .../product/generated/generatedV1Page.ts | 6 +- .../generated/generatedV1Prediction.ts | 6 +- src/{ => v1}/product/generated/index.ts | 0 src/v1/product/ind/index.ts | 4 + .../product/ind/indianPassport/index.ts | 0 .../ind/indianPassport/indianPassportV1.ts | 2 +- .../indianPassportV1Document.ts | 4 +- src/{ => v1}/product/index.ts | 14 +++ src/{ => v1}/product/internationalId/index.ts | 0 .../internationalId/internationalIdV2.ts | 2 +- .../internationalIdV2Document.ts | 4 +- src/{ => v1}/product/invoice/index.ts | 0 src/{ => v1}/product/invoice/invoiceV4.ts | 2 +- .../product/invoice/invoiceV4Document.ts | 4 +- .../product/invoice/invoiceV4LineItem.ts | 4 +- src/{ => v1}/product/invoiceSplitter/index.ts | 0 .../invoiceSplitter/invoiceSplitterV1.ts | 2 +- .../invoiceSplitterV1Document.ts | 2 +- .../invoiceSplitterV1InvoicePageGroup.ts | 2 +- .../product/multiReceiptsDetector/index.ts | 0 .../multiReceiptsDetectorV1.ts | 2 +- .../multiReceiptsDetectorV1Document.ts | 4 +- src/{ => v1}/product/passport/index.ts | 0 src/{ => v1}/product/passport/passportV1.ts | 2 +- .../product/passport/passportV1Document.ts | 4 +- src/{ => v1}/product/receipt/index.ts | 0 src/{ => v1}/product/receipt/receiptV5.ts | 2 +- .../product/receipt/receiptV5Document.ts | 4 +- .../product/receipt/receiptV5LineItem.ts | 4 +- src/{ => v1}/product/resume/index.ts | 0 src/{ => v1}/product/resume/resumeV1.ts | 2 +- .../product/resume/resumeV1Certificate.ts | 4 +- .../product/resume/resumeV1Document.ts | 4 +- .../product/resume/resumeV1Education.ts | 4 +- .../product/resume/resumeV1Language.ts | 4 +- .../resume/resumeV1ProfessionalExperience.ts | 4 +- .../resume/resumeV1SocialNetworksUrl.ts | 4 +- .../product/us/bankCheck/bankCheckV1.ts | 2 +- .../us/bankCheck/bankCheckV1Document.ts | 4 +- .../product/us/bankCheck/bankCheckV1Page.ts | 4 +- src/{ => v1}/product/us/bankCheck/index.ts | 0 src/v1/product/us/index.ts | 6 + src/{ => v1}/product/us/usMail/index.ts | 0 src/{ => v1}/product/us/usMail/usMailV3.ts | 2 +- .../product/us/usMail/usMailV3Document.ts | 4 +- .../us/usMail/usMailV3RecipientAddress.ts | 4 +- .../us/usMail/usMailV3SenderAddress.ts | 2 +- src/{cliV2.ts => v2/cli.ts} | 12 +- src/{clientV2.ts => v2/client.ts} | 111 ++---------------- src/{input => v2/client}/dataSchema.ts | 4 +- src/v2/client/index.ts | 2 + src/v2/client/pollingOptions.ts | 89 ++++++++++++++ src/{ => v2}/http/apiSettingsV2.ts | 8 +- src/v2/http/errors.ts | 20 ++++ src/v2/http/index.ts | 2 + src/{ => v2}/http/mindeeApiV2.ts | 25 ++-- src/v2/index.ts | 15 +++ .../v2 => v2/parsing}/commonResponse.ts | 2 +- .../parsing}/dataSchemaActiveOption.ts | 2 +- src/{parsing/v2 => v2/parsing}/errorItem.ts | 2 +- .../v2 => v2/parsing}/errorResponse.ts | 2 +- .../v2 => v2/parsing}/field/baseField.ts | 2 +- .../parsing}/field/fieldConfidence.ts | 0 .../v2 => v2/parsing}/field/fieldFactory.ts | 8 +- .../v2 => v2/parsing}/field/fieldLocation.ts | 2 +- src/{parsing/v2 => v2/parsing}/field/index.ts | 0 .../parsing}/field/inferenceFields.ts | 2 +- .../v2 => v2/parsing}/field/listField.ts | 10 +- .../v2 => v2/parsing}/field/objectField.ts | 2 +- .../v2 => v2/parsing}/field/simpleField.ts | 2 +- src/{parsing/v2 => v2/parsing}/index.ts | 10 +- src/{parsing/v2 => v2/parsing}/inference.ts | 2 +- .../parsing}/inferenceActiveOptions.ts | 2 +- .../v2 => v2/parsing}/inferenceFile.ts | 2 +- .../v2 => v2/parsing}/inferenceModel.ts | 2 +- .../v2 => v2/parsing}/inferenceResponse.ts | 2 +- .../v2 => v2/parsing}/inferenceResult.ts | 2 +- src/{parsing/v2 => v2/parsing}/job.ts | 4 +- src/{parsing/v2 => v2/parsing}/jobResponse.ts | 2 +- src/{parsing/v2 => v2/parsing}/jobWebhook.ts | 2 +- src/v2/parsing/localResponse.ts | 31 +++++ src/{parsing/v2 => v2/parsing}/ragMetadata.ts | 2 +- src/{parsing/v2 => v2/parsing}/rawText.ts | 2 +- src/{parsing/v2 => v2/parsing}/rawTextPage.ts | 2 +- tests/input/sources.integration.ts | 6 +- tests/input/sources.spec.ts | 2 +- tests/input/urlInputSource.integration.ts | 4 +- tests/v1/api/asyncResponse.spec.ts | 6 +- tests/v1/api/endpoint.spec.ts | 5 +- tests/v1/api/feedbackResponse.spec.ts | 2 +- tests/v1/api/response.spec.ts | 4 +- tests/v1/clientInit.spec.ts | 2 +- .../invoiceSplitterExtractor.spec.ts | 4 +- .../invoiceSplitterReconstruction.spec.ts | 6 +- .../multiReceiptsExtractor.spec.ts | 4 +- ...multiReceiptsReconstruction.integration.ts | 8 +- .../multiReceiptsReconstruction.spec.ts | 7 +- tests/v1/extras/extras.integration.ts | 12 +- tests/v1/extras/fullTextOcr.spec.ts | 4 +- tests/v1/extras/ocr.spec.ts | 4 +- tests/v1/input/localResponse.spec.ts | 13 +- tests/v1/parsing/standard/amount.spec.ts | 2 +- .../parsing/standard/classification.spec.ts | 2 +- tests/v1/parsing/standard/date.spec.ts | 2 +- tests/v1/parsing/standard/field.spec.ts | 2 +- tests/v1/parsing/standard/locale.spec.ts | 2 +- tests/v1/parsing/standard/orientation.spec.ts | 2 +- .../parsing/standard/paymentDetails.spec.ts | 2 +- tests/v1/parsing/standard/position.spec.ts | 2 +- tests/v1/parsing/standard/tax.spec.ts | 2 +- tests/v1/parsing/standard/text.spec.ts | 2 +- .../barcodeReader/barcodeReaderV1.spec.ts | 4 +- tests/v1/product/cropper/cropperV1.spec.ts | 6 +- .../driverLicense/driverLicenseV1.spec.ts | 4 +- .../financialDocumentV1.spec.ts | 10 +- .../bankAccountDetailsV1.spec.ts | 5 +- .../bankAccountDetailsV2.spec.ts | 4 +- .../fr/carteGrise/carteGriseV1.spec.ts | 4 +- .../fr/energyBill/energyBillV1.spec.ts | 4 +- .../fr/healthCard/healthCardV1.spec.ts | 4 +- tests/v1/product/fr/idCard/idCardV1.spec.ts | 6 +- tests/v1/product/fr/idCard/idCardV2.spec.ts | 6 +- tests/v1/product/fr/payslip/payslipV2.spec.ts | 4 +- tests/v1/product/fr/payslip/payslipV3.spec.ts | 4 +- .../product/generated/generatedList.spec.ts | 2 +- .../product/generated/generatedObject.spec.ts | 2 +- .../v1/product/generated/generatedV1.spec.ts | 18 +-- .../indianPassport/indianPassportV1.spec.ts | 4 +- .../internationalId/internationalIdV2.spec.ts | 4 +- tests/v1/product/invoice/invoiceV4.spec.ts | 4 +- .../invoiceSplitter.integration.ts | 14 +-- .../invoiceSplitter/invoiceSplitterV1.spec.ts | 4 +- .../multiReceiptsDetectorV1.spec.ts | 4 +- tests/v1/product/passport/passportV1.spec.ts | 4 +- tests/v1/product/receipt/receiptV5.spec.ts | 4 +- tests/v1/product/resume/resumeV1.spec.ts | 4 +- .../product/us/bankCheck/bankCheckV1.spec.ts | 6 +- tests/v1/product/us/usMail/usMailV3.spec.ts | 4 +- tests/v1/workflows/workflow.integration.ts | 12 +- tests/v1/workflows/workflow.spec.ts | 3 +- ...2.integration.ts => client.integration.ts} | 12 +- tests/v2/{clientV2.spec.ts => client.spec.ts} | 9 +- tests/v2/input/inferenceParameter.spec.ts | 4 +- tests/v2/input/localResponse.spec.ts | 2 +- tests/v2/parsing/inference.spec.ts | 4 +- tests/v2/parsing/job.spec.ts | 3 +- 341 files changed, 958 insertions(+), 820 deletions(-) rename src/{imageOperations/common => image}/extractedImage.ts (96%) rename src/{imageOperations => image}/imageCompressor.ts (100%) rename src/{imageOperations/common => image}/imageExtractor.ts (100%) rename src/{imageOperations/common => image}/index.ts (66%) rename src/input/{sources => }/base64Input.ts (100%) rename src/input/{sources => }/bufferInput.ts (100%) rename src/input/{sources => }/bytesInput.ts (100%) rename src/input/{sources => }/inputSource.ts (100%) rename src/input/{sources => }/localInputSource.ts (98%) rename src/input/{sources => }/pathInput.ts (100%) delete mode 100644 src/input/sources/index.ts rename src/input/{sources => }/streamInput.ts (100%) rename src/input/{sources => }/urlInput.ts (100%) rename src/parsing/{common => }/dateParser.ts (100%) rename src/{input/localResponse.ts => parsing/localResponseBase.ts} (73%) rename src/parsing/{common => }/stringDict.ts (100%) delete mode 100644 src/product/fr/internal.ts delete mode 100644 src/product/ind/index.ts delete mode 100644 src/product/ind/internal.ts delete mode 100644 src/product/internal.ts delete mode 100644 src/product/us/index.ts delete mode 100644 src/product/us/internal.ts rename src/{cliV1.ts => v1/cli.ts} (95%) rename src/{ => v1}/client.ts (90%) rename src/{imageOperations => v1/extraction}/index.ts (65%) rename src/{imageOperations => v1/extraction}/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts (83%) rename src/{imageOperations => v1/extraction}/invoiceSplitterExtractor/index.ts (100%) rename src/{imageOperations => v1/extraction}/invoiceSplitterExtractor/invoiceSplitterExtractor.ts (98%) rename src/{imageOperations => v1/extraction}/multiReceiptsExtractor/extractedMultiReceiptImage.ts (83%) rename src/{imageOperations => v1/extraction}/multiReceiptsExtractor/index.ts (100%) rename src/{imageOperations => v1/extraction}/multiReceiptsExtractor/multiReceiptsExtractor.ts (94%) rename src/{http/apiSettings.ts => v1/http/apiSettingsV1.ts} (81%) rename src/{ => v1}/http/endpoint.ts (88%) rename src/{http/error.ts => v1/http/errors.ts} (88%) rename src/{ => v1}/http/httpParams.ts (86%) create mode 100644 src/v1/http/index.ts rename src/{ => v1}/http/responseValidation.ts (90%) rename src/{ => v1}/http/workflowEndpoint.ts (85%) create mode 100644 src/v1/index.ts rename src/{ => v1}/parsing/common/apiRequest.ts (92%) rename src/{ => v1}/parsing/common/apiResponse.ts (92%) rename src/{ => v1}/parsing/common/asyncPredictResponse.ts (97%) rename src/{ => v1}/parsing/common/document.ts (98%) rename src/{ => v1}/parsing/common/execution.ts (91%) rename src/{ => v1}/parsing/common/executionFile.ts (84%) rename src/{ => v1}/parsing/common/executionPriority.ts (100%) rename src/{ => v1}/parsing/common/extras/cropperExtra.ts (85%) rename src/{ => v1}/parsing/common/extras/extras.ts (100%) rename src/{ => v1}/parsing/common/extras/fullTextOcrExtra.ts (89%) rename src/{ => v1}/parsing/common/extras/index.ts (100%) rename src/{ => v1}/parsing/common/extras/ragExtra.ts (86%) rename src/{ => v1}/parsing/common/feedback/feedbackResponse.ts (88%) rename src/{ => v1}/parsing/common/index.ts (85%) rename src/{ => v1}/parsing/common/inference.ts (96%) rename src/{ => v1}/parsing/common/mvisionV1.ts (80%) rename src/{ => v1}/parsing/common/ocr.ts (84%) rename src/{ => v1}/parsing/common/ocrPage.ts (95%) rename src/{ => v1}/parsing/common/orientation.ts (91%) rename src/{ => v1}/parsing/common/page.ts (98%) rename src/{ => v1}/parsing/common/predictResponse.ts (92%) rename src/{ => v1}/parsing/common/prediction.ts (100%) rename src/{ => v1}/parsing/common/product.ts (100%) rename src/{ => v1}/parsing/common/summaryHelper.ts (100%) rename src/{ => v1}/parsing/common/workflowResponse.ts (91%) rename src/{ => v1}/parsing/generated/generatedList.ts (93%) rename src/{ => v1}/parsing/generated/generatedObject.ts (96%) rename src/{ => v1}/parsing/generated/index.ts (100%) create mode 100644 src/v1/parsing/index.ts create mode 100644 src/v1/parsing/localResponse.ts rename src/{ => v1}/parsing/standard/addressField.ts (100%) rename src/{ => v1}/parsing/standard/amount.ts (93%) rename src/{ => v1}/parsing/standard/base.ts (97%) rename src/{ => v1}/parsing/standard/boolean.ts (91%) rename src/{ => v1}/parsing/standard/classification.ts (100%) rename src/{ => v1}/parsing/standard/companyRegistration.ts (94%) rename src/{ => v1}/parsing/standard/date.ts (100%) rename src/{ => v1}/parsing/standard/field.ts (100%) rename src/{ => v1}/parsing/standard/index.ts (100%) rename src/{ => v1}/parsing/standard/locale.ts (100%) rename src/{ => v1}/parsing/standard/paymentDetails.ts (98%) rename src/{ => v1}/parsing/standard/position.ts (96%) rename src/{ => v1}/parsing/standard/tax.ts (98%) rename src/{ => v1}/parsing/standard/text.ts (91%) rename src/{ => v1}/parsing/standard/word.ts (100%) rename src/{ => v1}/product/barcodeReader/barcodeReaderV1.ts (92%) rename src/{ => v1}/product/barcodeReader/barcodeReaderV1Document.ts (92%) rename src/{ => v1}/product/barcodeReader/index.ts (100%) rename src/{ => v1/product}/cliProducts.ts (97%) rename src/{ => v1}/product/cropper/cropperV1.ts (92%) rename src/{ => v1}/product/cropper/cropperV1Document.ts (77%) rename src/{ => v1}/product/cropper/cropperV1Page.ts (84%) rename src/{ => v1}/product/cropper/index.ts (100%) rename src/{ => v1}/product/driverLicense/driverLicenseV1.ts (92%) rename src/{ => v1}/product/driverLicense/driverLicenseV1Document.ts (96%) rename src/{ => v1}/product/driverLicense/index.ts (100%) rename src/{ => v1}/product/financialDocument/financialDocumentV1.ts (93%) rename src/{ => v1}/product/financialDocument/financialDocumentV1Document.ts (99%) rename src/{ => v1}/product/financialDocument/financialDocumentV1LineItem.ts (97%) rename src/{ => v1}/product/financialDocument/index.ts (100%) rename src/{ => v1}/product/fr/bankAccountDetails/bankAccountDetailsV1.ts (93%) rename src/{ => v1}/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts (91%) rename src/{ => v1}/product/fr/bankAccountDetails/bankAccountDetailsV2.ts (93%) rename src/{ => v1}/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts (97%) rename src/{ => v1}/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts (93%) rename src/{ => v1}/product/fr/bankAccountDetails/index.ts (100%) rename src/{ => v1}/product/fr/carteGrise/carteGriseV1.ts (92%) rename src/{ => v1}/product/fr/carteGrise/carteGriseV1Document.ts (98%) rename src/{ => v1}/product/fr/carteGrise/index.ts (100%) rename src/{ => v1}/product/fr/energyBill/energyBillV1.ts (92%) rename src/{ => v1}/product/fr/energyBill/energyBillV1Document.ts (98%) rename src/{ => v1}/product/fr/energyBill/energyBillV1EnergyConsumer.ts (96%) rename src/{ => v1}/product/fr/energyBill/energyBillV1EnergySupplier.ts (96%) rename src/{ => v1}/product/fr/energyBill/energyBillV1EnergyUsage.ts (97%) rename src/{ => v1}/product/fr/energyBill/energyBillV1MeterDetail.ts (96%) rename src/{ => v1}/product/fr/energyBill/energyBillV1Subscription.ts (96%) rename src/{ => v1}/product/fr/energyBill/energyBillV1TaxesAndContribution.ts (96%) rename src/{ => v1}/product/fr/energyBill/index.ts (100%) rename src/{ => v1}/product/fr/healthCard/healthCardV1.ts (92%) rename src/{ => v1}/product/fr/healthCard/healthCardV1Document.ts (93%) rename src/{ => v1}/product/fr/healthCard/index.ts (100%) rename src/{ => v1}/product/fr/idCard/idCardV1.ts (92%) rename src/{ => v1}/product/fr/idCard/idCardV1Document.ts (96%) rename src/{ => v1}/product/fr/idCard/idCardV1Page.ts (81%) rename src/{ => v1}/product/fr/idCard/idCardV2.ts (92%) rename src/{ => v1}/product/fr/idCard/idCardV2Document.ts (97%) rename src/{ => v1}/product/fr/idCard/idCardV2Page.ts (85%) rename src/{ => v1}/product/fr/idCard/index.ts (100%) rename src/{ => v1}/product/fr/index.ts (58%) rename src/{ => v1}/product/fr/payslip/index.ts (100%) rename src/{ => v1}/product/fr/payslip/payslipV2.ts (92%) rename src/{ => v1}/product/fr/payslip/payslipV2BankAccountDetail.ts (96%) rename src/{ => v1}/product/fr/payslip/payslipV2Document.ts (98%) rename src/{ => v1}/product/fr/payslip/payslipV2Employee.ts (98%) rename src/{ => v1}/product/fr/payslip/payslipV2Employer.ts (97%) rename src/{ => v1}/product/fr/payslip/payslipV2Employment.ts (96%) rename src/{ => v1}/product/fr/payslip/payslipV2PayDetail.ts (98%) rename src/{ => v1}/product/fr/payslip/payslipV2PayPeriod.ts (97%) rename src/{ => v1}/product/fr/payslip/payslipV2Pto.ts (96%) rename src/{ => v1}/product/fr/payslip/payslipV2SalaryDetail.ts (95%) rename src/{ => v1}/product/fr/payslip/payslipV3.ts (92%) rename src/{ => v1}/product/fr/payslip/payslipV3BankAccountDetail.ts (96%) rename src/{ => v1}/product/fr/payslip/payslipV3Document.ts (99%) rename src/{ => v1}/product/fr/payslip/payslipV3Employee.ts (98%) rename src/{ => v1}/product/fr/payslip/payslipV3Employer.ts (97%) rename src/{ => v1}/product/fr/payslip/payslipV3Employment.ts (98%) rename src/{ => v1}/product/fr/payslip/payslipV3PaidTimeOff.ts (96%) rename src/{ => v1}/product/fr/payslip/payslipV3PayDetail.ts (98%) rename src/{ => v1}/product/fr/payslip/payslipV3PayPeriod.ts (97%) rename src/{ => v1}/product/fr/payslip/payslipV3SalaryDetail.ts (96%) rename src/{ => v1}/product/generated/generatedV1.ts (92%) rename src/{ => v1}/product/generated/generatedV1Document.ts (86%) rename src/{ => v1}/product/generated/generatedV1Page.ts (87%) rename src/{ => v1}/product/generated/generatedV1Prediction.ts (91%) rename src/{ => v1}/product/generated/index.ts (100%) create mode 100644 src/v1/product/ind/index.ts rename src/{ => v1}/product/ind/indianPassport/index.ts (100%) rename src/{ => v1}/product/ind/indianPassport/indianPassportV1.ts (92%) rename src/{ => v1}/product/ind/indianPassport/indianPassportV1Document.ts (98%) rename src/{ => v1}/product/index.ts (51%) rename src/{ => v1}/product/internationalId/index.ts (100%) rename src/{ => v1}/product/internationalId/internationalIdV2.ts (93%) rename src/{ => v1}/product/internationalId/internationalIdV2Document.ts (98%) rename src/{ => v1}/product/invoice/index.ts (100%) rename src/{ => v1}/product/invoice/invoiceV4.ts (92%) rename src/{ => v1}/product/invoice/invoiceV4Document.ts (99%) rename src/{ => v1}/product/invoice/invoiceV4LineItem.ts (97%) rename src/{ => v1}/product/invoiceSplitter/index.ts (100%) rename src/{ => v1}/product/invoiceSplitter/invoiceSplitterV1.ts (93%) rename src/{ => v1}/product/invoiceSplitter/invoiceSplitterV1Document.ts (97%) rename src/{ => v1}/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts (96%) rename src/{ => v1}/product/multiReceiptsDetector/index.ts (100%) rename src/{ => v1}/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts (93%) rename src/{ => v1}/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts (89%) rename src/{ => v1}/product/passport/index.ts (100%) rename src/{ => v1}/product/passport/passportV1.ts (92%) rename src/{ => v1}/product/passport/passportV1Document.ts (96%) rename src/{ => v1}/product/receipt/index.ts (100%) rename src/{ => v1}/product/receipt/receiptV5.ts (92%) rename src/{ => v1}/product/receipt/receiptV5Document.ts (98%) rename src/{ => v1}/product/receipt/receiptV5LineItem.ts (95%) rename src/{ => v1}/product/resume/index.ts (100%) rename src/{ => v1}/product/resume/resumeV1.ts (92%) rename src/{ => v1}/product/resume/resumeV1Certificate.ts (95%) rename src/{ => v1}/product/resume/resumeV1Document.ts (98%) rename src/{ => v1}/product/resume/resumeV1Education.ts (97%) rename src/{ => v1}/product/resume/resumeV1Language.ts (93%) rename src/{ => v1}/product/resume/resumeV1ProfessionalExperience.ts (97%) rename src/{ => v1}/product/resume/resumeV1SocialNetworksUrl.ts (93%) rename src/{ => v1}/product/us/bankCheck/bankCheckV1.ts (93%) rename src/{ => v1}/product/us/bankCheck/bankCheckV1Document.ts (96%) rename src/{ => v1}/product/us/bankCheck/bankCheckV1Page.ts (89%) rename src/{ => v1}/product/us/bankCheck/index.ts (100%) create mode 100644 src/v1/product/us/index.ts rename src/{ => v1}/product/us/usMail/index.ts (100%) rename src/{ => v1}/product/us/usMail/usMailV3.ts (92%) rename src/{ => v1}/product/us/usMail/usMailV3Document.ts (96%) rename src/{ => v1}/product/us/usMail/usMailV3RecipientAddress.ts (97%) rename src/{ => v1}/product/us/usMail/usMailV3SenderAddress.ts (97%) rename src/{cliV2.ts => v2/cli.ts} (87%) rename src/{clientV2.ts => v2/client.ts} (69%) rename src/{input => v2/client}/dataSchema.ts (97%) create mode 100644 src/v2/client/index.ts create mode 100644 src/v2/client/pollingOptions.ts rename src/{ => v2}/http/apiSettingsV2.ts (84%) create mode 100644 src/v2/http/errors.ts create mode 100644 src/v2/http/index.ts rename src/{ => v2}/http/mindeeApiV2.ts (87%) create mode 100644 src/v2/index.ts rename src/{parsing/v2 => v2/parsing}/commonResponse.ts (88%) rename src/{parsing/v2 => v2/parsing}/dataSchemaActiveOption.ts (86%) rename src/{parsing/v2 => v2/parsing}/errorItem.ts (89%) rename src/{parsing/v2 => v2/parsing}/errorResponse.ts (95%) rename src/{parsing/v2 => v2/parsing}/field/baseField.ts (92%) rename src/{parsing/v2 => v2/parsing}/field/fieldConfidence.ts (100%) rename src/{parsing/v2 => v2/parsing}/field/fieldFactory.ts (79%) rename src/{parsing/v2 => v2/parsing}/field/fieldLocation.ts (89%) rename src/{parsing/v2 => v2/parsing}/field/index.ts (100%) rename src/{parsing/v2 => v2/parsing}/field/inferenceFields.ts (97%) rename src/{parsing/v2 => v2/parsing}/field/listField.ts (88%) rename src/{parsing/v2 => v2/parsing}/field/objectField.ts (94%) rename src/{parsing/v2 => v2/parsing}/field/simpleField.ts (96%) rename src/{parsing/v2 => v2/parsing}/index.ts (100%) rename src/{parsing/v2 => v2/parsing}/inference.ts (95%) rename src/{parsing/v2 => v2/parsing}/inferenceActiveOptions.ts (95%) rename src/{parsing/v2 => v2/parsing}/inferenceFile.ts (92%) rename src/{parsing/v2 => v2/parsing}/inferenceModel.ts (81%) rename src/{parsing/v2 => v2/parsing}/inferenceResponse.ts (85%) rename src/{parsing/v2 => v2/parsing}/inferenceResult.ts (92%) rename src/{parsing/v2 => v2/parsing}/job.ts (93%) rename src/{parsing/v2 => v2/parsing}/jobResponse.ts (83%) rename src/{parsing/v2 => v2/parsing}/jobWebhook.ts (90%) create mode 100644 src/v2/parsing/localResponse.ts rename src/{parsing/v2 => v2/parsing}/ragMetadata.ts (81%) rename src/{parsing/v2 => v2/parsing}/rawText.ts (88%) rename src/{parsing/v2 => v2/parsing}/rawTextPage.ts (81%) rename tests/v1/{imageOperations => extraction}/invoiceSplitterExtractor.spec.ts (92%) rename tests/v1/{imageOperations => extraction}/invoiceSplitterReconstruction.spec.ts (92%) rename tests/v1/{imageOperations => extraction}/multiReceiptsExtractor.spec.ts (95%) rename tests/v1/{imageOperations => extraction}/multiReceiptsReconstruction.integration.ts (96%) rename tests/v1/{imageOperations => extraction}/multiReceiptsReconstruction.spec.ts (93%) rename tests/v2/{clientV2.integration.ts => client.integration.ts} (96%) rename tests/v2/{clientV2.spec.ts => client.spec.ts} (94%) diff --git a/bin/mindeeV1.ts b/bin/mindeeV1.ts index 8f46f652..12fa8168 100755 --- a/bin/mindeeV1.ts +++ b/bin/mindeeV1.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { cliV1 } from "@/cliV1.js"; +import { cli } from "@/v1/cli.js"; -cliV1(); +cli(); diff --git a/bin/mindeeV2.ts b/bin/mindeeV2.ts index 0040c7d7..ad38cd00 100755 --- a/bin/mindeeV2.ts +++ b/bin/mindeeV2.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { cliV2 } from "@/cliV2.js"; +import { cli } from "@/v2/cli.js"; -cliV2(); +cli(); diff --git a/docs/code_samples/bank_account_details_v1.txt b/docs/code_samples/bank_account_details_v1.txt index 2074b2d2..a5edf36a 100644 --- a/docs/code_samples/bank_account_details_v1.txt +++ b/docs/code_samples/bank_account_details_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.fr.BankAccountDetailsV1, + mindee.v1.product.fr.BankAccountDetailsV1, inputSource ); diff --git a/docs/code_samples/bank_account_details_v2.txt b/docs/code_samples/bank_account_details_v2.txt index e1226a7f..43f3f232 100644 --- a/docs/code_samples/bank_account_details_v2.txt +++ b/docs/code_samples/bank_account_details_v2.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.fr.BankAccountDetailsV2, + mindee.v1.product.fr.BankAccountDetailsV2, inputSource ); diff --git a/docs/code_samples/bank_check_v1.txt b/docs/code_samples/bank_check_v1.txt index c10957cb..76c8d74f 100644 --- a/docs/code_samples/bank_check_v1.txt +++ b/docs/code_samples/bank_check_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.us.BankCheckV1, + mindee.v1.product.us.BankCheckV1, inputSource ); diff --git a/docs/code_samples/barcode_reader_v1.txt b/docs/code_samples/barcode_reader_v1.txt index 7368e1c4..afea500f 100644 --- a/docs/code_samples/barcode_reader_v1.txt +++ b/docs/code_samples/barcode_reader_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.BarcodeReaderV1, + mindee.v1.product.BarcodeReaderV1, inputSource ); diff --git a/docs/code_samples/carte_grise_v1.txt b/docs/code_samples/carte_grise_v1.txt index f597c727..38b8d04d 100644 --- a/docs/code_samples/carte_grise_v1.txt +++ b/docs/code_samples/carte_grise_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.fr.CarteGriseV1, + mindee.v1.product.fr.CarteGriseV1, inputSource ); diff --git a/docs/code_samples/cropper_v1.txt b/docs/code_samples/cropper_v1.txt index 12afcf3e..e7513d2b 100644 --- a/docs/code_samples/cropper_v1.txt +++ b/docs/code_samples/cropper_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.CropperV1, + mindee.v1.product.CropperV1, inputSource ); diff --git a/docs/code_samples/default.txt b/docs/code_samples/default.txt index 96b93842..875363d6 100644 --- a/docs/code_samples/default.txt +++ b/docs/code_samples/default.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -20,7 +22,7 @@ const customEndpoint = mindeeClient.createEndpoint( // Parse the file. const apiResponse = mindeeClient .parse( - mindee.product.GeneratedV1, + mindee.v1.product.GeneratedV1, inputSource, { endpoint: customEndpoint } ); diff --git a/docs/code_samples/default_async.txt b/docs/code_samples/default_async.txt index 232c51a3..f4260c2f 100644 --- a/docs/code_samples/default_async.txt +++ b/docs/code_samples/default_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -19,7 +21,7 @@ const customEndpoint = mindeeClient.createEndpoint( // Parse the file asynchronously. const asyncApiResponse = mindeeClient.enqueueAndParse( - mindee.product.GeneratedV1, + mindee.v1.product.GeneratedV1, inputSource, { endpoint: customEndpoint } ); diff --git a/docs/code_samples/default_v2.txt b/docs/code_samples/default_v2.txt index 4f43d600..bf95a030 100644 --- a/docs/code_samples/default_v2.txt +++ b/docs/code_samples/default_v2.txt @@ -7,7 +7,9 @@ const filePath = "/path/to/the/file.ext"; const modelId = "MY_MODEL_ID"; // Init a new client -const mindeeClient = new mindee.ClientV2({ apiKey: apiKey }); +const mindeeClient = new mindee.Client( + { apiKey: apiKey } +); // Set inference parameters const inferenceParams = { diff --git a/docs/code_samples/driver_license_v1_async.txt b/docs/code_samples/driver_license_v1_async.txt index 2c081f3c..c2e4c1b2 100644 --- a/docs/code_samples/driver_license_v1_async.txt +++ b/docs/code_samples/driver_license_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.DriverLicenseV1, + mindee.v1.product.DriverLicenseV1, inputSource ); diff --git a/docs/code_samples/energy_bill_fra_v1_async.txt b/docs/code_samples/energy_bill_fra_v1_async.txt index 8d5ba1f5..fb52aac3 100644 --- a/docs/code_samples/energy_bill_fra_v1_async.txt +++ b/docs/code_samples/energy_bill_fra_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.fr.EnergyBillV1, + mindee.v1.product.fr.EnergyBillV1, inputSource ); diff --git a/docs/code_samples/expense_receipts_v5.txt b/docs/code_samples/expense_receipts_v5.txt index bacb0b85..502cad69 100644 --- a/docs/code_samples/expense_receipts_v5.txt +++ b/docs/code_samples/expense_receipts_v5.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.ReceiptV5, + mindee.v1.product.ReceiptV5, inputSource ); diff --git a/docs/code_samples/expense_receipts_v5_async.txt b/docs/code_samples/expense_receipts_v5_async.txt index ec4162d8..6f8f0d7d 100644 --- a/docs/code_samples/expense_receipts_v5_async.txt +++ b/docs/code_samples/expense_receipts_v5_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.ReceiptV5, + mindee.v1.product.ReceiptV5, inputSource ); diff --git a/docs/code_samples/financial_document_v1.txt b/docs/code_samples/financial_document_v1.txt index 065e0bca..9e2a1ce3 100644 --- a/docs/code_samples/financial_document_v1.txt +++ b/docs/code_samples/financial_document_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.FinancialDocumentV1, + mindee.v1.product.FinancialDocumentV1, inputSource ); diff --git a/docs/code_samples/financial_document_v1_async.txt b/docs/code_samples/financial_document_v1_async.txt index e856278e..e5063cf8 100644 --- a/docs/code_samples/financial_document_v1_async.txt +++ b/docs/code_samples/financial_document_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.FinancialDocumentV1, + mindee.v1.product.FinancialDocumentV1, inputSource ); diff --git a/docs/code_samples/french_healthcard_v1_async.txt b/docs/code_samples/french_healthcard_v1_async.txt index c8d16616..2433d2c0 100644 --- a/docs/code_samples/french_healthcard_v1_async.txt +++ b/docs/code_samples/french_healthcard_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.fr.HealthCardV1, + mindee.v1.product.fr.HealthCardV1, inputSource ); diff --git a/docs/code_samples/idcard_fr_v1.txt b/docs/code_samples/idcard_fr_v1.txt index 07a0973f..be7f748b 100644 --- a/docs/code_samples/idcard_fr_v1.txt +++ b/docs/code_samples/idcard_fr_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.fr.IdCardV1, + mindee.v1.product.fr.IdCardV1, inputSource ); diff --git a/docs/code_samples/idcard_fr_v2.txt b/docs/code_samples/idcard_fr_v2.txt index 07db4803..d4e4d001 100644 --- a/docs/code_samples/idcard_fr_v2.txt +++ b/docs/code_samples/idcard_fr_v2.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.fr.IdCardV2, + mindee.v1.product.fr.IdCardV2, inputSource ); diff --git a/docs/code_samples/ind_passport_v1_async.txt b/docs/code_samples/ind_passport_v1_async.txt index 5daa5913..b8647a39 100644 --- a/docs/code_samples/ind_passport_v1_async.txt +++ b/docs/code_samples/ind_passport_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.ind.IndianPassportV1, + mindee.v1.product.ind.IndianPassportV1, inputSource ); diff --git a/docs/code_samples/international_id_v2_async.txt b/docs/code_samples/international_id_v2_async.txt index 107261dc..3765f8eb 100644 --- a/docs/code_samples/international_id_v2_async.txt +++ b/docs/code_samples/international_id_v2_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.InternationalIdV2, + mindee.v1.product.InternationalIdV2, inputSource ); diff --git a/docs/code_samples/invoice_splitter_v1_async.txt b/docs/code_samples/invoice_splitter_v1_async.txt index 81c9a5af..451b6c1f 100644 --- a/docs/code_samples/invoice_splitter_v1_async.txt +++ b/docs/code_samples/invoice_splitter_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.InvoiceSplitterV1, + mindee.v1.product.InvoiceSplitterV1, inputSource ); diff --git a/docs/code_samples/invoices_v4.txt b/docs/code_samples/invoices_v4.txt index cc80b368..c48565b6 100644 --- a/docs/code_samples/invoices_v4.txt +++ b/docs/code_samples/invoices_v4.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.InvoiceV4, + mindee.v1.product.InvoiceV4, inputSource ); diff --git a/docs/code_samples/invoices_v4_async.txt b/docs/code_samples/invoices_v4_async.txt index 85e4cc93..f11ed961 100644 --- a/docs/code_samples/invoices_v4_async.txt +++ b/docs/code_samples/invoices_v4_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.InvoiceV4, + mindee.v1.product.InvoiceV4, inputSource ); diff --git a/docs/code_samples/multi_receipts_detector_v1.txt b/docs/code_samples/multi_receipts_detector_v1.txt index 0c89b623..f17555ca 100644 --- a/docs/code_samples/multi_receipts_detector_v1.txt +++ b/docs/code_samples/multi_receipts_detector_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.MultiReceiptsDetectorV1, + mindee.v1.product.MultiReceiptsDetectorV1, inputSource ); diff --git a/docs/code_samples/passport_v1.txt b/docs/code_samples/passport_v1.txt index 5fd1b9d2..c60f4ff9 100644 --- a/docs/code_samples/passport_v1.txt +++ b/docs/code_samples/passport_v1.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.parse( - mindee.product.PassportV1, + mindee.v1.product.PassportV1, inputSource ); diff --git a/docs/code_samples/payslip_fra_v2_async.txt b/docs/code_samples/payslip_fra_v2_async.txt index 8a053cd5..4db98d32 100644 --- a/docs/code_samples/payslip_fra_v2_async.txt +++ b/docs/code_samples/payslip_fra_v2_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.fr.PayslipV2, + mindee.v1.product.fr.PayslipV2, inputSource ); diff --git a/docs/code_samples/payslip_fra_v3_async.txt b/docs/code_samples/payslip_fra_v3_async.txt index 8ac5f253..5f57040a 100644 --- a/docs/code_samples/payslip_fra_v3_async.txt +++ b/docs/code_samples/payslip_fra_v3_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.fr.PayslipV3, + mindee.v1.product.fr.PayslipV3, inputSource ); diff --git a/docs/code_samples/resume_v1_async.txt b/docs/code_samples/resume_v1_async.txt index 20f699b0..f760cc57 100644 --- a/docs/code_samples/resume_v1_async.txt +++ b/docs/code_samples/resume_v1_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.ResumeV1, + mindee.v1.product.ResumeV1, inputSource ); diff --git a/docs/code_samples/us_mail_v3_async.txt b/docs/code_samples/us_mail_v3_async.txt index 5938069a..f9881a89 100644 --- a/docs/code_samples/us_mail_v3_async.txt +++ b/docs/code_samples/us_mail_v3_async.txt @@ -3,7 +3,9 @@ const mindee = require("mindee"); // import * as mindee from "mindee"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -12,7 +14,7 @@ const inputSource = new mindee.PathInput( // Parse the file const apiResponse = mindeeClient.enqueueAndParse( - mindee.product.us.UsMailV3, + mindee.v1.product.us.UsMailV3, inputSource ); diff --git a/docs/code_samples/workflow_execution.txt b/docs/code_samples/workflow_execution.txt index 8ee38248..7ab2f67d 100644 --- a/docs/code_samples/workflow_execution.txt +++ b/docs/code_samples/workflow_execution.txt @@ -5,7 +5,9 @@ const mindee = require("mindee"); const workflowId: string = "workflow-id"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( diff --git a/docs/code_samples/workflow_ots_rag.txt b/docs/code_samples/workflow_ots_rag.txt index ad50a07a..0cc72d3e 100644 --- a/docs/code_samples/workflow_ots_rag.txt +++ b/docs/code_samples/workflow_ots_rag.txt @@ -5,7 +5,9 @@ const mindee = require("mindee"); const workflowId: string = "workflow-id"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -20,7 +22,7 @@ const workflowParams = { // Parse the file asynchronously on a workflow queue const asyncApiResponse = mindeeClient.enqueueAndParse( - mindee.product.FinancialDocumentV1, + mindee.v1.product.FinancialDocumentV1, inputSource, workflowParams ); diff --git a/docs/code_samples/workflow_polling.txt b/docs/code_samples/workflow_polling.txt index eba9a306..9d6cf2c0 100644 --- a/docs/code_samples/workflow_polling.txt +++ b/docs/code_samples/workflow_polling.txt @@ -5,7 +5,9 @@ const mindee = require("mindee"); const workflowId: string = "workflow-id"; // Init a new client -const mindeeClient = new mindee.Client({ apiKey: "my-api-key" }); +const mindeeClient = new mindee.v1.Client( + { apiKey: "my-api-key" } +); // Load a file from disk const inputSource = new mindee.PathInput( @@ -27,7 +29,7 @@ const workflowParams = { // Parse the file asynchronously on a workflow queue const asyncApiResponse = mindeeClient.enqueueAndParse( - mindee.product.GeneratedV1, + mindee.v1.product.GeneratedV1, inputSource, workflowParams ); diff --git a/src/errors/index.ts b/src/errors/index.ts index e773bbb8..5789ab53 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -1,5 +1,8 @@ export { MindeeError, - MindeeMimeTypeError, MindeeImageError, MindeePdfError, - MindeeHttpErrorV2, MindeeApiV2Error, + MindeeMimeTypeError, + MindeeImageError, + MindeePdfError, + MindeeDeserializationError, + MindeeConfigurationError, } from "./mindeeError.js"; diff --git a/src/errors/mindeeError.ts b/src/errors/mindeeError.ts index 462f5c8f..0274f8b3 100644 --- a/src/errors/mindeeError.ts +++ b/src/errors/mindeeError.ts @@ -1,5 +1,3 @@ -import { ErrorDetails, ErrorResponse, ErrorItem } from "@/parsing/v2/index.js"; - /** * Main Mindee Error custom class. */ @@ -20,7 +18,6 @@ export class MindeeMimeTypeError extends MindeeError { } } - export class MindeeImageError extends MindeeError { constructor(message: string) { super(message); @@ -28,34 +25,23 @@ export class MindeeImageError extends MindeeError { } } -export class MindeePdfError extends MindeeError { +export class MindeeDeserializationError extends MindeeError { constructor(message: string) { super(message); - this.name = "MindeePdfError"; + this.name = "MindeeDeserializationError"; } } -export class MindeeApiV2Error extends MindeeError { +export class MindeeConfigurationError extends MindeeError { constructor(message: string) { super(message); - this.name = "MindeeApiV2Error"; + this.name = "MindeeConfigurationError"; } } -export class MindeeHttpErrorV2 extends MindeeError implements ErrorDetails { - public status: number; - public detail: string; - public title: string; - public code: string; - public errors: ErrorItem[]; - - constructor(error: ErrorResponse) { - super(`HTTP ${error.status} - ${error.title} :: ${error.code} - ${error.detail}`); - this.status = error.status; - this.detail = error.detail; - this.title = error.title; - this.code = error.code; - this.errors = error.errors; - this.name = "MindeeHttpErrorV2"; +export class MindeePdfError extends MindeeError { + constructor(message: string) { + super(message); + this.name = "MindeePdfError"; } } diff --git a/src/http/apiCore.ts b/src/http/apiCore.ts index b74a408e..995e1f1d 100644 --- a/src/http/apiCore.ts +++ b/src/http/apiCore.ts @@ -13,7 +13,7 @@ export interface RequestOptions { body?: any; } -export interface EndpointResponse { +export interface BaseHttpResponse { messageObj: any; data: { [key: string]: any }; } @@ -38,7 +38,7 @@ export async function cutDocPages(inputDoc: InputSource, pageOptions: PageOption export async function sendRequestAndReadResponse( dispatcher: Dispatcher, options: RequestOptions, -): Promise { +): Promise { const url: string = `https://${options.hostname}${options.path}`; logger.debug(`${options.method}: ${url}`); diff --git a/src/http/index.ts b/src/http/index.ts index 275d6615..d740b785 100644 --- a/src/http/index.ts +++ b/src/http/index.ts @@ -1,24 +1,7 @@ -export { Endpoint } from "./endpoint.js"; -export type { EndpointResponse } from "./apiCore.js"; -export { - STANDARD_API_OWNER, - ApiSettings, -} from "./apiSettings.js"; -export { - MindeeHttpError, - MindeeHttp400Error, - MindeeHttp401Error, - MindeeHttp403Error, - MindeeHttp404Error, - MindeeHttp413Error, - MindeeHttp429Error, - MindeeHttp500Error, - MindeeHttp504Error, - handleError, -} from "./error.js"; +export type { BaseHttpResponse } from "./apiCore.js"; export { isValidSyncResponse, isValidAsyncResponse, cleanRequestData, -} from "./responseValidation.js"; -export type { PredictParams, WorkflowParams } from "./httpParams.js"; +} from "../v1/http/responseValidation.js"; +export { BaseSettings } from "./baseSettings.js"; diff --git a/src/imageOperations/common/extractedImage.ts b/src/image/extractedImage.ts similarity index 96% rename from src/imageOperations/common/extractedImage.ts rename to src/image/extractedImage.ts index 5e16a1c0..e568014c 100644 --- a/src/imageOperations/common/extractedImage.ts +++ b/src/image/extractedImage.ts @@ -3,8 +3,7 @@ import { MindeeError } from "@/errors/index.js"; import { writeFileSync } from "node:fs"; import path from "node:path"; import { logger } from "@/logger.js"; -import { BufferInput } from "@/input/index.js"; -import { MIMETYPES } from "@/input/sources/localInputSource.js"; +import { BufferInput, MIMETYPES } from "@/input/index.js"; import { Poppler } from "node-poppler"; import { writeFile } from "fs/promises"; @@ -15,7 +14,6 @@ export class ExtractedImage { public buffer: Buffer; protected internalFileName: string; - protected constructor(buffer: Uint8Array, fileName: string) { this.buffer = Buffer.from(buffer); this.internalFileName = fileName; @@ -65,7 +63,6 @@ export class ExtractedImage { } } - /** * Attempts to saves the document to a file synchronously. * Throws an error if the file extension is not supported or if the file could not be saved to disk for some reason. @@ -92,7 +89,6 @@ export class ExtractedImage { } } - /** * Return the file as a Mindee-compatible BufferInput source. * diff --git a/src/imageOperations/imageCompressor.ts b/src/image/imageCompressor.ts similarity index 100% rename from src/imageOperations/imageCompressor.ts rename to src/image/imageCompressor.ts diff --git a/src/imageOperations/common/imageExtractor.ts b/src/image/imageExtractor.ts similarity index 100% rename from src/imageOperations/common/imageExtractor.ts rename to src/image/imageExtractor.ts diff --git a/src/imageOperations/common/index.ts b/src/image/index.ts similarity index 66% rename from src/imageOperations/common/index.ts rename to src/image/index.ts index f87b9a6a..5ace9a21 100644 --- a/src/imageOperations/common/index.ts +++ b/src/image/index.ts @@ -1,2 +1,3 @@ +export { compressImage } from "./imageCompressor.js"; export { ExtractedImage } from "./extractedImage.js"; export { extractFromPage } from "./imageExtractor.js"; diff --git a/src/index.ts b/src/index.ts index 16849ac0..c40ab2be 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,23 +1,3 @@ -export * as product from "./product/index.js"; -export { Client } from "./client.js"; -export type { PredictOptions, WorkflowOptions } from "./client.js"; -export { ClientV2 } from "./clientV2.js"; -export type { InferenceParameters, PollingOptions } from "./clientV2.js"; -export { - AsyncPredictResponse, - PredictResponse, - Inference, - Prediction, - Document, - Page, -} from "./parsing/common/index.js"; -export { - InferenceFile, - InferenceResponse, - JobResponse, - RawText, - RagMetadata, -} from "./parsing/v2/index.js"; export { InputSource, Base64Input, @@ -25,8 +5,24 @@ export { BytesInput, PathInput, StreamInput, - UrlInput, PageOptionsOperation, - LocalResponse + UrlInput, + PageOptionsOperation, } from "./input/index.js"; export type { PageOptions } from "./input/index.js"; -export * as imageOperations from "./imageOperations/index.js"; +export * as image from "./image/index.js"; + +// V1 +export * as v1 from "./v1/index.js"; + +// V2 +export * as v2 from "./v2/index.js"; +export { + Client, + InferenceFile, + InferenceResponse, + JobResponse, + RawText, + RagMetadata, + DataSchema, +} from "./v2/index.js"; +export type { InferenceParameters, PollingOptions } from "./v2/index.js"; diff --git a/src/input/sources/base64Input.ts b/src/input/base64Input.ts similarity index 100% rename from src/input/sources/base64Input.ts rename to src/input/base64Input.ts diff --git a/src/input/sources/bufferInput.ts b/src/input/bufferInput.ts similarity index 100% rename from src/input/sources/bufferInput.ts rename to src/input/bufferInput.ts diff --git a/src/input/sources/bytesInput.ts b/src/input/bytesInput.ts similarity index 100% rename from src/input/sources/bytesInput.ts rename to src/input/bytesInput.ts diff --git a/src/input/index.ts b/src/input/index.ts index 24ec093b..00baaa60 100644 --- a/src/input/index.ts +++ b/src/input/index.ts @@ -1,8 +1,18 @@ +export { Base64Input } from "./base64Input.js"; +export { BufferInput } from "./bufferInput.js"; +export { BytesInput } from "./bytesInput.js"; export { - DataSchema, DataSchemaField, DataSchemaReplace -} from "./dataSchema.js"; -export * from "./sources/index.js"; -export { LocalResponse } from "./localResponse.js"; + InputSource, + INPUT_TYPE_PATH, + INPUT_TYPE_STREAM, + INPUT_TYPE_BUFFER, + INPUT_TYPE_BASE64, + INPUT_TYPE_BYTES +} from "./inputSource.js"; +export type { InputConstructor } from "./inputSource.js"; +export { LocalInputSource, MIMETYPES } from "./localInputSource.js"; +export { PathInput } from "./pathInput.js"; +export { StreamInput } from "./streamInput.js"; +export { UrlInput } from "./urlInput.js"; export { PageOptionsOperation } from "./pageOptions.js"; export type { PageOptions } from "./pageOptions.js"; - diff --git a/src/input/sources/inputSource.ts b/src/input/inputSource.ts similarity index 100% rename from src/input/sources/inputSource.ts rename to src/input/inputSource.ts diff --git a/src/input/sources/localInputSource.ts b/src/input/localInputSource.ts similarity index 98% rename from src/input/sources/localInputSource.ts rename to src/input/localInputSource.ts index 9e66615c..68af1c1b 100644 --- a/src/input/sources/localInputSource.ts +++ b/src/input/localInputSource.ts @@ -1,10 +1,10 @@ import { errorHandler } from "@/errors/handler.js"; import { logger } from "@/logger.js"; -import { compressImage } from "@/imageOperations/index.js"; +import { compressImage } from "@/image/index.js"; import { compressPdf, countPages, extractPages, hasSourceText } from "@/pdf/index.js"; import path from "path"; import { fileTypeFromBuffer } from "file-type"; -import { PageOptions } from "../pageOptions.js"; +import { PageOptions } from "../input/pageOptions.js"; import { InputSource, InputConstructor, @@ -24,6 +24,7 @@ export const MIMETYPES = new Map([ [".tiff", "image/tiff"], [".webp", "image/webp"], ]); + const ALLOWED_INPUT_TYPES = [ INPUT_TYPE_STREAM, INPUT_TYPE_BASE64, diff --git a/src/input/pageOptions.ts b/src/input/pageOptions.ts index 17277467..1781c936 100644 --- a/src/input/pageOptions.ts +++ b/src/input/pageOptions.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ /** * Options to pass to the `parse` method for cutting multi-page documents. */ @@ -8,13 +7,13 @@ export interface PageOptions { * * A negative index can be used, indicating an offset from the end of the document. * - * [0, -1] represents the fist and last pages of the document. + * [0, -1] represents the first and last pages of the document. */ pageIndexes: number[]; /** Operation to apply on the document, given the `pageIndexes` specified. */ operation: PageOptionsOperation; /** - * Apply the operation only if document has at least this many pages. + * Apply the operation only if the document has at least this many pages. */ onMinPages: number; } @@ -22,6 +21,7 @@ export interface PageOptions { /** * Operation to apply on the document, given the page indexes specified. */ +/* eslint-disable @typescript-eslint/naming-convention */ export enum PageOptionsOperation { /** Only keep pages matching the provided indexes. */ KeepOnly = "KEEP_ONLY", diff --git a/src/input/sources/pathInput.ts b/src/input/pathInput.ts similarity index 100% rename from src/input/sources/pathInput.ts rename to src/input/pathInput.ts diff --git a/src/input/sources/index.ts b/src/input/sources/index.ts deleted file mode 100644 index 34b7feff..00000000 --- a/src/input/sources/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { Base64Input } from "./base64Input.js"; -export { BufferInput } from "./bufferInput.js"; -export { BytesInput } from "./bytesInput.js"; -export { - InputSource, - INPUT_TYPE_PATH, - INPUT_TYPE_STREAM, INPUT_TYPE_BUFFER, - INPUT_TYPE_BASE64, - INPUT_TYPE_BYTES -} from "./inputSource.js"; -export type { InputConstructor } from "./inputSource.js"; -export { LocalInputSource } from "./localInputSource.js"; -export { PathInput } from "./pathInput.js"; -export { StreamInput } from "./streamInput.js"; -export { UrlInput } from "./urlInput.js"; diff --git a/src/input/sources/streamInput.ts b/src/input/streamInput.ts similarity index 100% rename from src/input/sources/streamInput.ts rename to src/input/streamInput.ts diff --git a/src/input/sources/urlInput.ts b/src/input/urlInput.ts similarity index 100% rename from src/input/sources/urlInput.ts rename to src/input/urlInput.ts diff --git a/src/parsing/common/dateParser.ts b/src/parsing/dateParser.ts similarity index 100% rename from src/parsing/common/dateParser.ts rename to src/parsing/dateParser.ts diff --git a/src/parsing/index.ts b/src/parsing/index.ts index d854428f..a7add5bc 100644 --- a/src/parsing/index.ts +++ b/src/parsing/index.ts @@ -1,4 +1,2 @@ -export * as common from "./common/index.js"; -export * as standard from "./standard/index.js"; -export * as generated from "./generated/index.js"; -export * as v2 from "./v2/index.js"; +export type { StringDict } from "./stringDict.js"; +export { parseDate } from "./dateParser.js"; diff --git a/src/input/localResponse.ts b/src/parsing/localResponseBase.ts similarity index 73% rename from src/input/localResponse.ts rename to src/parsing/localResponseBase.ts index b5af6c27..e920f495 100644 --- a/src/input/localResponse.ts +++ b/src/parsing/localResponseBase.ts @@ -1,15 +1,14 @@ import * as crypto from "crypto"; import * as fs from "node:fs/promises"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { MindeeError } from "../errors/index.js"; import { Buffer } from "buffer"; -import { CommonResponse } from "../parsing/v2/index.js"; /** * Local response loaded from a file. * Note: Has to be initialized through init() before use. */ -export class LocalResponse { +export abstract class LocalResponseBase { private file: Buffer; private readonly inputHandle: Buffer | string; protected initialized = false; @@ -60,7 +59,7 @@ export class LocalResponse { } /** - * Returns the HMAC signature of the local response, from the secret key provided. + * Returns the HMAC signature of the local response from the secret key provided. * @param secretKey - Secret key, either a string or a byte/byte array. * @returns The HMAC signature of the local response. */ @@ -94,24 +93,4 @@ export class LocalResponse { } return signature === this.getHmacSignature(secretKey); } - - /** - * Deserialize the loaded local response into the requested CommonResponse-derived class. - * - * Typically used when dealing with V2 webhook callbacks. - * - * @typeParam ResponseT - A class that extends `CommonResponse`. - * @param responseClass - The constructor of the class into which the payload should be deserialized. - * @returns An instance of `responseClass` populated with the file content. - * @throws MindeeError If the provided class cannot be instantiated. - */ - public async deserializeResponse( - responseClass: new (serverResponse: StringDict) => ResponseT - ): Promise { - try { - return new responseClass(await this.asDict()); - } catch { - throw new MindeeError("Invalid response provided."); - } - } } diff --git a/src/parsing/common/stringDict.ts b/src/parsing/stringDict.ts similarity index 100% rename from src/parsing/common/stringDict.ts rename to src/parsing/stringDict.ts diff --git a/src/pdf/pdfCompressor.ts b/src/pdf/pdfCompressor.ts index 32409017..c031a679 100644 --- a/src/pdf/pdfCompressor.ts +++ b/src/pdf/pdfCompressor.ts @@ -4,7 +4,7 @@ import { ExtractedPdfInfo, extractTextFromPdf, hasSourceText } from "./pdfUtils. import * as fs from "node:fs"; import { Poppler } from "node-poppler"; import { PDFDocument, PDFFont, PDFPage, rgb, StandardFonts } from "@cantoo/pdf-lib"; -import { compressImage } from "@/imageOperations/imageCompressor.js"; +import { compressImage } from "@/image/index.js"; /** * Compresses each page of a provided PDF buffer. diff --git a/src/pdf/pdfOperation.ts b/src/pdf/pdfOperation.ts index d4b48e4b..27845468 100644 --- a/src/pdf/pdfOperation.ts +++ b/src/pdf/pdfOperation.ts @@ -10,10 +10,10 @@ export interface SplitPdf { } /** - * Cut pages from a pdf file. If pages index are out of bound, it will throw an error. + * Cut pages from a PDF file. If pages indexes are out of bounds, it will throw an error. * @param file * @param pageOptions - * @returns the new cut pdf file. + * @returns the new cut PDF file. */ export async function extractPages( file: Buffer, @@ -85,7 +85,7 @@ export async function extractPages( } /** - * Count the number of pages in a pdf file. + * Count the number of pages in a PDF file. * @param file * @returns the number of pages in the file. */ diff --git a/src/product/fr/internal.ts b/src/product/fr/internal.ts deleted file mode 100644 index f2348565..00000000 --- a/src/product/fr/internal.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * as bankAccountDetails from "./bankAccountDetails/index.js"; -export * as energyBill from "./energyBill/index.js"; -export * as healthCard from "./healthCard/index.js"; -export * as idCard from "./idCard/index.js"; -export * as payslip from "./payslip/index.js"; diff --git a/src/product/ind/index.ts b/src/product/ind/index.ts deleted file mode 100644 index 3249f812..00000000 --- a/src/product/ind/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { IndianPassportV1 } from "./indianPassport/index.js"; diff --git a/src/product/ind/internal.ts b/src/product/ind/internal.ts deleted file mode 100644 index 2dc538de..00000000 --- a/src/product/ind/internal.ts +++ /dev/null @@ -1 +0,0 @@ -export * as indianPassport from "./indianPassport/index.js"; diff --git a/src/product/internal.ts b/src/product/internal.ts deleted file mode 100644 index 2112bb85..00000000 --- a/src/product/internal.ts +++ /dev/null @@ -1,15 +0,0 @@ -export * as barcodeReader from "./barcodeReader/index.js"; -export * as cropper from "./cropper/index.js"; -export * as driverLicense from "./driverLicense/index.js"; -export * as financialDocument from "./financialDocument/index.js"; -export * as fr from "./fr/index.js"; -export * as generated from "./generated/index.js"; -export * as ind from "./ind/index.js"; -export * as internationalId from "./internationalId/index.js"; -export * as invoice from "./invoice/index.js"; -export * as invoiceSplitter from "./invoiceSplitter/index.js"; -export * as multiReceiptsDetector from "./multiReceiptsDetector/index.js"; -export * as passport from "./passport/index.js"; -export * as receipt from "./receipt/index.js"; -export * as resume from "./resume/index.js"; -export * as us from "./us/index.js"; diff --git a/src/product/us/index.ts b/src/product/us/index.ts deleted file mode 100644 index ac5e7b47..00000000 --- a/src/product/us/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { BankCheckV1 } from "./bankCheck/index.js"; -export { UsMailV3 } from "./usMail/index.js"; diff --git a/src/product/us/internal.ts b/src/product/us/internal.ts deleted file mode 100644 index 786879e8..00000000 --- a/src/product/us/internal.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * as bankCheck from "./bankCheck/index.js"; -export * as usMail from "./usMail/index.js"; diff --git a/src/cliV1.ts b/src/v1/cli.ts similarity index 95% rename from src/cliV1.ts rename to src/v1/cli.ts index d14043fe..6a628dcd 100644 --- a/src/cliV1.ts +++ b/src/v1/cli.ts @@ -1,13 +1,19 @@ -import { Command, OptionValues, Option } from "commander"; import { - Document, Inference, StringDict -} from "@/parsing/common/index.js"; -import { Client, PredictOptions } from "./client.js"; -import { PageOptions, PageOptionsOperation, PathInput } from "./input/index.js"; + Command, OptionValues, Option, +} from "commander"; +import { + Document, Inference, StringDict, +} from "@/v1/parsing/common/index.js"; +import { + Client, PredictOptions, +} from "./client.js"; +import { + PageOptions, PageOptionsOperation, PathInput, +} from "@/input/index.js"; import * as console from "console"; import { - CLI_COMMAND_CONFIG, COMMAND_GENERATED, ProductConfig -} from "./cliProducts.js"; + CLI_COMMAND_CONFIG, COMMAND_GENERATED, ProductConfig, +} from "./product/cliProducts.js"; import { Endpoint } from "./http/index.js"; const program = new Command(); @@ -227,7 +233,7 @@ function addPredictAction(prog: Command) { } } -export function cliV1() { +export function cli() { program.name("mindee") .description("Command line interface for Mindee products.") .option("-d, --debug", "high verbosity mode"); diff --git a/src/client.ts b/src/v1/client.ts similarity index 90% rename from src/client.ts rename to src/v1/client.ts index 7de5de84..51364859 100644 --- a/src/client.ts +++ b/src/v1/client.ts @@ -1,11 +1,16 @@ +import { setTimeout } from "node:timers/promises"; import { Dispatcher } from "undici"; import { InputSource, - LocalResponse, PageOptions, -} from "./input/index.js"; +} from "@/input/index.js"; +import { BaseHttpResponse } from "@/http/index.js"; +import { errorHandler } from "@/errors/handler.js"; +import { LOG_LEVELS, logger } from "@/logger.js"; import { - ApiSettings, Endpoint, EndpointResponse, STANDARD_API_OWNER + ApiSettingsV1, + Endpoint, + STANDARD_API_OWNER, } from "./http/index.js"; import { AsyncPredictResponse, @@ -16,16 +21,12 @@ import { StringDict, WorkflowResponse, } from "./parsing/common/index.js"; -import { errorHandler } from "./errors/handler.js"; -import { LOG_LEVELS, logger } from "./logger.js"; import { InferenceFactory } from "./parsing/common/inference.js"; import { GeneratedV1 } from "./product/index.js"; -import { setTimeout } from "node:timers/promises"; -import { MindeeError } from "./errors/index.js"; -import { WorkflowEndpoint } from "./http/workflowEndpoint.js"; +import { WorkflowEndpoint } from "./http/index.js"; /** - * Common options for workflows & predictions. + * Common options for workflows and predictions. */ interface BaseOptions { /** @@ -133,7 +134,7 @@ export interface ClientOptions { */ export class Client { /** Mindee V1 API settings. */ - protected apiSettings: ApiSettings; + protected apiSettings: ApiSettingsV1; /** * @param {ClientOptions} options options for the initialization of a client. @@ -146,7 +147,7 @@ export class Client { dispatcher: undefined, } ) { - this.apiSettings = new ApiSettings({ + this.apiSettings = new ApiSettingsV1({ apiKey: apiKey, dispatcher: dispatcher, }); @@ -194,7 +195,7 @@ export class Client { /** * Send the document to an asynchronous endpoint and return its ID in the queue. - * @param productClass product class to use for calling the API and parsing the response. + * @param productClass product class to use for calling the API and parsing the response. * @param inputSource file to parse. * @param params parameters relating to prediction options. * @category Asynchronous @@ -226,7 +227,7 @@ export class Client { /** * Polls a queue and returns its status as well as the prediction results if the parsing is done. * - * @param productClass product class to use for calling the API and parsing the response. + * @param productClass product class to use for calling the API and parsing the response. * @param queueId id of the queue to poll. * @param params parameters relating to prediction options. * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. @@ -245,29 +246,6 @@ export class Client { return new AsyncPredictResponse(productClass, docResponse.data); } - async loadPrediction( - productClass: new (httpResponse: StringDict) => T, - localResponse: LocalResponse - ) { - /** - * Load a prediction. - * - * @param productClass Product class to use for calling the API and parsing the response. - * @param localResponse Local response to load. - * @category Asynchronous - * @returns A valid prediction - */ - try { - const asDict = await localResponse.asDict(); - if (Object.prototype.hasOwnProperty.call(asDict, "job")) { - return new AsyncPredictResponse(productClass, asDict); - } - return new PredictResponse(productClass, asDict); - } catch { - throw new MindeeError("No prediction found in local response."); - } - } - /** * Send the document to an asynchronous endpoint and return its ID in the queue. * @param inputSource file to send to the API. @@ -299,7 +277,7 @@ export class Client { /** * Fetch prediction results from a document already processed. * - * @param productClass product class to use for calling the API and parsing the response. + * @param productClass product class to use for calling the API and parsing the response. * @param documentId id of the document to fetch. * @param params optional parameters. * @param params.endpoint Endpoint, only specify if using a custom product. @@ -314,14 +292,14 @@ export class Client { ): Promise> { const endpoint: Endpoint = params?.endpoint ?? this.#initializeOTSEndpoint(productClass); - const response: EndpointResponse = await endpoint.getDocument(documentId); + const response: BaseHttpResponse = await endpoint.getDocument(documentId); return new PredictResponse(productClass, response.data); } /** - * Send a feedback for a document. + * Send feedback for a document. * - * @param productClass product class to use for calling the API and parsing the response. + * @param productClass product class to use for calling the API and parsing the response. * @param documentId id of the document to send feedback for. * @param feedback the feedback to send. * @param params optional parameters. @@ -338,7 +316,7 @@ export class Client { ): Promise { const endpoint: Endpoint = params?.endpoint ?? this.#initializeOTSEndpoint(productClass); - const response: EndpointResponse = await endpoint.sendFeedback(documentId, feedback); + const response: BaseHttpResponse = await endpoint.sendFeedback(documentId, feedback); return new FeedbackResponse(response.data); } @@ -370,7 +348,7 @@ export class Client { /** * Send a document to an asynchronous endpoint and poll the server until the result is sent or - * until the maximum amount of tries is reached. + * until the maximum number of tries is reached. * * @param productClass product class to use for calling the API and parsing the response. * @param inputSource document to parse. diff --git a/src/imageOperations/index.ts b/src/v1/extraction/index.ts similarity index 65% rename from src/imageOperations/index.ts rename to src/v1/extraction/index.ts index bac08a1c..cf7cd9ea 100644 --- a/src/imageOperations/index.ts +++ b/src/v1/extraction/index.ts @@ -1,4 +1,2 @@ export { extractReceipts, ExtractedMultiReceiptImage } from "./multiReceiptsExtractor/index.js"; export { extractInvoices, ExtractedInvoiceSplitterImage } from "./invoiceSplitterExtractor/index.js"; -export { compressImage } from "./imageCompressor.js"; -export { ExtractedImage } from "./common/index.js"; diff --git a/src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts b/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts similarity index 83% rename from src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts rename to src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts index 44f88ae9..21f3c0c3 100644 --- a/src/imageOperations/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts +++ b/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts @@ -1,4 +1,4 @@ -import { ExtractedImage } from "@/imageOperations/common/extractedImage.js"; +import { ExtractedImage } from "@/image/extractedImage.js"; /** * Wrapper class for extracted invoice pages. diff --git a/src/imageOperations/invoiceSplitterExtractor/index.ts b/src/v1/extraction/invoiceSplitterExtractor/index.ts similarity index 100% rename from src/imageOperations/invoiceSplitterExtractor/index.ts rename to src/v1/extraction/invoiceSplitterExtractor/index.ts diff --git a/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts b/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts similarity index 98% rename from src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts rename to src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts index f47a9f28..cfc14cb9 100644 --- a/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.ts +++ b/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts @@ -1,6 +1,6 @@ import { PDFDocument } from "@cantoo/pdf-lib"; import { MindeeError, MindeeMimeTypeError } from "@/errors/index.js"; -import { InvoiceSplitterV1 } from "@/product/index.js"; +import { InvoiceSplitterV1 } from "@/v1/product/index.js"; import { LocalInputSource } from "@/input/index.js"; import { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterImage.js"; diff --git a/src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts b/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts similarity index 83% rename from src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts rename to src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts index d236fb23..075cc633 100644 --- a/src/imageOperations/multiReceiptsExtractor/extractedMultiReceiptImage.ts +++ b/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts @@ -1,4 +1,4 @@ -import { ExtractedImage } from "@/imageOperations/common/extractedImage.js"; +import { ExtractedImage } from "@/image/index.js"; /** * Wrapper class for extracted multiple-receipts images. diff --git a/src/imageOperations/multiReceiptsExtractor/index.ts b/src/v1/extraction/multiReceiptsExtractor/index.ts similarity index 100% rename from src/imageOperations/multiReceiptsExtractor/index.ts rename to src/v1/extraction/multiReceiptsExtractor/index.ts diff --git a/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts b/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts similarity index 94% rename from src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts rename to src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts index c90cb854..ce830799 100644 --- a/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.ts +++ b/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts @@ -1,11 +1,11 @@ import { PDFDocument, PDFImage, PDFPage, degrees } from "@cantoo/pdf-lib"; import { MindeeError, MindeeMimeTypeError } from "@/errors/index.js"; import { Polygon } from "@/geometry/index.js"; -import { MultiReceiptsDetectorV1 } from "@/product/index.js"; +import { MultiReceiptsDetectorV1 } from "@/v1/product/index.js"; import { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage.js"; import { LocalInputSource } from "@/input/index.js"; -import { extractFromPage } from "../common/index.js"; -import { PositionField } from "@/parsing/standard/index.js"; +import { extractFromPage } from "@/image/index.js"; +import { PositionField } from "@/v1/parsing/standard/index.js"; /** * Given a page and a set of coordinates, extracts & assigns individual receipts to an ExtractedMultiReceiptImage diff --git a/src/http/apiSettings.ts b/src/v1/http/apiSettingsV1.ts similarity index 81% rename from src/http/apiSettings.ts rename to src/v1/http/apiSettingsV1.ts index 361287e2..ec4213d0 100644 --- a/src/http/apiSettings.ts +++ b/src/v1/http/apiSettingsV1.ts @@ -1,13 +1,14 @@ -/* eslint-disable @typescript-eslint/naming-convention */ + import { logger } from "@/logger.js"; -import { BaseSettings, MindeeApiConstructorProps } from "./baseSettings.js"; +import { BaseSettings, MindeeApiConstructorProps } from "../../http/baseSettings.js"; +import { MindeeConfigurationError } from "@/errors/index.js"; export const STANDARD_API_OWNER: string = "mindee"; const API_V1_KEY_ENVVAR_NAME: string = "MINDEE_API_KEY"; const API_V1_HOST_ENVVAR_NAME: string = "MINDEE_API_HOST"; const DEFAULT_MINDEE_API_HOST: string = "api.mindee.net"; -export class ApiSettings extends BaseSettings { +export class ApiSettingsV1 extends BaseSettings { baseHeaders: Record; constructor({ @@ -16,11 +17,12 @@ export class ApiSettings extends BaseSettings { }: MindeeApiConstructorProps) { super(apiKey, dispatcher); if (!this.apiKey || this.apiKey.length === 0) { - throw new Error( + throw new MindeeConfigurationError( "Your V1 API key could not be set, check your Client Configuration\n." + `You can set this using the ${API_V1_KEY_ENVVAR_NAME} environment variable.` ); } + /* eslint-disable @typescript-eslint/naming-convention */ this.baseHeaders = { "User-Agent": this.getUserAgent(), Authorization: `Token ${this.apiKey}`, diff --git a/src/http/endpoint.ts b/src/v1/http/endpoint.ts similarity index 88% rename from src/http/endpoint.ts rename to src/v1/http/endpoint.ts index 567605de..d74cf2ca 100644 --- a/src/http/endpoint.ts +++ b/src/v1/http/endpoint.ts @@ -1,9 +1,9 @@ import { URLSearchParams } from "url"; import { InputSource, LocalInputSource } from "@/input/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; -import { cutDocPages, sendRequestAndReadResponse, EndpointResponse } from "./apiCore.js"; -import { ApiSettings } from "./apiSettings.js"; -import { handleError } from "./error.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { cutDocPages, sendRequestAndReadResponse, BaseHttpResponse } from "@/http/apiCore.js"; +import { ApiSettingsV1 } from "./apiSettingsV1.js"; +import { handleError } from "./errors.js"; import { PredictParams } from "./httpParams.js"; import { isValidAsyncResponse, isValidSyncResponse } from "./responseValidation.js"; @@ -12,7 +12,7 @@ import { isValidAsyncResponse, isValidSyncResponse } from "./responseValidation. */ export class Endpoint { /** Settings relating to the API. */ - settings: ApiSettings; + settings: ApiSettingsV1; /** Root of the URL for API calls. */ urlRoot: string; /** URL of a product. */ @@ -26,7 +26,7 @@ export class Endpoint { urlName: string, owner: string, version: string, - settings: ApiSettings + settings: ApiSettingsV1 ) { this.settings = settings; this.urlRoot = `/v1/products/${owner}/${urlName}/v${version}`; @@ -42,7 +42,7 @@ export class Endpoint { * @category Synchronous * @returns a `Promise` containing parsing results. */ - async predict(params: PredictParams): Promise { + async predict(params: PredictParams): Promise { await params.inputDoc.init(); if (params.pageOptions !== undefined) { await cutDocPages(params.inputDoc, params.pageOptions); @@ -66,7 +66,7 @@ export class Endpoint { * @category Asynchronous * @returns a `Promise` containing queue data. */ - async predictAsync(params: PredictParams): Promise { + async predictAsync(params: PredictParams): Promise { await params.inputDoc.init(); if (params.pageOptions !== undefined) { await cutDocPages(params.inputDoc, params.pageOptions); @@ -85,7 +85,7 @@ export class Endpoint { return response; } - private extractStatusMessage(response: EndpointResponse): string | undefined { + private extractStatusMessage(response: BaseHttpResponse): string | undefined { if (response.messageObj?.statusMessage !== undefined && response.messageObj?.statusMessage !== null) { return response.messageObj?.statusMessage; } @@ -107,8 +107,8 @@ export class Endpoint { * @category Asynchronous * @returns a `Promise` containing the parsed result. */ - async getQueuedDocument(queueId: string): Promise { - const queueResponse: EndpointResponse = await this.#documentQueueReqGet(queueId); + async getQueuedDocument(queueId: string): Promise { + const queueResponse: BaseHttpResponse = await this.#documentQueueReqGet(queueId); const queueStatusCode = queueResponse.messageObj.statusCode; if (!isValidAsyncResponse(queueResponse)) { handleError(this.urlName, queueResponse, this.extractStatusMessage(queueResponse)); @@ -129,7 +129,7 @@ export class Endpoint { * Send a feedback * @param {string} documentId */ - async getDocument(documentId: string): Promise { + async getDocument(documentId: string): Promise { const response = await this.#documentGetReq( documentId, ); @@ -147,8 +147,8 @@ export class Endpoint { async sendFeedback( documentId: string, feedback: StringDict - ): Promise { - const response: EndpointResponse = await this.#documentFeedbackPutReq( + ): Promise { + const response: BaseHttpResponse = await this.#documentFeedbackPutReq( documentId, feedback, ); @@ -176,7 +176,7 @@ export class Endpoint { cropper: boolean = false, rag: boolean = false, workflowId: string | undefined = undefined - ): Promise { + ): Promise { const searchParams = new URLSearchParams(); if (cropper) { searchParams.set("cropper", "true"); @@ -231,7 +231,7 @@ export class Endpoint { includeWords: boolean = false, fullText: boolean = false, cropper: boolean = false - ): Promise { + ): Promise { return this.sendFileForPrediction(input, "predict", includeWords, fullText, cropper); } @@ -251,7 +251,7 @@ export class Endpoint { cropper: boolean = false, rag: boolean = false, workflowId: string | undefined = undefined - ): Promise { + ): Promise { return this.sendFileForPrediction( input, "predict_async", @@ -267,7 +267,7 @@ export class Endpoint { * Make a request to GET the status of a document in the queue. * @param queueId */ - async #documentQueueReqGet(queueId: string): Promise { + async #documentQueueReqGet(queueId: string): Promise { const options = { method: "GET", headers: this.settings.baseHeaders, @@ -282,7 +282,7 @@ export class Endpoint { * Make a request to GET a document. * @param documentId */ - async #documentGetReq(documentId: string): Promise { + async #documentGetReq(documentId: string): Promise { const options = { method: "GET", headers: this.settings.baseHeaders, @@ -298,7 +298,7 @@ export class Endpoint { * @param documentId * @param feedback */ - async #documentFeedbackPutReq(documentId: string, feedback: StringDict): Promise { + async #documentFeedbackPutReq(documentId: string, feedback: StringDict): Promise { const options = { method: "PUT", headers: this.settings.baseHeaders, diff --git a/src/http/error.ts b/src/v1/http/errors.ts similarity index 88% rename from src/http/error.ts rename to src/v1/http/errors.ts index 74c5100b..46ac6773 100644 --- a/src/http/error.ts +++ b/src/v1/http/errors.ts @@ -1,11 +1,11 @@ import { MindeeError } from "@/errors/index.js"; import { errorHandler } from "@/errors/handler.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; -import { EndpointResponse } from "./apiCore.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { BaseHttpResponse } from "../../http/apiCore.js"; export function handleError( urlName: string, - response: EndpointResponse, + response: BaseHttpResponse, serverError?: string ): void { let code; @@ -99,7 +99,7 @@ export function handleError( errorToThrow = new MindeeHttp504Error(errorObj, urlName, code); break; default: - errorToThrow = new MindeeHttpError(errorObj, urlName, code); + errorToThrow = new MindeeHttpErrorV1(errorObj, urlName, code); break; } errorHandler.throw(errorToThrow); @@ -109,7 +109,7 @@ export function handleError( * `Error` wrapper for server (HTTP) errors. * Is used when an error is lacking a handled error code. */ -export class MindeeHttpError extends MindeeError { +export class MindeeHttpErrorV1 extends MindeeError { /** Description of the error. */ message: string = ""; /** Additional details on the error. */ @@ -130,7 +130,7 @@ export class MindeeHttpError extends MindeeError { * Generic client errors. * Can include errors like InvalidQuery. */ -export class MindeeHttp400Error extends MindeeHttpError { +export class MindeeHttp400Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp400Error"; @@ -140,7 +140,7 @@ export class MindeeHttp400Error extends MindeeHttpError { /** * Can include errors like NoTokenSet or InvalidToken. */ -export class MindeeHttp401Error extends MindeeHttpError { +export class MindeeHttp401Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp401Error"; @@ -151,14 +151,14 @@ export class MindeeHttp401Error extends MindeeHttpError { * Regular AccessForbidden error. * Can also include errors like PlanLimitReached, AsyncRequestDisallowed or SyncRequestDisallowed. */ -export class MindeeHttp403Error extends MindeeHttpError { +export class MindeeHttp403Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp403Error"; } } -export class MindeeHttp404Error extends MindeeHttpError { +export class MindeeHttp404Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp404Error"; @@ -169,7 +169,7 @@ export class MindeeHttp404Error extends MindeeHttpError { * Rare error. * Can occasionally happen when unusually large documents are passed. */ -export class MindeeHttp413Error extends MindeeHttpError { +export class MindeeHttp413Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp413Error"; @@ -180,7 +180,7 @@ export class MindeeHttp413Error extends MindeeHttpError { * Usually corresponds to TooManyRequests errors. * Arises whenever too many calls to the API are made in quick succession. */ -export class MindeeHttp429Error extends MindeeHttpError { +export class MindeeHttp429Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp429Error"; @@ -190,7 +190,7 @@ export class MindeeHttp429Error extends MindeeHttpError { /** * Generic server errors. */ -export class MindeeHttp500Error extends MindeeHttpError { +export class MindeeHttp500Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp500Error"; @@ -201,7 +201,7 @@ export class MindeeHttp500Error extends MindeeHttpError { * Miscellaneous server errors. * Can include errors like RequestTimeout or GatewayTimeout. */ -export class MindeeHttp504Error extends MindeeHttpError { +export class MindeeHttp504Error extends MindeeHttpErrorV1 { constructor(httpError: StringDict, urlName: string, code?: number) { super(httpError, urlName, code); this.name = "MindeeHttp504Error"; diff --git a/src/http/httpParams.ts b/src/v1/http/httpParams.ts similarity index 86% rename from src/http/httpParams.ts rename to src/v1/http/httpParams.ts index 8b5f701a..4cbab337 100644 --- a/src/http/httpParams.ts +++ b/src/v1/http/httpParams.ts @@ -1,5 +1,5 @@ import { InputSource, PageOptions } from "@/input/index.js"; -import { ExecutionPriority } from "@/parsing/common/index.js"; +import { ExecutionPriority } from "@/v1/parsing/common/index.js"; interface HTTPParams { inputDoc: InputSource; diff --git a/src/v1/http/index.ts b/src/v1/http/index.ts new file mode 100644 index 00000000..77ff1c36 --- /dev/null +++ b/src/v1/http/index.ts @@ -0,0 +1,19 @@ +export { Endpoint } from "./endpoint.js"; +export { + STANDARD_API_OWNER, + ApiSettingsV1, +} from "./apiSettingsV1.js"; +export { + MindeeHttpErrorV1, + MindeeHttp400Error, + MindeeHttp401Error, + MindeeHttp403Error, + MindeeHttp404Error, + MindeeHttp413Error, + MindeeHttp429Error, + MindeeHttp500Error, + MindeeHttp504Error, + handleError, +} from "./errors.js"; +export { WorkflowEndpoint } from "./workflowEndpoint.js"; +export type { PredictParams, WorkflowParams } from "./httpParams.js"; diff --git a/src/http/responseValidation.ts b/src/v1/http/responseValidation.ts similarity index 90% rename from src/http/responseValidation.ts rename to src/v1/http/responseValidation.ts index 884cab71..8aa63ca9 100644 --- a/src/http/responseValidation.ts +++ b/src/v1/http/responseValidation.ts @@ -1,4 +1,4 @@ -import { EndpointResponse } from "./apiCore.js"; +import { BaseHttpResponse } from "../../http/apiCore.js"; /** * Checks if the synchronous response is valid. Returns True if the response is valid. @@ -6,7 +6,7 @@ import { EndpointResponse } from "./apiCore.js"; * @param response an endpoint response object. * @returns bool */ -export function isValidSyncResponse(response: EndpointResponse): boolean { +export function isValidSyncResponse(response: BaseHttpResponse): boolean { if (!response.messageObj || !response.messageObj.statusCode) { return false; } @@ -33,7 +33,7 @@ export function isValidSyncResponse(response: EndpointResponse): boolean { * @param response an endpoint response object. * @returns bool */ -export function isValidAsyncResponse(response: EndpointResponse): boolean { +export function isValidAsyncResponse(response: BaseHttpResponse): boolean { if (!isValidSyncResponse(response)) { return false; } @@ -61,7 +61,7 @@ export function isValidAsyncResponse(response: EndpointResponse): boolean { * @param response an endpoint response object. * @returns EndpointResponse Returns the job error if the error is due to parsing, returns the http error otherwise. */ -export function cleanRequestData(response: EndpointResponse): EndpointResponse { +export function cleanRequestData(response: BaseHttpResponse): BaseHttpResponse { if (response.messageObj && response.messageObj.statusCode && ( diff --git a/src/http/workflowEndpoint.ts b/src/v1/http/workflowEndpoint.ts similarity index 85% rename from src/http/workflowEndpoint.ts rename to src/v1/http/workflowEndpoint.ts index 595f4309..7a4b5959 100644 --- a/src/http/workflowEndpoint.ts +++ b/src/v1/http/workflowEndpoint.ts @@ -1,9 +1,9 @@ import { URLSearchParams } from "url"; import { InputSource, LocalInputSource } from "@/input/index.js"; -import { ExecutionPriority } from "@/parsing/common/index.js"; -import { cutDocPages, sendRequestAndReadResponse, EndpointResponse } from "./apiCore.js"; -import { ApiSettings } from "./apiSettings.js"; -import { handleError } from "./error.js"; +import { ExecutionPriority } from "@/v1/parsing/common/index.js"; +import { cutDocPages, sendRequestAndReadResponse, BaseHttpResponse } from "../../http/apiCore.js"; +import { ApiSettingsV1 } from "./apiSettingsV1.js"; +import { handleError } from "./errors.js"; import { WorkflowParams } from "./httpParams.js"; import { isValidSyncResponse } from "./responseValidation.js"; @@ -12,12 +12,12 @@ import { isValidSyncResponse } from "./responseValidation.js"; */ export class WorkflowEndpoint { /** Settings relating to the API. */ - settings: ApiSettings; + settings: ApiSettingsV1; /** Root of the URL for API calls. */ urlRoot: string; constructor( - settings: ApiSettings, + settings: ApiSettingsV1, workflowId: string ) { this.settings = settings; @@ -31,7 +31,7 @@ export class WorkflowEndpoint { * @category Synchronous * @returns a `Promise` containing parsing results. */ - async executeWorkflow(params: WorkflowParams): Promise { + async executeWorkflow(params: WorkflowParams): Promise { await params.inputDoc.init(); if (params.pageOptions !== undefined) { await cutDocPages(params.inputDoc, params.pageOptions); @@ -48,7 +48,7 @@ export class WorkflowEndpoint { * * @param {WorkflowParams} params parameters relating to prediction options. */ - #workflowReqPost(params: WorkflowParams): Promise { + #workflowReqPost(params: WorkflowParams): Promise { return this.sendFileForPrediction( params.inputDoc, params.alias, @@ -75,7 +75,7 @@ export class WorkflowEndpoint { fullText: boolean = false, publicUrl: string | null = null, rag: boolean | null = null, - ): Promise { + ): Promise { const searchParams = new URLSearchParams(); if (fullText) { searchParams.set("full_text_ocr", "true"); diff --git a/src/v1/index.ts b/src/v1/index.ts new file mode 100644 index 00000000..a0263960 --- /dev/null +++ b/src/v1/index.ts @@ -0,0 +1,19 @@ +export * as extraction from "./extraction/index.js"; +export * as http from "./http/index.js"; +export * as parsing from "./parsing/index.js"; +export * as product from "./product/index.js"; +export { LocalResponse } from "./parsing/localResponse.js"; +export { Client } from "./client.js"; +export type { + OptionalAsyncOptions, + PredictOptions, + WorkflowOptions +} from "./client.js"; +export { + AsyncPredictResponse, + PredictResponse, + Inference, + Prediction, + Document, + Page, +} from "./parsing/common/index.js"; diff --git a/src/parsing/common/apiRequest.ts b/src/v1/parsing/common/apiRequest.ts similarity index 92% rename from src/parsing/common/apiRequest.ts rename to src/v1/parsing/common/apiRequest.ts index a502f161..3d28d3db 100644 --- a/src/parsing/common/apiRequest.ts +++ b/src/v1/parsing/common/apiRequest.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * Holds the information relating to an API HTTP request. * diff --git a/src/parsing/common/apiResponse.ts b/src/v1/parsing/common/apiResponse.ts similarity index 92% rename from src/parsing/common/apiResponse.ts rename to src/v1/parsing/common/apiResponse.ts index 39654808..b900eccd 100644 --- a/src/parsing/common/apiResponse.ts +++ b/src/v1/parsing/common/apiResponse.ts @@ -1,5 +1,5 @@ import { ApiRequest } from "./apiRequest.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** Base wrapper for API requests. diff --git a/src/parsing/common/asyncPredictResponse.ts b/src/v1/parsing/common/asyncPredictResponse.ts similarity index 97% rename from src/parsing/common/asyncPredictResponse.ts rename to src/v1/parsing/common/asyncPredictResponse.ts index 6c60ac2c..ea477892 100644 --- a/src/parsing/common/asyncPredictResponse.ts +++ b/src/v1/parsing/common/asyncPredictResponse.ts @@ -1,5 +1,5 @@ import { ApiResponse } from "./apiResponse.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Inference } from "./inference.js"; import { Document } from "./document.js"; diff --git a/src/parsing/common/document.ts b/src/v1/parsing/common/document.ts similarity index 98% rename from src/parsing/common/document.ts rename to src/v1/parsing/common/document.ts index c94867ed..f9d8c4a8 100644 --- a/src/parsing/common/document.ts +++ b/src/v1/parsing/common/document.ts @@ -1,7 +1,7 @@ import { CropperExtra, FullTextOcrExtra, ExtraField, Extras } from "./extras/index.js"; import { Inference } from "./inference.js"; import { Ocr } from "./ocr.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { RAGExtra } from "./extras/ragExtra.js"; /** diff --git a/src/parsing/common/execution.ts b/src/v1/parsing/common/execution.ts similarity index 91% rename from src/parsing/common/execution.ts rename to src/v1/parsing/common/execution.ts index 78d66660..4560c122 100644 --- a/src/parsing/common/execution.ts +++ b/src/v1/parsing/common/execution.ts @@ -1,9 +1,9 @@ import { Inference } from "./inference.js"; -import { GeneratedV1Document } from "@/product/generated/generatedV1Document.js"; +import { GeneratedV1Document } from "@/v1/product/generated/generatedV1Document.js"; import { ExecutionFile } from "./executionFile.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { ExecutionPriority } from "./executionPriority.js"; -import { parseDate } from "./dateParser.js"; +import { parseDate } from "../../../parsing/dateParser.js"; /** * Representation of an execution for a workflow. diff --git a/src/parsing/common/executionFile.ts b/src/v1/parsing/common/executionFile.ts similarity index 84% rename from src/parsing/common/executionFile.ts rename to src/v1/parsing/common/executionFile.ts index 72e9db13..b13530b3 100644 --- a/src/parsing/common/executionFile.ts +++ b/src/v1/parsing/common/executionFile.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * Representation of an execution's file info. diff --git a/src/parsing/common/executionPriority.ts b/src/v1/parsing/common/executionPriority.ts similarity index 100% rename from src/parsing/common/executionPriority.ts rename to src/v1/parsing/common/executionPriority.ts diff --git a/src/parsing/common/extras/cropperExtra.ts b/src/v1/parsing/common/extras/cropperExtra.ts similarity index 85% rename from src/parsing/common/extras/cropperExtra.ts rename to src/v1/parsing/common/extras/cropperExtra.ts index 303f37aa..1884972a 100644 --- a/src/parsing/common/extras/cropperExtra.ts +++ b/src/v1/parsing/common/extras/cropperExtra.ts @@ -1,5 +1,5 @@ -import { PositionField } from "@/parsing/standard/position.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { PositionField } from "@/v1/parsing/standard/position.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { cleanOutString } from "../summaryHelper.js"; import { ExtraField } from "./extras.js"; diff --git a/src/parsing/common/extras/extras.ts b/src/v1/parsing/common/extras/extras.ts similarity index 100% rename from src/parsing/common/extras/extras.ts rename to src/v1/parsing/common/extras/extras.ts diff --git a/src/parsing/common/extras/fullTextOcrExtra.ts b/src/v1/parsing/common/extras/fullTextOcrExtra.ts similarity index 89% rename from src/parsing/common/extras/fullTextOcrExtra.ts rename to src/v1/parsing/common/extras/fullTextOcrExtra.ts index 94f0a949..eaea594a 100644 --- a/src/parsing/common/extras/fullTextOcrExtra.ts +++ b/src/v1/parsing/common/extras/fullTextOcrExtra.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { ExtraField } from "./extras.js"; export class FullTextOcrExtra extends ExtraField { diff --git a/src/parsing/common/extras/index.ts b/src/v1/parsing/common/extras/index.ts similarity index 100% rename from src/parsing/common/extras/index.ts rename to src/v1/parsing/common/extras/index.ts diff --git a/src/parsing/common/extras/ragExtra.ts b/src/v1/parsing/common/extras/ragExtra.ts similarity index 86% rename from src/parsing/common/extras/ragExtra.ts rename to src/v1/parsing/common/extras/ragExtra.ts index cd0a28d0..563a1ff4 100644 --- a/src/parsing/common/extras/ragExtra.ts +++ b/src/v1/parsing/common/extras/ragExtra.ts @@ -1,5 +1,5 @@ import { ExtraField } from "./extras.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class RAGExtra extends ExtraField { /** diff --git a/src/parsing/common/feedback/feedbackResponse.ts b/src/v1/parsing/common/feedback/feedbackResponse.ts similarity index 88% rename from src/parsing/common/feedback/feedbackResponse.ts rename to src/v1/parsing/common/feedback/feedbackResponse.ts index b31408ee..070114e3 100644 --- a/src/parsing/common/feedback/feedbackResponse.ts +++ b/src/v1/parsing/common/feedback/feedbackResponse.ts @@ -1,5 +1,5 @@ import { ApiResponse } from "../apiResponse.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * Wrapper for feedback response. diff --git a/src/parsing/common/index.ts b/src/v1/parsing/common/index.ts similarity index 85% rename from src/parsing/common/index.ts rename to src/v1/parsing/common/index.ts index f66cf009..0b6084dc 100644 --- a/src/parsing/common/index.ts +++ b/src/v1/parsing/common/index.ts @@ -5,7 +5,7 @@ export { ExecutionPriority } from "./executionPriority.js"; export { Inference } from "./inference.js"; export { FeedbackResponse } from "./feedback/feedbackResponse.js"; export { OrientationField } from "./orientation.js"; -export type { StringDict } from "./stringDict.js"; +export type { StringDict } from "../../../parsing/stringDict.js"; export { AsyncPredictResponse } from "./asyncPredictResponse.js"; export { PredictResponse } from "./predictResponse.js"; export { Prediction } from "./prediction.js"; @@ -14,5 +14,5 @@ export { cleanOutString, lineSeparator, floatToString, cleanSpecialChars } from "./summaryHelper.js"; export * as extras from "./extras/index.js"; -export { parseDate } from "./dateParser.js"; +export { parseDate } from "../../../parsing/dateParser.js"; export { WorkflowResponse } from "./workflowResponse.js"; diff --git a/src/parsing/common/inference.ts b/src/v1/parsing/common/inference.ts similarity index 96% rename from src/parsing/common/inference.ts rename to src/v1/parsing/common/inference.ts index a1e0237d..be25f514 100644 --- a/src/parsing/common/inference.ts +++ b/src/v1/parsing/common/inference.ts @@ -1,10 +1,11 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Page } from "./page.js"; import type { Prediction } from "./prediction.js"; import { Product } from "./product.js"; import { CropperExtra, FullTextOcrExtra, ExtraField, Extras, RAGExtra } from "./extras/index.js"; +import { MindeeConfigurationError } from "@/errors/index.js"; /** * @@ -118,7 +119,7 @@ export class InferenceFactory { emptyProduct.endpointName.length === 0 || emptyProduct.endpointVersion.length === 0 ) { - throw new Error( + throw new MindeeConfigurationError( `Error during endpoint verification, no endpoint found for product ${inferenceClass.name}.` ); } diff --git a/src/parsing/common/mvisionV1.ts b/src/v1/parsing/common/mvisionV1.ts similarity index 80% rename from src/parsing/common/mvisionV1.ts rename to src/v1/parsing/common/mvisionV1.ts index dfe6d1ed..ca392aa8 100644 --- a/src/parsing/common/mvisionV1.ts +++ b/src/v1/parsing/common/mvisionV1.ts @@ -1,5 +1,5 @@ -import { Word } from "../standard/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { Word } from "@/v1/parsing/standard/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { OcrPage } from "./ocrPage.js"; export class MvisionV1 { diff --git a/src/parsing/common/ocr.ts b/src/v1/parsing/common/ocr.ts similarity index 84% rename from src/parsing/common/ocr.ts rename to src/v1/parsing/common/ocr.ts index 21718519..477ea394 100644 --- a/src/parsing/common/ocr.ts +++ b/src/v1/parsing/common/ocr.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { MvisionV1 } from "./mvisionV1.js"; export class Ocr { diff --git a/src/parsing/common/ocrPage.ts b/src/v1/parsing/common/ocrPage.ts similarity index 95% rename from src/parsing/common/ocrPage.ts rename to src/v1/parsing/common/ocrPage.ts index b78216f8..617e74a6 100644 --- a/src/parsing/common/ocrPage.ts +++ b/src/v1/parsing/common/ocrPage.ts @@ -4,8 +4,8 @@ import { getCentroid, isPointInPolygonY, } from "@/geometry/index.js"; -import { Word } from "@/parsing/standard/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { Word } from "@/v1/parsing/standard/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class OcrPage { /** Flat list of all words read */ diff --git a/src/parsing/common/orientation.ts b/src/v1/parsing/common/orientation.ts similarity index 91% rename from src/parsing/common/orientation.ts rename to src/v1/parsing/common/orientation.ts index 19cd3da5..967555c8 100644 --- a/src/parsing/common/orientation.ts +++ b/src/v1/parsing/common/orientation.ts @@ -1,4 +1,4 @@ -import { BaseField, BaseFieldConstructor } from "@/parsing/standard/index.js"; +import { BaseField, BaseFieldConstructor } from "@/v1/parsing/standard/index.js"; interface OrientationFieldConstructor extends BaseFieldConstructor { pageId: number; diff --git a/src/parsing/common/page.ts b/src/v1/parsing/common/page.ts similarity index 98% rename from src/parsing/common/page.ts rename to src/v1/parsing/common/page.ts index 7330a28d..206c4495 100644 --- a/src/parsing/common/page.ts +++ b/src/v1/parsing/common/page.ts @@ -1,7 +1,7 @@ import { CropperExtra, FullTextOcrExtra, ExtraField, Extras } from "./extras/index.js"; import { OrientationField } from "./orientation.js"; import { Prediction } from "./prediction.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** diff --git a/src/parsing/common/predictResponse.ts b/src/v1/parsing/common/predictResponse.ts similarity index 92% rename from src/parsing/common/predictResponse.ts rename to src/v1/parsing/common/predictResponse.ts index e0a31858..b8ad6a41 100644 --- a/src/parsing/common/predictResponse.ts +++ b/src/v1/parsing/common/predictResponse.ts @@ -1,7 +1,7 @@ import { ApiResponse } from "./apiResponse.js"; import { Document } from "./document.js"; import { Inference } from "./inference.js"; -import { StringDict } from "./stringDict.js"; +import { StringDict } from "../../../parsing/stringDict.js"; /** Wrapper for synchronous prediction response. * diff --git a/src/parsing/common/prediction.ts b/src/v1/parsing/common/prediction.ts similarity index 100% rename from src/parsing/common/prediction.ts rename to src/v1/parsing/common/prediction.ts diff --git a/src/parsing/common/product.ts b/src/v1/parsing/common/product.ts similarity index 100% rename from src/parsing/common/product.ts rename to src/v1/parsing/common/product.ts diff --git a/src/parsing/common/summaryHelper.ts b/src/v1/parsing/common/summaryHelper.ts similarity index 100% rename from src/parsing/common/summaryHelper.ts rename to src/v1/parsing/common/summaryHelper.ts diff --git a/src/parsing/common/workflowResponse.ts b/src/v1/parsing/common/workflowResponse.ts similarity index 91% rename from src/parsing/common/workflowResponse.ts rename to src/v1/parsing/common/workflowResponse.ts index a82236b5..56c4b6b6 100644 --- a/src/parsing/common/workflowResponse.ts +++ b/src/v1/parsing/common/workflowResponse.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { ApiResponse } from "./apiResponse.js"; import { Execution } from "./execution.js"; import { Inference } from "./inference.js"; diff --git a/src/parsing/generated/generatedList.ts b/src/v1/parsing/generated/generatedList.ts similarity index 93% rename from src/parsing/generated/generatedList.ts rename to src/v1/parsing/generated/generatedList.ts index 819f1e6f..86c96614 100644 --- a/src/parsing/generated/generatedList.ts +++ b/src/v1/parsing/generated/generatedList.ts @@ -1,5 +1,5 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; -import { StringField } from "@/parsing/standard/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; import { GeneratedObjectField, isGeneratedObject } from "./generatedObject.js"; export interface GeneratedListFieldConstructor { diff --git a/src/parsing/generated/generatedObject.ts b/src/v1/parsing/generated/generatedObject.ts similarity index 96% rename from src/parsing/generated/generatedObject.ts rename to src/v1/parsing/generated/generatedObject.ts index 582d444b..6fb592eb 100644 --- a/src/parsing/generated/generatedObject.ts +++ b/src/v1/parsing/generated/generatedObject.ts @@ -1,5 +1,5 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; -import { BaseFieldConstructor, PositionField } from "@/parsing/standard/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { BaseFieldConstructor, PositionField } from "@/v1/parsing/standard/index.js"; /** A JSON-like object, with miscellaneous values. */ diff --git a/src/parsing/generated/index.ts b/src/v1/parsing/generated/index.ts similarity index 100% rename from src/parsing/generated/index.ts rename to src/v1/parsing/generated/index.ts diff --git a/src/v1/parsing/index.ts b/src/v1/parsing/index.ts new file mode 100644 index 00000000..b2fa95a5 --- /dev/null +++ b/src/v1/parsing/index.ts @@ -0,0 +1,4 @@ +export * as common from "./common/index.js"; +export * as generated from "./generated/index.js"; +export * as standard from "./standard/index.js"; +export { LocalResponse } from "./localResponse.js"; diff --git a/src/v1/parsing/localResponse.ts b/src/v1/parsing/localResponse.ts new file mode 100644 index 00000000..9ba58346 --- /dev/null +++ b/src/v1/parsing/localResponse.ts @@ -0,0 +1,32 @@ +import { LocalResponseBase } from "@/parsing/localResponseBase.js"; +import { AsyncPredictResponse, Inference, PredictResponse } from "@/v1/index.js"; +import { StringDict } from "@/parsing/index.js"; +import { MindeeError } from "@/errors/index.js"; + +/** + * Local response loaded from a file. + * Note: Has to be initialized through init() before use. + */ +export class LocalResponse extends LocalResponseBase { + async loadPrediction( + productClass: new (httpResponse: StringDict) => T + ) { + /** + * Load a prediction. + * + * @param productClass Product class to use for calling the API and parsing the response. + * @param localResponse Local response to load. + * @category Asynchronous + * @returns A valid prediction + */ + try { + const asDict = await this.asDict(); + if (Object.prototype.hasOwnProperty.call(asDict, "job")) { + return new AsyncPredictResponse(productClass, asDict); + } + return new PredictResponse(productClass, asDict); + } catch { + throw new MindeeError("No prediction found in local response."); + } + } +} diff --git a/src/parsing/standard/addressField.ts b/src/v1/parsing/standard/addressField.ts similarity index 100% rename from src/parsing/standard/addressField.ts rename to src/v1/parsing/standard/addressField.ts diff --git a/src/parsing/standard/amount.ts b/src/v1/parsing/standard/amount.ts similarity index 93% rename from src/parsing/standard/amount.ts rename to src/v1/parsing/standard/amount.ts index 135aeea3..af4892c0 100644 --- a/src/parsing/standard/amount.ts +++ b/src/v1/parsing/standard/amount.ts @@ -1,6 +1,6 @@ import { Field } from "./field.js"; import { BaseFieldConstructor } from "./base.js"; -import { floatToString } from "@/parsing/common/index.js"; +import { floatToString } from "@/v1/parsing/common/index.js"; /** * A field containing an amount value. diff --git a/src/parsing/standard/base.ts b/src/v1/parsing/standard/base.ts similarity index 97% rename from src/parsing/standard/base.ts rename to src/v1/parsing/standard/base.ts index cd23901a..f0d6a73f 100644 --- a/src/parsing/standard/base.ts +++ b/src/v1/parsing/standard/base.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * @property {object} prediction - Prediction object from HTTP response. diff --git a/src/parsing/standard/boolean.ts b/src/v1/parsing/standard/boolean.ts similarity index 91% rename from src/parsing/standard/boolean.ts rename to src/v1/parsing/standard/boolean.ts index e490b3b7..f96e395b 100644 --- a/src/parsing/standard/boolean.ts +++ b/src/v1/parsing/standard/boolean.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Field } from "./field.js"; export interface FieldConstructor { diff --git a/src/parsing/standard/classification.ts b/src/v1/parsing/standard/classification.ts similarity index 100% rename from src/parsing/standard/classification.ts rename to src/v1/parsing/standard/classification.ts diff --git a/src/parsing/standard/companyRegistration.ts b/src/v1/parsing/standard/companyRegistration.ts similarity index 94% rename from src/parsing/standard/companyRegistration.ts rename to src/v1/parsing/standard/companyRegistration.ts index 69d46223..d11fae3d 100644 --- a/src/parsing/standard/companyRegistration.ts +++ b/src/v1/parsing/standard/companyRegistration.ts @@ -1,6 +1,6 @@ import { Field } from "./field.js"; import { BaseFieldConstructor } from "./base.js"; -import { cleanOutString } from "@/parsing/common/index.js"; +import { cleanOutString } from "@/v1/parsing/common/index.js"; /** * A company registration item. diff --git a/src/parsing/standard/date.ts b/src/v1/parsing/standard/date.ts similarity index 100% rename from src/parsing/standard/date.ts rename to src/v1/parsing/standard/date.ts diff --git a/src/parsing/standard/field.ts b/src/v1/parsing/standard/field.ts similarity index 100% rename from src/parsing/standard/field.ts rename to src/v1/parsing/standard/field.ts diff --git a/src/parsing/standard/index.ts b/src/v1/parsing/standard/index.ts similarity index 100% rename from src/parsing/standard/index.ts rename to src/v1/parsing/standard/index.ts diff --git a/src/parsing/standard/locale.ts b/src/v1/parsing/standard/locale.ts similarity index 100% rename from src/parsing/standard/locale.ts rename to src/v1/parsing/standard/locale.ts diff --git a/src/parsing/standard/paymentDetails.ts b/src/v1/parsing/standard/paymentDetails.ts similarity index 98% rename from src/parsing/standard/paymentDetails.ts rename to src/v1/parsing/standard/paymentDetails.ts index c1c06c46..b56c6fda 100644 --- a/src/parsing/standard/paymentDetails.ts +++ b/src/v1/parsing/standard/paymentDetails.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Field } from "./field.js"; /** diff --git a/src/parsing/standard/position.ts b/src/v1/parsing/standard/position.ts similarity index 96% rename from src/parsing/standard/position.ts rename to src/v1/parsing/standard/position.ts index 23b88fc6..428c6e71 100644 --- a/src/parsing/standard/position.ts +++ b/src/v1/parsing/standard/position.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; export interface PositionFieldConstructor { diff --git a/src/parsing/standard/tax.ts b/src/v1/parsing/standard/tax.ts similarity index 98% rename from src/parsing/standard/tax.ts rename to src/v1/parsing/standard/tax.ts index 25707551..4e63d3ca 100644 --- a/src/parsing/standard/tax.ts +++ b/src/v1/parsing/standard/tax.ts @@ -1,4 +1,4 @@ -import { floatToString, StringDict } from "@/parsing/common/index.js"; +import { floatToString, StringDict } from "@/v1/parsing/common/index.js"; import { Field } from "./field.js"; import { BaseFieldConstructor } from "./base.js"; diff --git a/src/parsing/standard/text.ts b/src/v1/parsing/standard/text.ts similarity index 91% rename from src/parsing/standard/text.ts rename to src/v1/parsing/standard/text.ts index 014f92f7..90881511 100644 --- a/src/parsing/standard/text.ts +++ b/src/v1/parsing/standard/text.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Field } from "./field.js"; export interface FieldConstructor { diff --git a/src/parsing/standard/word.ts b/src/v1/parsing/standard/word.ts similarity index 100% rename from src/parsing/standard/word.ts rename to src/v1/parsing/standard/word.ts diff --git a/src/product/barcodeReader/barcodeReaderV1.ts b/src/v1/product/barcodeReader/barcodeReaderV1.ts similarity index 92% rename from src/product/barcodeReader/barcodeReaderV1.ts rename to src/v1/product/barcodeReader/barcodeReaderV1.ts index 37aceb25..b5e9d022 100644 --- a/src/product/barcodeReader/barcodeReaderV1.ts +++ b/src/v1/product/barcodeReader/barcodeReaderV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { BarcodeReaderV1Document } from "./barcodeReaderV1Document.js"; /** diff --git a/src/product/barcodeReader/barcodeReaderV1Document.ts b/src/v1/product/barcodeReader/barcodeReaderV1Document.ts similarity index 92% rename from src/product/barcodeReader/barcodeReaderV1Document.ts rename to src/v1/product/barcodeReader/barcodeReaderV1Document.ts index b0d9f4d5..d37a647e 100644 --- a/src/product/barcodeReader/barcodeReaderV1Document.ts +++ b/src/v1/product/barcodeReader/barcodeReaderV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; /** * Barcode Reader API version 1.0 document data. diff --git a/src/product/barcodeReader/index.ts b/src/v1/product/barcodeReader/index.ts similarity index 100% rename from src/product/barcodeReader/index.ts rename to src/v1/product/barcodeReader/index.ts diff --git a/src/cliProducts.ts b/src/v1/product/cliProducts.ts similarity index 97% rename from src/cliProducts.ts rename to src/v1/product/cliProducts.ts index 81e286f7..bae6c208 100644 --- a/src/cliProducts.ts +++ b/src/v1/product/cliProducts.ts @@ -4,8 +4,8 @@ // The Map's key is the command name as it will appear on the console. // -import * as product from "@/product/index.js"; -import { Inference, StringDict } from "@/parsing/common/index.js"; +import * as product from "@/v1/product/index.js"; +import { Inference, StringDict } from "@/v1/parsing/common/index.js"; export const COMMAND_GENERATED = "generated"; diff --git a/src/product/cropper/cropperV1.ts b/src/v1/product/cropper/cropperV1.ts similarity index 92% rename from src/product/cropper/cropperV1.ts rename to src/v1/product/cropper/cropperV1.ts index 9d950687..2383a6ce 100644 --- a/src/product/cropper/cropperV1.ts +++ b/src/v1/product/cropper/cropperV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { CropperV1Document } from "./cropperV1Document.js"; import { CropperV1Page } from "./cropperV1Page.js"; diff --git a/src/product/cropper/cropperV1Document.ts b/src/v1/product/cropper/cropperV1Document.ts similarity index 77% rename from src/product/cropper/cropperV1Document.ts rename to src/v1/product/cropper/cropperV1Document.ts index 1044739c..82342acd 100644 --- a/src/product/cropper/cropperV1Document.ts +++ b/src/v1/product/cropper/cropperV1Document.ts @@ -1,4 +1,4 @@ -import { Prediction } from "@/parsing/common/index.js"; +import { Prediction } from "@/v1/parsing/common/index.js"; /** diff --git a/src/product/cropper/cropperV1Page.ts b/src/v1/product/cropper/cropperV1Page.ts similarity index 84% rename from src/product/cropper/cropperV1Page.ts rename to src/v1/product/cropper/cropperV1Page.ts index 2ea83a3c..39b43e6e 100644 --- a/src/product/cropper/cropperV1Page.ts +++ b/src/v1/product/cropper/cropperV1Page.ts @@ -1,5 +1,5 @@ -import { StringDict, cleanOutString } from "@/parsing/common/index.js"; -import { PositionField } from "@/parsing/standard/index.js"; +import { StringDict, cleanOutString } from "@/v1/parsing/common/index.js"; +import { PositionField } from "@/v1/parsing/standard/index.js"; import { CropperV1Document } from "./cropperV1Document.js"; diff --git a/src/product/cropper/index.ts b/src/v1/product/cropper/index.ts similarity index 100% rename from src/product/cropper/index.ts rename to src/v1/product/cropper/index.ts diff --git a/src/product/driverLicense/driverLicenseV1.ts b/src/v1/product/driverLicense/driverLicenseV1.ts similarity index 92% rename from src/product/driverLicense/driverLicenseV1.ts rename to src/v1/product/driverLicense/driverLicenseV1.ts index f47b4b6d..e1c5d52e 100644 --- a/src/product/driverLicense/driverLicenseV1.ts +++ b/src/v1/product/driverLicense/driverLicenseV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { DriverLicenseV1Document } from "./driverLicenseV1Document.js"; /** diff --git a/src/product/driverLicense/driverLicenseV1Document.ts b/src/v1/product/driverLicense/driverLicenseV1Document.ts similarity index 96% rename from src/product/driverLicense/driverLicenseV1Document.ts rename to src/v1/product/driverLicense/driverLicenseV1Document.ts index 2620c08b..8a75b4f3 100644 --- a/src/product/driverLicense/driverLicenseV1Document.ts +++ b/src/v1/product/driverLicense/driverLicenseV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { DateField, StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { DateField, StringField } from "@/v1/parsing/standard/index.js"; /** * Driver License API version 1.0 document data. diff --git a/src/product/driverLicense/index.ts b/src/v1/product/driverLicense/index.ts similarity index 100% rename from src/product/driverLicense/index.ts rename to src/v1/product/driverLicense/index.ts diff --git a/src/product/financialDocument/financialDocumentV1.ts b/src/v1/product/financialDocument/financialDocumentV1.ts similarity index 93% rename from src/product/financialDocument/financialDocumentV1.ts rename to src/v1/product/financialDocument/financialDocumentV1.ts index 0e9364b6..b8216510 100644 --- a/src/product/financialDocument/financialDocumentV1.ts +++ b/src/v1/product/financialDocument/financialDocumentV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { FinancialDocumentV1Document } from "./financialDocumentV1Document.js"; /** diff --git a/src/product/financialDocument/financialDocumentV1Document.ts b/src/v1/product/financialDocument/financialDocumentV1Document.ts similarity index 99% rename from src/product/financialDocument/financialDocumentV1Document.ts rename to src/v1/product/financialDocument/financialDocumentV1Document.ts index c4224779..91e0e88f 100644 --- a/src/product/financialDocument/financialDocumentV1Document.ts +++ b/src/v1/product/financialDocument/financialDocumentV1Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem.js"; import { AddressField, @@ -14,7 +14,7 @@ import { PaymentDetailsField, StringField, Taxes, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * Financial Document API version 1.14 document data. diff --git a/src/product/financialDocument/financialDocumentV1LineItem.ts b/src/v1/product/financialDocument/financialDocumentV1LineItem.ts similarity index 97% rename from src/product/financialDocument/financialDocumentV1LineItem.ts rename to src/v1/product/financialDocument/financialDocumentV1LineItem.ts index 16c99c67..1ec5a2fc 100644 --- a/src/product/financialDocument/financialDocumentV1LineItem.ts +++ b/src/v1/product/financialDocument/financialDocumentV1LineItem.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/financialDocument/index.ts b/src/v1/product/financialDocument/index.ts similarity index 100% rename from src/product/financialDocument/index.ts rename to src/v1/product/financialDocument/index.ts diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts similarity index 93% rename from src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts rename to src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts index cf017376..d38530b9 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV1.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { BankAccountDetailsV1Document } from "./bankAccountDetailsV1Document.js"; /** diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts similarity index 91% rename from src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts rename to src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts index 47a73b34..310af901 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; /** * Bank Account Details API version 1.0 document data. diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts similarity index 93% rename from src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts rename to src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts index 8358ecdf..2eb6a721 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { BankAccountDetailsV2Document } from "./bankAccountDetailsV2Document.js"; /** diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts similarity index 97% rename from src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts rename to src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts index 0659716b..a2096a17 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts similarity index 93% rename from src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts rename to src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts index d26ba0d8..c96053be 100644 --- a/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts @@ -2,9 +2,9 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { BankAccountDetailsV2Bban } from "./bankAccountDetailsV2Bban.js"; -import { StringField } from "@/parsing/standard/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; /** * Bank Account Details API version 2.0 document data. diff --git a/src/product/fr/bankAccountDetails/index.ts b/src/v1/product/fr/bankAccountDetails/index.ts similarity index 100% rename from src/product/fr/bankAccountDetails/index.ts rename to src/v1/product/fr/bankAccountDetails/index.ts diff --git a/src/product/fr/carteGrise/carteGriseV1.ts b/src/v1/product/fr/carteGrise/carteGriseV1.ts similarity index 92% rename from src/product/fr/carteGrise/carteGriseV1.ts rename to src/v1/product/fr/carteGrise/carteGriseV1.ts index 29d6425b..b3b24051 100644 --- a/src/product/fr/carteGrise/carteGriseV1.ts +++ b/src/v1/product/fr/carteGrise/carteGriseV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { CarteGriseV1Document } from "./carteGriseV1Document.js"; /** diff --git a/src/product/fr/carteGrise/carteGriseV1Document.ts b/src/v1/product/fr/carteGrise/carteGriseV1Document.ts similarity index 98% rename from src/product/fr/carteGrise/carteGriseV1Document.ts rename to src/v1/product/fr/carteGrise/carteGriseV1Document.ts index 0b3e9683..421079ff 100644 --- a/src/product/fr/carteGrise/carteGriseV1Document.ts +++ b/src/v1/product/fr/carteGrise/carteGriseV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { DateField, StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { DateField, StringField } from "@/v1/parsing/standard/index.js"; /** * Carte Grise API version 1.1 document data. diff --git a/src/product/fr/carteGrise/index.ts b/src/v1/product/fr/carteGrise/index.ts similarity index 100% rename from src/product/fr/carteGrise/index.ts rename to src/v1/product/fr/carteGrise/index.ts diff --git a/src/product/fr/energyBill/energyBillV1.ts b/src/v1/product/fr/energyBill/energyBillV1.ts similarity index 92% rename from src/product/fr/energyBill/energyBillV1.ts rename to src/v1/product/fr/energyBill/energyBillV1.ts index 2370f834..aa65f886 100644 --- a/src/product/fr/energyBill/energyBillV1.ts +++ b/src/v1/product/fr/energyBill/energyBillV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { EnergyBillV1Document } from "./energyBillV1Document.js"; /** diff --git a/src/product/fr/energyBill/energyBillV1Document.ts b/src/v1/product/fr/energyBill/energyBillV1Document.ts similarity index 98% rename from src/product/fr/energyBill/energyBillV1Document.ts rename to src/v1/product/fr/energyBill/energyBillV1Document.ts index e2c9a1cb..3431c38b 100644 --- a/src/product/fr/energyBill/energyBillV1Document.ts +++ b/src/v1/product/fr/energyBill/energyBillV1Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { EnergyBillV1EnergySupplier } from "./energyBillV1EnergySupplier.js"; import { EnergyBillV1EnergyConsumer } from "./energyBillV1EnergyConsumer.js"; import { EnergyBillV1Subscription } from "./energyBillV1Subscription.js"; @@ -13,7 +13,7 @@ import { AmountField, DateField, StringField, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * Energy Bill API version 1.2 document data. diff --git a/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts b/src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts similarity index 96% rename from src/product/fr/energyBill/energyBillV1EnergyConsumer.ts rename to src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts index 24e934ba..f20acbb8 100644 --- a/src/product/fr/energyBill/energyBillV1EnergyConsumer.ts +++ b/src/v1/product/fr/energyBill/energyBillV1EnergyConsumer.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/energyBill/energyBillV1EnergySupplier.ts b/src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts similarity index 96% rename from src/product/fr/energyBill/energyBillV1EnergySupplier.ts rename to src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts index 2b400e71..76961d9f 100644 --- a/src/product/fr/energyBill/energyBillV1EnergySupplier.ts +++ b/src/v1/product/fr/energyBill/energyBillV1EnergySupplier.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/energyBill/energyBillV1EnergyUsage.ts b/src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts similarity index 97% rename from src/product/fr/energyBill/energyBillV1EnergyUsage.ts rename to src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts index afaf10a4..f87d67fd 100644 --- a/src/product/fr/energyBill/energyBillV1EnergyUsage.ts +++ b/src/v1/product/fr/energyBill/energyBillV1EnergyUsage.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/energyBill/energyBillV1MeterDetail.ts b/src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts similarity index 96% rename from src/product/fr/energyBill/energyBillV1MeterDetail.ts rename to src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts index 2458b68a..50f4ec4a 100644 --- a/src/product/fr/energyBill/energyBillV1MeterDetail.ts +++ b/src/v1/product/fr/energyBill/energyBillV1MeterDetail.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/energyBill/energyBillV1Subscription.ts b/src/v1/product/fr/energyBill/energyBillV1Subscription.ts similarity index 96% rename from src/product/fr/energyBill/energyBillV1Subscription.ts rename to src/v1/product/fr/energyBill/energyBillV1Subscription.ts index 7161ddd2..631c5c0f 100644 --- a/src/product/fr/energyBill/energyBillV1Subscription.ts +++ b/src/v1/product/fr/energyBill/energyBillV1Subscription.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts b/src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts similarity index 96% rename from src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts rename to src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts index ce6e0854..f6c8393b 100644 --- a/src/product/fr/energyBill/energyBillV1TaxesAndContribution.ts +++ b/src/v1/product/fr/energyBill/energyBillV1TaxesAndContribution.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/energyBill/index.ts b/src/v1/product/fr/energyBill/index.ts similarity index 100% rename from src/product/fr/energyBill/index.ts rename to src/v1/product/fr/energyBill/index.ts diff --git a/src/product/fr/healthCard/healthCardV1.ts b/src/v1/product/fr/healthCard/healthCardV1.ts similarity index 92% rename from src/product/fr/healthCard/healthCardV1.ts rename to src/v1/product/fr/healthCard/healthCardV1.ts index cf9651ed..e89f8840 100644 --- a/src/product/fr/healthCard/healthCardV1.ts +++ b/src/v1/product/fr/healthCard/healthCardV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { HealthCardV1Document } from "./healthCardV1Document.js"; /** diff --git a/src/product/fr/healthCard/healthCardV1Document.ts b/src/v1/product/fr/healthCard/healthCardV1Document.ts similarity index 93% rename from src/product/fr/healthCard/healthCardV1Document.ts rename to src/v1/product/fr/healthCard/healthCardV1Document.ts index a9f4b475..17f0a549 100644 --- a/src/product/fr/healthCard/healthCardV1Document.ts +++ b/src/v1/product/fr/healthCard/healthCardV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { DateField, StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { DateField, StringField } from "@/v1/parsing/standard/index.js"; /** * Health Card API version 1.0 document data. diff --git a/src/product/fr/healthCard/index.ts b/src/v1/product/fr/healthCard/index.ts similarity index 100% rename from src/product/fr/healthCard/index.ts rename to src/v1/product/fr/healthCard/index.ts diff --git a/src/product/fr/idCard/idCardV1.ts b/src/v1/product/fr/idCard/idCardV1.ts similarity index 92% rename from src/product/fr/idCard/idCardV1.ts rename to src/v1/product/fr/idCard/idCardV1.ts index 1c5385b0..ef65fcd0 100644 --- a/src/product/fr/idCard/idCardV1.ts +++ b/src/v1/product/fr/idCard/idCardV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { IdCardV1Document } from "./idCardV1Document.js"; import { IdCardV1Page } from "./idCardV1Page.js"; diff --git a/src/product/fr/idCard/idCardV1Document.ts b/src/v1/product/fr/idCard/idCardV1Document.ts similarity index 96% rename from src/product/fr/idCard/idCardV1Document.ts rename to src/v1/product/fr/idCard/idCardV1Document.ts index e4a411e3..a2ab1e3e 100644 --- a/src/product/fr/idCard/idCardV1Document.ts +++ b/src/v1/product/fr/idCard/idCardV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { DateField, StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { DateField, StringField } from "@/v1/parsing/standard/index.js"; /** * Carte Nationale d'Identité API version 1.1 document data. diff --git a/src/product/fr/idCard/idCardV1Page.ts b/src/v1/product/fr/idCard/idCardV1Page.ts similarity index 81% rename from src/product/fr/idCard/idCardV1Page.ts rename to src/v1/product/fr/idCard/idCardV1Page.ts index 25ecc5be..2f12718e 100644 --- a/src/product/fr/idCard/idCardV1Page.ts +++ b/src/v1/product/fr/idCard/idCardV1Page.ts @@ -1,5 +1,5 @@ -import { StringDict, cleanOutString } from "@/parsing/common/index.js"; -import { ClassificationField } from "@/parsing/standard/index.js"; +import { StringDict, cleanOutString } from "@/v1/parsing/common/index.js"; +import { ClassificationField } from "@/v1/parsing/standard/index.js"; import { IdCardV1Document } from "./idCardV1Document.js"; /** diff --git a/src/product/fr/idCard/idCardV2.ts b/src/v1/product/fr/idCard/idCardV2.ts similarity index 92% rename from src/product/fr/idCard/idCardV2.ts rename to src/v1/product/fr/idCard/idCardV2.ts index 6e8b0319..3ebfdfe8 100644 --- a/src/product/fr/idCard/idCardV2.ts +++ b/src/v1/product/fr/idCard/idCardV2.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { IdCardV2Document } from "./idCardV2Document.js"; import { IdCardV2Page } from "./idCardV2Page.js"; diff --git a/src/product/fr/idCard/idCardV2Document.ts b/src/v1/product/fr/idCard/idCardV2Document.ts similarity index 97% rename from src/product/fr/idCard/idCardV2Document.ts rename to src/v1/product/fr/idCard/idCardV2Document.ts index 0ccf3ec8..df8e3c6d 100644 --- a/src/product/fr/idCard/idCardV2Document.ts +++ b/src/v1/product/fr/idCard/idCardV2Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { DateField, StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { DateField, StringField } from "@/v1/parsing/standard/index.js"; /** * Carte Nationale d'Identité API version 2.0 document data. diff --git a/src/product/fr/idCard/idCardV2Page.ts b/src/v1/product/fr/idCard/idCardV2Page.ts similarity index 85% rename from src/product/fr/idCard/idCardV2Page.ts rename to src/v1/product/fr/idCard/idCardV2Page.ts index cd0ec833..5ad0bcb5 100644 --- a/src/product/fr/idCard/idCardV2Page.ts +++ b/src/v1/product/fr/idCard/idCardV2Page.ts @@ -1,5 +1,5 @@ -import { StringDict, cleanOutString } from "@/parsing/common/index.js"; -import { ClassificationField } from "@/parsing/standard/index.js"; +import { StringDict, cleanOutString } from "@/v1/parsing/common/index.js"; +import { ClassificationField } from "@/v1/parsing/standard/index.js"; import { IdCardV2Document } from "./idCardV2Document.js"; /** diff --git a/src/product/fr/idCard/index.ts b/src/v1/product/fr/idCard/index.ts similarity index 100% rename from src/product/fr/idCard/index.ts rename to src/v1/product/fr/idCard/index.ts diff --git a/src/product/fr/index.ts b/src/v1/product/fr/index.ts similarity index 58% rename from src/product/fr/index.ts rename to src/v1/product/fr/index.ts index 2d9f4949..da4a208c 100644 --- a/src/product/fr/index.ts +++ b/src/v1/product/fr/index.ts @@ -7,3 +7,10 @@ export { IdCardV2 } from "./idCard/index.js"; export { PayslipV2 } from "./payslip/index.js"; export { PayslipV3 } from "./payslip/index.js"; export { CarteGriseV1 } from "./carteGrise/index.js"; + +// not sure if we want to export these -- advanced users can import them directly +export * as bankAccountDetails from "./bankAccountDetails/index.js"; +export * as energyBill from "./energyBill/index.js"; +export * as healthCard from "./healthCard/index.js"; +export * as idCard from "./idCard/index.js"; +export * as payslip from "./payslip/index.js"; diff --git a/src/product/fr/payslip/index.ts b/src/v1/product/fr/payslip/index.ts similarity index 100% rename from src/product/fr/payslip/index.ts rename to src/v1/product/fr/payslip/index.ts diff --git a/src/product/fr/payslip/payslipV2.ts b/src/v1/product/fr/payslip/payslipV2.ts similarity index 92% rename from src/product/fr/payslip/payslipV2.ts rename to src/v1/product/fr/payslip/payslipV2.ts index 2ae4d0f0..c2a56747 100644 --- a/src/product/fr/payslip/payslipV2.ts +++ b/src/v1/product/fr/payslip/payslipV2.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { PayslipV2Document } from "./payslipV2Document.js"; /** diff --git a/src/product/fr/payslip/payslipV2BankAccountDetail.ts b/src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts similarity index 96% rename from src/product/fr/payslip/payslipV2BankAccountDetail.ts rename to src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts index 0fba12d1..2242d3ba 100644 --- a/src/product/fr/payslip/payslipV2BankAccountDetail.ts +++ b/src/v1/product/fr/payslip/payslipV2BankAccountDetail.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2Document.ts b/src/v1/product/fr/payslip/payslipV2Document.ts similarity index 98% rename from src/product/fr/payslip/payslipV2Document.ts rename to src/v1/product/fr/payslip/payslipV2Document.ts index 3750c764..06f27df6 100644 --- a/src/product/fr/payslip/payslipV2Document.ts +++ b/src/v1/product/fr/payslip/payslipV2Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { PayslipV2Employee } from "./payslipV2Employee.js"; import { PayslipV2Employer } from "./payslipV2Employer.js"; import { PayslipV2BankAccountDetail } from "./payslipV2BankAccountDetail.js"; diff --git a/src/product/fr/payslip/payslipV2Employee.ts b/src/v1/product/fr/payslip/payslipV2Employee.ts similarity index 98% rename from src/product/fr/payslip/payslipV2Employee.ts rename to src/v1/product/fr/payslip/payslipV2Employee.ts index 12fe4384..c4838723 100644 --- a/src/product/fr/payslip/payslipV2Employee.ts +++ b/src/v1/product/fr/payslip/payslipV2Employee.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2Employer.ts b/src/v1/product/fr/payslip/payslipV2Employer.ts similarity index 97% rename from src/product/fr/payslip/payslipV2Employer.ts rename to src/v1/product/fr/payslip/payslipV2Employer.ts index de778ac2..69e9d580 100644 --- a/src/product/fr/payslip/payslipV2Employer.ts +++ b/src/v1/product/fr/payslip/payslipV2Employer.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2Employment.ts b/src/v1/product/fr/payslip/payslipV2Employment.ts similarity index 96% rename from src/product/fr/payslip/payslipV2Employment.ts rename to src/v1/product/fr/payslip/payslipV2Employment.ts index fd2a656a..1f2b0fe1 100644 --- a/src/product/fr/payslip/payslipV2Employment.ts +++ b/src/v1/product/fr/payslip/payslipV2Employment.ts @@ -1,5 +1,5 @@ -import { floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2PayDetail.ts b/src/v1/product/fr/payslip/payslipV2PayDetail.ts similarity index 98% rename from src/product/fr/payslip/payslipV2PayDetail.ts rename to src/v1/product/fr/payslip/payslipV2PayDetail.ts index 6012131b..56add1ef 100644 --- a/src/product/fr/payslip/payslipV2PayDetail.ts +++ b/src/v1/product/fr/payslip/payslipV2PayDetail.ts @@ -1,5 +1,5 @@ -import { floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2PayPeriod.ts b/src/v1/product/fr/payslip/payslipV2PayPeriod.ts similarity index 97% rename from src/product/fr/payslip/payslipV2PayPeriod.ts rename to src/v1/product/fr/payslip/payslipV2PayPeriod.ts index 1e1eb093..602946c6 100644 --- a/src/product/fr/payslip/payslipV2PayPeriod.ts +++ b/src/v1/product/fr/payslip/payslipV2PayPeriod.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2Pto.ts b/src/v1/product/fr/payslip/payslipV2Pto.ts similarity index 96% rename from src/product/fr/payslip/payslipV2Pto.ts rename to src/v1/product/fr/payslip/payslipV2Pto.ts index b6a41d2c..d31fd584 100644 --- a/src/product/fr/payslip/payslipV2Pto.ts +++ b/src/v1/product/fr/payslip/payslipV2Pto.ts @@ -1,5 +1,5 @@ -import { floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV2SalaryDetail.ts b/src/v1/product/fr/payslip/payslipV2SalaryDetail.ts similarity index 95% rename from src/product/fr/payslip/payslipV2SalaryDetail.ts rename to src/v1/product/fr/payslip/payslipV2SalaryDetail.ts index c15a29eb..5a231117 100644 --- a/src/product/fr/payslip/payslipV2SalaryDetail.ts +++ b/src/v1/product/fr/payslip/payslipV2SalaryDetail.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3.ts b/src/v1/product/fr/payslip/payslipV3.ts similarity index 92% rename from src/product/fr/payslip/payslipV3.ts rename to src/v1/product/fr/payslip/payslipV3.ts index 04bc2af0..4a72be11 100644 --- a/src/product/fr/payslip/payslipV3.ts +++ b/src/v1/product/fr/payslip/payslipV3.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { PayslipV3Document } from "./payslipV3Document.js"; /** diff --git a/src/product/fr/payslip/payslipV3BankAccountDetail.ts b/src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts similarity index 96% rename from src/product/fr/payslip/payslipV3BankAccountDetail.ts rename to src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts index e79fa690..12c902ef 100644 --- a/src/product/fr/payslip/payslipV3BankAccountDetail.ts +++ b/src/v1/product/fr/payslip/payslipV3BankAccountDetail.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3Document.ts b/src/v1/product/fr/payslip/payslipV3Document.ts similarity index 99% rename from src/product/fr/payslip/payslipV3Document.ts rename to src/v1/product/fr/payslip/payslipV3Document.ts index cae6d91c..babf3276 100644 --- a/src/product/fr/payslip/payslipV3Document.ts +++ b/src/v1/product/fr/payslip/payslipV3Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { PayslipV3PayPeriod } from "./payslipV3PayPeriod.js"; import { PayslipV3Employee } from "./payslipV3Employee.js"; import { PayslipV3Employer } from "./payslipV3Employer.js"; diff --git a/src/product/fr/payslip/payslipV3Employee.ts b/src/v1/product/fr/payslip/payslipV3Employee.ts similarity index 98% rename from src/product/fr/payslip/payslipV3Employee.ts rename to src/v1/product/fr/payslip/payslipV3Employee.ts index 7037503d..284930d8 100644 --- a/src/product/fr/payslip/payslipV3Employee.ts +++ b/src/v1/product/fr/payslip/payslipV3Employee.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3Employer.ts b/src/v1/product/fr/payslip/payslipV3Employer.ts similarity index 97% rename from src/product/fr/payslip/payslipV3Employer.ts rename to src/v1/product/fr/payslip/payslipV3Employer.ts index 8d5e551d..b682f3e5 100644 --- a/src/product/fr/payslip/payslipV3Employer.ts +++ b/src/v1/product/fr/payslip/payslipV3Employer.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3Employment.ts b/src/v1/product/fr/payslip/payslipV3Employment.ts similarity index 98% rename from src/product/fr/payslip/payslipV3Employment.ts rename to src/v1/product/fr/payslip/payslipV3Employment.ts index 09230310..5fd91d45 100644 --- a/src/product/fr/payslip/payslipV3Employment.ts +++ b/src/v1/product/fr/payslip/payslipV3Employment.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3PaidTimeOff.ts b/src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts similarity index 96% rename from src/product/fr/payslip/payslipV3PaidTimeOff.ts rename to src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts index 82a49910..c537e820 100644 --- a/src/product/fr/payslip/payslipV3PaidTimeOff.ts +++ b/src/v1/product/fr/payslip/payslipV3PaidTimeOff.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3PayDetail.ts b/src/v1/product/fr/payslip/payslipV3PayDetail.ts similarity index 98% rename from src/product/fr/payslip/payslipV3PayDetail.ts rename to src/v1/product/fr/payslip/payslipV3PayDetail.ts index 1e3f5777..2d1d66c4 100644 --- a/src/product/fr/payslip/payslipV3PayDetail.ts +++ b/src/v1/product/fr/payslip/payslipV3PayDetail.ts @@ -1,5 +1,5 @@ -import { floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3PayPeriod.ts b/src/v1/product/fr/payslip/payslipV3PayPeriod.ts similarity index 97% rename from src/product/fr/payslip/payslipV3PayPeriod.ts rename to src/v1/product/fr/payslip/payslipV3PayPeriod.ts index 0feb3465..950af3e4 100644 --- a/src/product/fr/payslip/payslipV3PayPeriod.ts +++ b/src/v1/product/fr/payslip/payslipV3PayPeriod.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/fr/payslip/payslipV3SalaryDetail.ts b/src/v1/product/fr/payslip/payslipV3SalaryDetail.ts similarity index 96% rename from src/product/fr/payslip/payslipV3SalaryDetail.ts rename to src/v1/product/fr/payslip/payslipV3SalaryDetail.ts index 37927c77..bbc0e948 100644 --- a/src/product/fr/payslip/payslipV3SalaryDetail.ts +++ b/src/v1/product/fr/payslip/payslipV3SalaryDetail.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/generated/generatedV1.ts b/src/v1/product/generated/generatedV1.ts similarity index 92% rename from src/product/generated/generatedV1.ts rename to src/v1/product/generated/generatedV1.ts index 0af4a461..4e3cb522 100644 --- a/src/product/generated/generatedV1.ts +++ b/src/v1/product/generated/generatedV1.ts @@ -1,4 +1,4 @@ -import { Inference, Page, StringDict } from "@/parsing/common/index.js"; +import { Inference, Page, StringDict } from "@/v1/parsing/common/index.js"; import { GeneratedV1Document } from "./generatedV1Document.js"; import { GeneratedV1Page } from "./generatedV1Page.js"; diff --git a/src/product/generated/generatedV1Document.ts b/src/v1/product/generated/generatedV1Document.ts similarity index 86% rename from src/product/generated/generatedV1Document.ts rename to src/v1/product/generated/generatedV1Document.ts index 80a00bff..028d7d17 100644 --- a/src/product/generated/generatedV1Document.ts +++ b/src/v1/product/generated/generatedV1Document.ts @@ -1,6 +1,6 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; -import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "@/parsing/generated/index.js"; -import { StringField } from "@/parsing/standard/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "@/v1/parsing/generated/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; import { GeneratedV1Prediction } from "./generatedV1Prediction.js"; /** diff --git a/src/product/generated/generatedV1Page.ts b/src/v1/product/generated/generatedV1Page.ts similarity index 87% rename from src/product/generated/generatedV1Page.ts rename to src/v1/product/generated/generatedV1Page.ts index 77c1ad0a..8116307c 100644 --- a/src/product/generated/generatedV1Page.ts +++ b/src/v1/product/generated/generatedV1Page.ts @@ -1,6 +1,6 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; -import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "@/parsing/generated/index.js"; -import { StringField } from "@/parsing/standard/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { GeneratedListField, GeneratedObjectField, isGeneratedObject } from "@/v1/parsing/generated/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; import { GeneratedV1Prediction } from "./generatedV1Prediction.js"; /** diff --git a/src/product/generated/generatedV1Prediction.ts b/src/v1/product/generated/generatedV1Prediction.ts similarity index 91% rename from src/product/generated/generatedV1Prediction.ts rename to src/v1/product/generated/generatedV1Prediction.ts index 876f5df7..925bd503 100644 --- a/src/product/generated/generatedV1Prediction.ts +++ b/src/v1/product/generated/generatedV1Prediction.ts @@ -1,6 +1,6 @@ -import { Prediction, cleanOutString } from "@/parsing/common/index.js"; -import { GeneratedListField, GeneratedObjectField } from "@/parsing/generated/index.js"; -import { StringField } from "@/parsing/standard/index.js"; +import { Prediction, cleanOutString } from "@/v1/parsing/common/index.js"; +import { GeneratedListField, GeneratedObjectField } from "@/v1/parsing/generated/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; export class GeneratedV1Prediction implements Prediction { diff --git a/src/product/generated/index.ts b/src/v1/product/generated/index.ts similarity index 100% rename from src/product/generated/index.ts rename to src/v1/product/generated/index.ts diff --git a/src/v1/product/ind/index.ts b/src/v1/product/ind/index.ts new file mode 100644 index 00000000..43cc766a --- /dev/null +++ b/src/v1/product/ind/index.ts @@ -0,0 +1,4 @@ +export { IndianPassportV1 } from "./indianPassport/index.js"; + +// not sure if we want to export these -- advanced users can import them directly +export * as indianPassport from "./indianPassport/index.js"; diff --git a/src/product/ind/indianPassport/index.ts b/src/v1/product/ind/indianPassport/index.ts similarity index 100% rename from src/product/ind/indianPassport/index.ts rename to src/v1/product/ind/indianPassport/index.ts diff --git a/src/product/ind/indianPassport/indianPassportV1.ts b/src/v1/product/ind/indianPassport/indianPassportV1.ts similarity index 92% rename from src/product/ind/indianPassport/indianPassportV1.ts rename to src/v1/product/ind/indianPassport/indianPassportV1.ts index 1bba02fb..a1d73c05 100644 --- a/src/product/ind/indianPassport/indianPassportV1.ts +++ b/src/v1/product/ind/indianPassport/indianPassportV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { IndianPassportV1Document } from "./indianPassportV1Document.js"; /** diff --git a/src/product/ind/indianPassport/indianPassportV1Document.ts b/src/v1/product/ind/indianPassport/indianPassportV1Document.ts similarity index 98% rename from src/product/ind/indianPassport/indianPassportV1Document.ts rename to src/v1/product/ind/indianPassport/indianPassportV1Document.ts index 97f9ca5a..b5559503 100644 --- a/src/product/ind/indianPassport/indianPassportV1Document.ts +++ b/src/v1/product/ind/indianPassport/indianPassportV1Document.ts @@ -2,12 +2,12 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { ClassificationField, DateField, StringField, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * Passport - India API version 1.2 document data. diff --git a/src/product/index.ts b/src/v1/product/index.ts similarity index 51% rename from src/product/index.ts rename to src/v1/product/index.ts index faf6b179..ac80c597 100644 --- a/src/product/index.ts +++ b/src/v1/product/index.ts @@ -13,3 +13,17 @@ export { MultiReceiptsDetectorV1 } from "./multiReceiptsDetector/index.js"; export { PassportV1 } from "./passport/index.js"; export { ReceiptV5 } from "./receipt/index.js"; export { ResumeV1 } from "./resume/index.js"; + +// not sure if we want to export these -- advanced users can import them directly +export * as barcodeReader from "./barcodeReader/index.js"; +export * as cropper from "./cropper/index.js"; +export * as driverLicense from "./driverLicense/index.js"; +export * as financialDocument from "./financialDocument/index.js"; +export * as generated from "./generated/index.js"; +export * as internationalId from "./internationalId/index.js"; +export * as invoice from "./invoice/index.js"; +export * as invoiceSplitter from "./invoiceSplitter/index.js"; +export * as multiReceiptsDetector from "./multiReceiptsDetector/index.js"; +export * as passport from "./passport/index.js"; +export * as receipt from "./receipt/index.js"; +export * as resume from "./resume/index.js"; diff --git a/src/product/internationalId/index.ts b/src/v1/product/internationalId/index.ts similarity index 100% rename from src/product/internationalId/index.ts rename to src/v1/product/internationalId/index.ts diff --git a/src/product/internationalId/internationalIdV2.ts b/src/v1/product/internationalId/internationalIdV2.ts similarity index 93% rename from src/product/internationalId/internationalIdV2.ts rename to src/v1/product/internationalId/internationalIdV2.ts index a3941911..05dc1512 100644 --- a/src/product/internationalId/internationalIdV2.ts +++ b/src/v1/product/internationalId/internationalIdV2.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { InternationalIdV2Document } from "./internationalIdV2Document.js"; /** diff --git a/src/product/internationalId/internationalIdV2Document.ts b/src/v1/product/internationalId/internationalIdV2Document.ts similarity index 98% rename from src/product/internationalId/internationalIdV2Document.ts rename to src/v1/product/internationalId/internationalIdV2Document.ts index f9791400..531d41cd 100644 --- a/src/product/internationalId/internationalIdV2Document.ts +++ b/src/v1/product/internationalId/internationalIdV2Document.ts @@ -2,12 +2,12 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { ClassificationField, DateField, StringField, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * International ID API version 2.2 document data. diff --git a/src/product/invoice/index.ts b/src/v1/product/invoice/index.ts similarity index 100% rename from src/product/invoice/index.ts rename to src/v1/product/invoice/index.ts diff --git a/src/product/invoice/invoiceV4.ts b/src/v1/product/invoice/invoiceV4.ts similarity index 92% rename from src/product/invoice/invoiceV4.ts rename to src/v1/product/invoice/invoiceV4.ts index fd5e6c39..2d3cb4df 100644 --- a/src/product/invoice/invoiceV4.ts +++ b/src/v1/product/invoice/invoiceV4.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { InvoiceV4Document } from "./invoiceV4Document.js"; /** diff --git a/src/product/invoice/invoiceV4Document.ts b/src/v1/product/invoice/invoiceV4Document.ts similarity index 99% rename from src/product/invoice/invoiceV4Document.ts rename to src/v1/product/invoice/invoiceV4Document.ts index 55b7e4e8..4232f33f 100644 --- a/src/product/invoice/invoiceV4Document.ts +++ b/src/v1/product/invoice/invoiceV4Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { InvoiceV4LineItem } from "./invoiceV4LineItem.js"; import { AddressField, @@ -14,7 +14,7 @@ import { PaymentDetailsField, StringField, Taxes, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * Invoice API version 4.11 document data. diff --git a/src/product/invoice/invoiceV4LineItem.ts b/src/v1/product/invoice/invoiceV4LineItem.ts similarity index 97% rename from src/product/invoice/invoiceV4LineItem.ts rename to src/v1/product/invoice/invoiceV4LineItem.ts index 5cebf2a6..0dd06f33 100644 --- a/src/product/invoice/invoiceV4LineItem.ts +++ b/src/v1/product/invoice/invoiceV4LineItem.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/invoiceSplitter/index.ts b/src/v1/product/invoiceSplitter/index.ts similarity index 100% rename from src/product/invoiceSplitter/index.ts rename to src/v1/product/invoiceSplitter/index.ts diff --git a/src/product/invoiceSplitter/invoiceSplitterV1.ts b/src/v1/product/invoiceSplitter/invoiceSplitterV1.ts similarity index 93% rename from src/product/invoiceSplitter/invoiceSplitterV1.ts rename to src/v1/product/invoiceSplitter/invoiceSplitterV1.ts index 60e09985..97080e19 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1.ts +++ b/src/v1/product/invoiceSplitter/invoiceSplitterV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { InvoiceSplitterV1Document } from "./invoiceSplitterV1Document.js"; /** diff --git a/src/product/invoiceSplitter/invoiceSplitterV1Document.ts b/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts similarity index 97% rename from src/product/invoiceSplitter/invoiceSplitterV1Document.ts rename to src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts index d9374c82..a06ecec2 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1Document.ts +++ b/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { InvoiceSplitterV1InvoicePageGroup } from "./invoiceSplitterV1InvoicePageGroup.js"; diff --git a/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts b/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts similarity index 96% rename from src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts rename to src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts index 4eb1de28..d3f72552 100644 --- a/src/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts +++ b/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/multiReceiptsDetector/index.ts b/src/v1/product/multiReceiptsDetector/index.ts similarity index 100% rename from src/product/multiReceiptsDetector/index.ts rename to src/v1/product/multiReceiptsDetector/index.ts diff --git a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts similarity index 93% rename from src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts rename to src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts index 28e39d03..0433d9a0 100644 --- a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts +++ b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { MultiReceiptsDetectorV1Document } from "./multiReceiptsDetectorV1Document.js"; /** diff --git a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts similarity index 89% rename from src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts rename to src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts index 402bb9fc..cdd10464 100644 --- a/src/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts +++ b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { PositionField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { PositionField } from "@/v1/parsing/standard/index.js"; /** * Multi Receipts Detector API version 1.1 document data. diff --git a/src/product/passport/index.ts b/src/v1/product/passport/index.ts similarity index 100% rename from src/product/passport/index.ts rename to src/v1/product/passport/index.ts diff --git a/src/product/passport/passportV1.ts b/src/v1/product/passport/passportV1.ts similarity index 92% rename from src/product/passport/passportV1.ts rename to src/v1/product/passport/passportV1.ts index d8df9b93..f3c91647 100644 --- a/src/product/passport/passportV1.ts +++ b/src/v1/product/passport/passportV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { PassportV1Document } from "./passportV1Document.js"; /** diff --git a/src/product/passport/passportV1Document.ts b/src/v1/product/passport/passportV1Document.ts similarity index 96% rename from src/product/passport/passportV1Document.ts rename to src/v1/product/passport/passportV1Document.ts index 88781bf1..d809c164 100644 --- a/src/product/passport/passportV1Document.ts +++ b/src/v1/product/passport/passportV1Document.ts @@ -2,8 +2,8 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; -import { DateField, StringField } from "@/parsing/standard/index.js"; +} from "@/v1/parsing/common/index.js"; +import { DateField, StringField } from "@/v1/parsing/standard/index.js"; /** * Passport API version 1.1 document data. diff --git a/src/product/receipt/index.ts b/src/v1/product/receipt/index.ts similarity index 100% rename from src/product/receipt/index.ts rename to src/v1/product/receipt/index.ts diff --git a/src/product/receipt/receiptV5.ts b/src/v1/product/receipt/receiptV5.ts similarity index 92% rename from src/product/receipt/receiptV5.ts rename to src/v1/product/receipt/receiptV5.ts index be42ddd9..292ac397 100644 --- a/src/product/receipt/receiptV5.ts +++ b/src/v1/product/receipt/receiptV5.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { ReceiptV5Document } from "./receiptV5Document.js"; /** diff --git a/src/product/receipt/receiptV5Document.ts b/src/v1/product/receipt/receiptV5Document.ts similarity index 98% rename from src/product/receipt/receiptV5Document.ts rename to src/v1/product/receipt/receiptV5Document.ts index 457912ea..8bdbb411 100644 --- a/src/product/receipt/receiptV5Document.ts +++ b/src/v1/product/receipt/receiptV5Document.ts @@ -2,7 +2,7 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { ReceiptV5LineItem } from "./receiptV5LineItem.js"; import { AmountField, @@ -12,7 +12,7 @@ import { LocaleField, StringField, Taxes, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * Receipt API version 5.4 document data. diff --git a/src/product/receipt/receiptV5LineItem.ts b/src/v1/product/receipt/receiptV5LineItem.ts similarity index 95% rename from src/product/receipt/receiptV5LineItem.ts rename to src/v1/product/receipt/receiptV5LineItem.ts index 1598740a..6e1ebffb 100644 --- a/src/product/receipt/receiptV5LineItem.ts +++ b/src/v1/product/receipt/receiptV5LineItem.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars, floatToString } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars, floatToString } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/resume/index.ts b/src/v1/product/resume/index.ts similarity index 100% rename from src/product/resume/index.ts rename to src/v1/product/resume/index.ts diff --git a/src/product/resume/resumeV1.ts b/src/v1/product/resume/resumeV1.ts similarity index 92% rename from src/product/resume/resumeV1.ts rename to src/v1/product/resume/resumeV1.ts index 2ae4b196..231b3de1 100644 --- a/src/product/resume/resumeV1.ts +++ b/src/v1/product/resume/resumeV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { ResumeV1Document } from "./resumeV1Document.js"; /** diff --git a/src/product/resume/resumeV1Certificate.ts b/src/v1/product/resume/resumeV1Certificate.ts similarity index 95% rename from src/product/resume/resumeV1Certificate.ts rename to src/v1/product/resume/resumeV1Certificate.ts index e5b65870..3956fc17 100644 --- a/src/product/resume/resumeV1Certificate.ts +++ b/src/v1/product/resume/resumeV1Certificate.ts @@ -1,5 +1,5 @@ -import { cleanSpecialChars } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/resume/resumeV1Document.ts b/src/v1/product/resume/resumeV1Document.ts similarity index 98% rename from src/product/resume/resumeV1Document.ts rename to src/v1/product/resume/resumeV1Document.ts index 61675aa4..b129a3b9 100644 --- a/src/product/resume/resumeV1Document.ts +++ b/src/v1/product/resume/resumeV1Document.ts @@ -2,13 +2,13 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { ResumeV1SocialNetworksUrl } from "./resumeV1SocialNetworksUrl.js"; import { ResumeV1Language } from "./resumeV1Language.js"; import { ResumeV1Education } from "./resumeV1Education.js"; import { ResumeV1ProfessionalExperience } from "./resumeV1ProfessionalExperience.js"; import { ResumeV1Certificate } from "./resumeV1Certificate.js"; -import { ClassificationField, StringField } from "@/parsing/standard/index.js"; +import { ClassificationField, StringField } from "@/v1/parsing/standard/index.js"; /** * Resume API version 1.2 document data. diff --git a/src/product/resume/resumeV1Education.ts b/src/v1/product/resume/resumeV1Education.ts similarity index 97% rename from src/product/resume/resumeV1Education.ts rename to src/v1/product/resume/resumeV1Education.ts index 4b04a164..7b1de459 100644 --- a/src/product/resume/resumeV1Education.ts +++ b/src/v1/product/resume/resumeV1Education.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/resume/resumeV1Language.ts b/src/v1/product/resume/resumeV1Language.ts similarity index 93% rename from src/product/resume/resumeV1Language.ts rename to src/v1/product/resume/resumeV1Language.ts index 121ce1e3..b9eb3652 100644 --- a/src/product/resume/resumeV1Language.ts +++ b/src/v1/product/resume/resumeV1Language.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/resume/resumeV1ProfessionalExperience.ts b/src/v1/product/resume/resumeV1ProfessionalExperience.ts similarity index 97% rename from src/product/resume/resumeV1ProfessionalExperience.ts rename to src/v1/product/resume/resumeV1ProfessionalExperience.ts index 0538c0ad..f1474e37 100644 --- a/src/product/resume/resumeV1ProfessionalExperience.ts +++ b/src/v1/product/resume/resumeV1ProfessionalExperience.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/resume/resumeV1SocialNetworksUrl.ts b/src/v1/product/resume/resumeV1SocialNetworksUrl.ts similarity index 93% rename from src/product/resume/resumeV1SocialNetworksUrl.ts rename to src/v1/product/resume/resumeV1SocialNetworksUrl.ts index 58d3795d..85b73608 100644 --- a/src/product/resume/resumeV1SocialNetworksUrl.ts +++ b/src/v1/product/resume/resumeV1SocialNetworksUrl.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/us/bankCheck/bankCheckV1.ts b/src/v1/product/us/bankCheck/bankCheckV1.ts similarity index 93% rename from src/product/us/bankCheck/bankCheckV1.ts rename to src/v1/product/us/bankCheck/bankCheckV1.ts index 242e4eb3..4d8b2c9d 100644 --- a/src/product/us/bankCheck/bankCheckV1.ts +++ b/src/v1/product/us/bankCheck/bankCheckV1.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { BankCheckV1Document } from "./bankCheckV1Document.js"; import { BankCheckV1Page } from "./bankCheckV1Page.js"; diff --git a/src/product/us/bankCheck/bankCheckV1Document.ts b/src/v1/product/us/bankCheck/bankCheckV1Document.ts similarity index 96% rename from src/product/us/bankCheck/bankCheckV1Document.ts rename to src/v1/product/us/bankCheck/bankCheckV1Document.ts index 63483b0f..e4c8990f 100644 --- a/src/product/us/bankCheck/bankCheckV1Document.ts +++ b/src/v1/product/us/bankCheck/bankCheckV1Document.ts @@ -2,12 +2,12 @@ import { Prediction, StringDict, cleanOutString, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { AmountField, DateField, StringField, -} from "@/parsing/standard/index.js"; +} from "@/v1/parsing/standard/index.js"; /** * Bank Check API version 1.1 document data. diff --git a/src/product/us/bankCheck/bankCheckV1Page.ts b/src/v1/product/us/bankCheck/bankCheckV1Page.ts similarity index 89% rename from src/product/us/bankCheck/bankCheckV1Page.ts rename to src/v1/product/us/bankCheck/bankCheckV1Page.ts index e39de604..52ef31ef 100644 --- a/src/product/us/bankCheck/bankCheckV1Page.ts +++ b/src/v1/product/us/bankCheck/bankCheckV1Page.ts @@ -1,5 +1,5 @@ -import { StringDict, cleanOutString } from "@/parsing/common/index.js"; -import { PositionField } from "@/parsing/standard/index.js"; +import { StringDict, cleanOutString } from "@/v1/parsing/common/index.js"; +import { PositionField } from "@/v1/parsing/standard/index.js"; import { BankCheckV1Document } from "./bankCheckV1Document.js"; /** diff --git a/src/product/us/bankCheck/index.ts b/src/v1/product/us/bankCheck/index.ts similarity index 100% rename from src/product/us/bankCheck/index.ts rename to src/v1/product/us/bankCheck/index.ts diff --git a/src/v1/product/us/index.ts b/src/v1/product/us/index.ts new file mode 100644 index 00000000..fcf56cdf --- /dev/null +++ b/src/v1/product/us/index.ts @@ -0,0 +1,6 @@ +export { BankCheckV1 } from "./bankCheck/index.js"; +export { UsMailV3 } from "./usMail/index.js"; + +// not sure if we want to export these -- advanced users can import them directly +export * as bankCheck from "./bankCheck/index.js"; +export * as usMail from "./usMail/index.js"; diff --git a/src/product/us/usMail/index.ts b/src/v1/product/us/usMail/index.ts similarity index 100% rename from src/product/us/usMail/index.ts rename to src/v1/product/us/usMail/index.ts diff --git a/src/product/us/usMail/usMailV3.ts b/src/v1/product/us/usMail/usMailV3.ts similarity index 92% rename from src/product/us/usMail/usMailV3.ts rename to src/v1/product/us/usMail/usMailV3.ts index a4f637b8..5444b5d4 100644 --- a/src/product/us/usMail/usMailV3.ts +++ b/src/v1/product/us/usMail/usMailV3.ts @@ -1,4 +1,4 @@ -import { Inference, StringDict, Page } from "@/parsing/common/index.js"; +import { Inference, StringDict, Page } from "@/v1/parsing/common/index.js"; import { UsMailV3Document } from "./usMailV3Document.js"; /** diff --git a/src/product/us/usMail/usMailV3Document.ts b/src/v1/product/us/usMail/usMailV3Document.ts similarity index 96% rename from src/product/us/usMail/usMailV3Document.ts rename to src/v1/product/us/usMail/usMailV3Document.ts index 13dc36f9..67eb1a4d 100644 --- a/src/product/us/usMail/usMailV3Document.ts +++ b/src/v1/product/us/usMail/usMailV3Document.ts @@ -2,10 +2,10 @@ import { Prediction, StringDict, cleanOutString,lineSeparator, -} from "@/parsing/common/index.js"; +} from "@/v1/parsing/common/index.js"; import { UsMailV3SenderAddress } from "./usMailV3SenderAddress.js"; import { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress.js"; -import { BooleanField, StringField } from "@/parsing/standard/index.js"; +import { BooleanField, StringField } from "@/v1/parsing/standard/index.js"; /** * US Mail API version 3.0 document data. diff --git a/src/product/us/usMail/usMailV3RecipientAddress.ts b/src/v1/product/us/usMail/usMailV3RecipientAddress.ts similarity index 97% rename from src/product/us/usMail/usMailV3RecipientAddress.ts rename to src/v1/product/us/usMail/usMailV3RecipientAddress.ts index 85e370a8..c26ac5f5 100644 --- a/src/product/us/usMail/usMailV3RecipientAddress.ts +++ b/src/v1/product/us/usMail/usMailV3RecipientAddress.ts @@ -1,6 +1,6 @@ -import { cleanSpecialChars } from "@/parsing/common/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { cleanSpecialChars } from "@/v1/parsing/common/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/product/us/usMail/usMailV3SenderAddress.ts b/src/v1/product/us/usMail/usMailV3SenderAddress.ts similarity index 97% rename from src/product/us/usMail/usMailV3SenderAddress.ts rename to src/v1/product/us/usMail/usMailV3SenderAddress.ts index 204e74e3..13559239 100644 --- a/src/product/us/usMail/usMailV3SenderAddress.ts +++ b/src/v1/product/us/usMail/usMailV3SenderAddress.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Polygon } from "@/geometry/index.js"; /** diff --git a/src/cliV2.ts b/src/v2/cli.ts similarity index 87% rename from src/cliV2.ts rename to src/v2/cli.ts index 22407ef4..bedb1413 100644 --- a/src/cliV2.ts +++ b/src/v2/cli.ts @@ -1,8 +1,8 @@ import { Command, OptionValues } from "commander"; -import { ClientV2 } from "./clientV2.js"; -import { PathInput } from "./input/index.js"; +import { Client } from "./client.js"; +import { PathInput } from "../input/index.js"; import * as console from "console"; -import { Inference } from "@/parsing/v2/index.js"; +import { Inference } from "@/v2/parsing/index.js"; const program = new Command(); @@ -11,8 +11,8 @@ const program = new Command(); // EXECUTE THE COMMANDS // -function initClient(options: OptionValues): ClientV2 { - return new ClientV2({ +function initClient(options: OptionValues): Client { + return new Client({ apiKey: options.apiKey, debug: options.debug, }); @@ -59,7 +59,7 @@ function addMainOptions(prog: Command) { prog.argument("", "full path to the file"); } -export function cliV2() { +export function cli() { program.name("mindee") .description("Command line interface for Mindee products.") .option("-d, --debug", "high verbosity mode"); diff --git a/src/clientV2.ts b/src/v2/client.ts similarity index 69% rename from src/clientV2.ts rename to src/v2/client.ts index 5dd1064c..53e17c29 100644 --- a/src/clientV2.ts +++ b/src/v2/client.ts @@ -1,64 +1,14 @@ -import { Dispatcher } from "undici"; -import { DataSchema, InputSource } from "./input/index.js"; -import { errorHandler } from "./errors/handler.js"; -import { LOG_LEVELS, logger } from "./logger.js"; import { setTimeout } from "node:timers/promises"; -import { ErrorResponse, InferenceResponse, JobResponse } from "@/parsing/v2/index.js"; +import { Dispatcher } from "undici"; +import { InputSource } from "@/input/index.js"; +import { errorHandler } from "@/errors/handler.js"; +import { LOG_LEVELS, logger } from "@/logger.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { ErrorResponse, InferenceResponse, JobResponse } from "./parsing/index.js"; import { MindeeApiV2 } from "./http/mindeeApiV2.js"; -import { MindeeHttpErrorV2 } from "@/errors/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; - -/** - * Parameters for the internal polling loop in {@link ClientV2.enqueueAndGetInference | enqueueAndGetInference()} . - * - * Default behavior: - * - `initialDelaySec` = 2s - * - `delaySec` = 1.5s - * - `maxRetries` = 80 - * - * Validation rules: - * - `initialDelaySec` >= 1 - * - `delaySec` >= 1 - * - `maxRetries` >= 2 - * - * The `initialTimerOptions` and `recurringTimerOptions` objects let you pass an - * `AbortSignal` or make the timer `unref`-ed to the `setTimeout()`. - * - * @category ClientV2 - * @example - * const params = { - * initialDelaySec: 4, - * delaySec: 2, - * maxRetries: 50 - * }; - * - * const inference = await client.enqueueAndGetInference(inputDoc, params); - */ - -export interface PollingOptions { - /** Number of seconds to wait *before the first poll*. */ - initialDelaySec?: number; - /** Interval in seconds between two consecutive polls. */ - delaySec?: number; - /** Maximum number of polling attempts (including the first one). */ - maxRetries?: number; - /** Options passed to the initial `setTimeout()`. */ - initialTimerOptions?: { - ref?: boolean, - signal?: AbortSignal - }; - /** Options passed to every recurring `setTimeout()`. */ - recurringTimerOptions?: { - ref?: boolean, - signal?: AbortSignal - } -} - -interface ValidatedPollingOptions extends PollingOptions { - initialDelaySec: number; - delaySec: number; - maxRetries: number; -} +import { MindeeHttpErrorV2 } from "./http/errors.js"; +import { PollingOptions, DataSchema } from "./client/index.js"; +import { setAsyncParams } from "./client/pollingOptions.js"; /** * Parameters accepted by the asynchronous **inference** v2 endpoint. @@ -128,6 +78,7 @@ export interface ClientOptions { throwOnError?: boolean; /** Log debug messages. */ debug?: boolean; + /** Custom Dispatcher instance for the HTTP requests. */ dispatcher?: Dispatcher; } @@ -136,7 +87,7 @@ export interface ClientOptions { * * @category ClientV2 */ -export class ClientV2 { +export class Client { /** Mindee V2 API handler. */ protected mindeeApi: MindeeApiV2; @@ -219,44 +170,6 @@ export class ClientV2 { return await this.mindeeApi.reqGetJob(jobId); } - /** - * Checks the values for asynchronous parsing. Returns their corrected value if they are undefined. - * @param asyncParams parameters related to asynchronous parsing - * @returns A valid `AsyncOptions`. - */ - #setAsyncParams(asyncParams: PollingOptions | undefined = undefined): ValidatedPollingOptions { - const minDelaySec = 1; - const minInitialDelay = 1; - const minRetries = 2; - let newAsyncParams: PollingOptions; - if (asyncParams === undefined) { - newAsyncParams = { - delaySec: 1.5, - initialDelaySec: 2, - maxRetries: 80 - }; - } else { - newAsyncParams = { ...asyncParams }; - if ( - !newAsyncParams.delaySec || - !newAsyncParams.initialDelaySec || - !newAsyncParams.maxRetries - ) { - throw Error("Invalid polling options."); - } - if (newAsyncParams.delaySec < minDelaySec) { - throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`); - } - if (newAsyncParams.initialDelaySec < minInitialDelay) { - throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`); - } - if (newAsyncParams.maxRetries < minRetries) { - throw Error(`Cannot set retry to less than ${minRetries}.`); - } - } - return newAsyncParams as ValidatedPollingOptions; - } - /** * Send a document to an endpoint and poll the server until the result is sent or * until the maximum number of tries is reached. @@ -272,7 +185,7 @@ export class ClientV2 { inputSource: InputSource, params: InferenceParameters ): Promise { - const validatedAsyncParams = this.#setAsyncParams(params.pollingOptions); + const validatedAsyncParams = setAsyncParams(params.pollingOptions); const enqueueResponse: JobResponse = await this.enqueueInference(inputSource, params); if (enqueueResponse.job.id === undefined || enqueueResponse.job.id.length === 0) { logger.error(`Failed enqueueing:\n${enqueueResponse.getRawHttp()}`); diff --git a/src/input/dataSchema.ts b/src/v2/client/dataSchema.ts similarity index 97% rename from src/input/dataSchema.ts rename to src/v2/client/dataSchema.ts index b5135f9e..19787dc2 100644 --- a/src/input/dataSchema.ts +++ b/src/v2/client/dataSchema.ts @@ -1,5 +1,5 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; -import { MindeeError } from "../errors/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { MindeeError } from "@/errors/index.js"; export class DataSchemaField { /** diff --git a/src/v2/client/index.ts b/src/v2/client/index.ts new file mode 100644 index 00000000..c31c7b5d --- /dev/null +++ b/src/v2/client/index.ts @@ -0,0 +1,2 @@ +export { DataSchema } from "./dataSchema.js"; +export type { PollingOptions, ValidatedPollingOptions } from "./pollingOptions.js"; diff --git a/src/v2/client/pollingOptions.ts b/src/v2/client/pollingOptions.ts new file mode 100644 index 00000000..2ad4a5c8 --- /dev/null +++ b/src/v2/client/pollingOptions.ts @@ -0,0 +1,89 @@ +/** + * Parameters for the internal polling loop in {@link ClientV2.enqueueAndGetInference | enqueueAndGetInference()}. + * + * Default behavior: + * - `initialDelaySec` = 2s + * - `delaySec` = 1.5s + * - `maxRetries` = 80 + * + * Validation rules: + * - `initialDelaySec` >= 1 + * - `delaySec` >= 1 + * - `maxRetries` >= 2 + * + * The `initialTimerOptions` and `recurringTimerOptions` objects let you pass an + * `AbortSignal` or make the timer `unref`-ed to the `setTimeout()`. + * + * @category ClientV2 + * @example + * const params = { + * initialDelaySec: 4, + * delaySec: 2, + * maxRetries: 50 + * }; + * + * const inference = await client.enqueueAndGetInference(inputDoc, params); + */ + +export interface PollingOptions { + /** Number of seconds to wait *before the first poll*. */ + initialDelaySec?: number; + /** Interval in seconds between two consecutive polls. */ + delaySec?: number; + /** Maximum number of polling attempts (including the first one). */ + maxRetries?: number; + /** Options passed to the initial `setTimeout()`. */ + initialTimerOptions?: { + ref?: boolean, + signal?: AbortSignal + }; + /** Options passed to every recurring `setTimeout()`. */ + recurringTimerOptions?: { + ref?: boolean, + signal?: AbortSignal + } +} + +export interface ValidatedPollingOptions extends PollingOptions { + initialDelaySec: number; + delaySec: number; + maxRetries: number; +} + +/** + * Checks the values for asynchronous parsing. Returns their corrected value if they are undefined. + * @param asyncParams parameters related to asynchronous parsing + * @returns A valid `AsyncOptions`. + */ +export function setAsyncParams(asyncParams: PollingOptions | undefined = undefined): ValidatedPollingOptions { + const minDelaySec = 1; + const minInitialDelay = 1; + const minRetries = 2; + let newAsyncParams: PollingOptions; + if (asyncParams === undefined) { + newAsyncParams = { + delaySec: 1.5, + initialDelaySec: 2, + maxRetries: 80 + }; + } else { + newAsyncParams = { ...asyncParams }; + if ( + !newAsyncParams.delaySec || + !newAsyncParams.initialDelaySec || + !newAsyncParams.maxRetries + ) { + throw Error("Invalid polling options."); + } + if (newAsyncParams.delaySec < minDelaySec) { + throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`); + } + if (newAsyncParams.initialDelaySec < minInitialDelay) { + throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`); + } + if (newAsyncParams.maxRetries < minRetries) { + throw Error(`Cannot set retry to less than ${minRetries}.`); + } + } + return newAsyncParams as ValidatedPollingOptions; +} diff --git a/src/http/apiSettingsV2.ts b/src/v2/http/apiSettingsV2.ts similarity index 84% rename from src/http/apiSettingsV2.ts rename to src/v2/http/apiSettingsV2.ts index a31c3c50..1fb295d7 100644 --- a/src/http/apiSettingsV2.ts +++ b/src/v2/http/apiSettingsV2.ts @@ -1,7 +1,6 @@ -/* eslint-disable @typescript-eslint/naming-convention */ import { logger } from "@/logger.js"; -import { BaseSettings, MindeeApiConstructorProps } from "./baseSettings.js"; -import { MindeeApiV2Error } from "@/errors/index.js"; +import { BaseSettings, MindeeApiConstructorProps } from "@/http/baseSettings.js"; +import { MindeeConfigurationError } from "@/errors/index.js"; const API_V2_KEY_ENVVAR_NAME: string = "MINDEE_V2_API_KEY"; const API_V2_HOST_ENVVAR_NAME: string = "MINDEE_V2_API_HOST"; @@ -16,11 +15,12 @@ export class ApiSettingsV2 extends BaseSettings { }: MindeeApiConstructorProps) { super(apiKey, dispatcher); if (!this.apiKey || this.apiKey.length === 0) { - throw new MindeeApiV2Error( + throw new MindeeConfigurationError( "Your V2 API key could not be set, check your Client Configuration\n." + `You can set this using the ${API_V2_KEY_ENVVAR_NAME} environment variable.` ); } + /* eslint-disable @typescript-eslint/naming-convention */ this.baseHeaders = { "User-Agent": this.getUserAgent(), Authorization: `${this.apiKey}`, diff --git a/src/v2/http/errors.ts b/src/v2/http/errors.ts new file mode 100644 index 00000000..9c8f05c6 --- /dev/null +++ b/src/v2/http/errors.ts @@ -0,0 +1,20 @@ +import { ErrorDetails, ErrorItem, ErrorResponse } from "@/v2/parsing/index.js"; +import { MindeeError } from "@/errors/index.js"; + +export class MindeeHttpErrorV2 extends MindeeError implements ErrorDetails { + public status: number; + public detail: string; + public title: string; + public code: string; + public errors: ErrorItem[]; + + constructor(error: ErrorResponse) { + super(`HTTP ${error.status} - ${error.title} :: ${error.code} - ${error.detail}`); + this.status = error.status; + this.detail = error.detail; + this.title = error.title; + this.code = error.code; + this.errors = error.errors; + this.name = "MindeeHttpErrorV2"; + } +} diff --git a/src/v2/http/index.ts b/src/v2/http/index.ts new file mode 100644 index 00000000..73bd7b80 --- /dev/null +++ b/src/v2/http/index.ts @@ -0,0 +1,2 @@ +export { MindeeHttpErrorV2 } from "./errors.js"; + diff --git a/src/http/mindeeApiV2.ts b/src/v2/http/mindeeApiV2.ts similarity index 87% rename from src/http/mindeeApiV2.ts rename to src/v2/http/mindeeApiV2.ts index 04f599b8..201f750c 100644 --- a/src/http/mindeeApiV2.ts +++ b/src/v2/http/mindeeApiV2.ts @@ -1,10 +1,11 @@ import { ApiSettingsV2 } from "./apiSettingsV2.js"; import { Dispatcher } from "undici"; -import { InferenceParameters } from "@/clientV2.js"; -import { ErrorResponse, InferenceResponse, JobResponse } from "@/parsing/v2/index.js"; -import { sendRequestAndReadResponse, EndpointResponse } from "./apiCore.js"; +import { InferenceParameters } from "@/v2/client.js"; +import { ErrorResponse, InferenceResponse, JobResponse } from "@/v2/parsing/index.js"; +import { sendRequestAndReadResponse, BaseHttpResponse } from "@/http/apiCore.js"; import { InputSource, LocalInputSource, UrlInput } from "@/input/index.js"; -import { MindeeApiV2Error, MindeeHttpErrorV2 } from "@/errors/index.js"; +import { MindeeConfigurationError, MindeeDeserializationError } from "@/errors/index.js"; +import { MindeeHttpErrorV2 } from "./errors.js"; import { logger } from "@/logger.js"; export class MindeeApiV2 { @@ -25,9 +26,9 @@ export class MindeeApiV2 { async reqPostInferenceEnqueue(inputSource: InputSource, params: InferenceParameters): Promise { await inputSource.init(); if (params.modelId === undefined || params.modelId === null || params.modelId === "") { - throw new Error("Model ID must be provided"); + throw new MindeeConfigurationError("Model ID must be provided"); } - const result: EndpointResponse = await this.#documentEnqueuePost(inputSource, params); + const result: BaseHttpResponse = await this.#documentEnqueuePost(inputSource, params); if (result.data.error !== undefined) { throw new MindeeHttpErrorV2(result.data.error); } @@ -43,7 +44,7 @@ export class MindeeApiV2 { * @returns a `Promise` containing either the parsed result, or information on the queue. */ async reqGetInference(inferenceId: string): Promise { - const queueResponse: EndpointResponse = await this.#inferenceResultReqGet(inferenceId, "inferences"); + const queueResponse: BaseHttpResponse = await this.#inferenceResultReqGet(inferenceId, "inferences"); return this.#processResponse(queueResponse, InferenceResponse); } @@ -55,12 +56,12 @@ export class MindeeApiV2 { * @returns a `Promise` containing information on the queue. */ async reqGetJob(jobId: string): Promise { - const queueResponse: EndpointResponse = await this.#inferenceResultReqGet(jobId, "jobs"); + const queueResponse: BaseHttpResponse = await this.#inferenceResultReqGet(jobId, "jobs"); return this.#processResponse(queueResponse, JobResponse); } #processResponse - (result: EndpointResponse, responseType: new (data: { [key: string]: any; }) => T): T { + (result: BaseHttpResponse, responseType: new (data: { [key: string]: any; }) => T): T { if (result.messageObj?.statusCode && (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) { if (result.data?.status !== null) { throw new MindeeHttpErrorV2(new ErrorResponse(result.data)); @@ -80,7 +81,7 @@ export class MindeeApiV2 { return new responseType(result.data); } catch (e) { logger.error(`Raised '${e}' Couldn't deserialize response object:\n${JSON.stringify(result.data)}`); - throw new MindeeApiV2Error("Couldn't deserialize response object."); + throw new MindeeDeserializationError("Couldn't deserialize response object."); } } @@ -93,7 +94,7 @@ export class MindeeApiV2 { async #documentEnqueuePost( inputSource: InputSource, params: InferenceParameters - ): Promise { + ): Promise { const form = new FormData(); form.set("model_id", params.modelId); @@ -142,7 +143,7 @@ export class MindeeApiV2 { * @category Asynchronous * @returns a `Promise` containing either the parsed result, or information on the queue. */ - async #inferenceResultReqGet(queueId: string, slug: string): Promise { + async #inferenceResultReqGet(queueId: string, slug: string): Promise { const options = { method: "GET", headers: this.settings.baseHeaders, diff --git a/src/v2/index.ts b/src/v2/index.ts new file mode 100644 index 00000000..d36b8748 --- /dev/null +++ b/src/v2/index.ts @@ -0,0 +1,15 @@ +export * as http from "./http/index.js"; +export * as parsing from "./parsing/index.js"; +export { LocalResponse } from "./parsing/localResponse.js"; +export { Client } from "./client.js"; +export { + InferenceFile, + InferenceResponse, + JobResponse, + RawText, + RagMetadata, + ErrorResponse, +} from "./parsing/index.js"; +export type { InferenceParameters } from "./client.js"; +export { DataSchema } from "./client/index.js"; +export type { PollingOptions } from "./client/index.js"; diff --git a/src/parsing/v2/commonResponse.ts b/src/v2/parsing/commonResponse.ts similarity index 88% rename from src/parsing/v2/commonResponse.ts rename to src/v2/parsing/commonResponse.ts index f6ab596a..21a81e3e 100644 --- a/src/parsing/v2/commonResponse.ts +++ b/src/v2/parsing/commonResponse.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export abstract class CommonResponse { diff --git a/src/parsing/v2/dataSchemaActiveOption.ts b/src/v2/parsing/dataSchemaActiveOption.ts similarity index 86% rename from src/parsing/v2/dataSchemaActiveOption.ts rename to src/v2/parsing/dataSchemaActiveOption.ts index d804aeff..841241ac 100644 --- a/src/parsing/v2/dataSchemaActiveOption.ts +++ b/src/v2/parsing/dataSchemaActiveOption.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * Data schema options activated during the inference. diff --git a/src/parsing/v2/errorItem.ts b/src/v2/parsing/errorItem.ts similarity index 89% rename from src/parsing/v2/errorItem.ts rename to src/v2/parsing/errorItem.ts index 63cae233..4ba4678b 100644 --- a/src/parsing/v2/errorItem.ts +++ b/src/v2/parsing/errorItem.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * Explicit details on a problem. diff --git a/src/parsing/v2/errorResponse.ts b/src/v2/parsing/errorResponse.ts similarity index 95% rename from src/parsing/v2/errorResponse.ts rename to src/v2/parsing/errorResponse.ts index 17de3b3e..4510ef78 100644 --- a/src/parsing/v2/errorResponse.ts +++ b/src/v2/parsing/errorResponse.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { ErrorItem } from "./errorItem.js"; export interface ErrorDetails { diff --git a/src/parsing/v2/field/baseField.ts b/src/v2/parsing/field/baseField.ts similarity index 92% rename from src/parsing/v2/field/baseField.ts rename to src/v2/parsing/field/baseField.ts index 4af5c38f..d1fc3747 100644 --- a/src/parsing/v2/field/baseField.ts +++ b/src/v2/parsing/field/baseField.ts @@ -1,5 +1,5 @@ import { FieldConfidence } from "./fieldConfidence.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { FieldLocation } from "./fieldLocation.js"; export abstract class BaseField { diff --git a/src/parsing/v2/field/fieldConfidence.ts b/src/v2/parsing/field/fieldConfidence.ts similarity index 100% rename from src/parsing/v2/field/fieldConfidence.ts rename to src/v2/parsing/field/fieldConfidence.ts diff --git a/src/parsing/v2/field/fieldFactory.ts b/src/v2/parsing/field/fieldFactory.ts similarity index 79% rename from src/parsing/v2/field/fieldFactory.ts rename to src/v2/parsing/field/fieldFactory.ts index aa42bc43..b5f539d8 100644 --- a/src/parsing/v2/field/fieldFactory.ts +++ b/src/v2/parsing/field/fieldFactory.ts @@ -1,15 +1,15 @@ /** * Factory helper. */ -import { StringDict } from "@/parsing/common/stringDict.js"; -import { MindeeApiV2Error } from "@/errors/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; +import { MindeeDeserializationError } from "@/errors/index.js"; import { ListField } from "./listField.js"; import { ObjectField } from "./objectField.js"; import { SimpleField } from "./simpleField.js"; export function createField(serverResponse: StringDict, indentLevel = 0) { if (typeof serverResponse !== "object" || serverResponse === null) { - throw new MindeeApiV2Error( + throw new MindeeDeserializationError( `Unrecognized field format ${JSON.stringify(serverResponse)}.` ); } @@ -26,7 +26,7 @@ export function createField(serverResponse: StringDict, indentLevel = 0) { return new SimpleField(serverResponse, indentLevel); } - throw new MindeeApiV2Error( + throw new MindeeDeserializationError( `Unrecognized field format in ${JSON.stringify(serverResponse)}.` ); } diff --git a/src/parsing/v2/field/fieldLocation.ts b/src/v2/parsing/field/fieldLocation.ts similarity index 89% rename from src/parsing/v2/field/fieldLocation.ts rename to src/v2/parsing/field/fieldLocation.ts index 95b5fd3f..14b9ae33 100644 --- a/src/parsing/v2/field/fieldLocation.ts +++ b/src/v2/parsing/field/fieldLocation.ts @@ -1,5 +1,5 @@ import { Polygon } from "@/geometry/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; /** * Location of a field. diff --git a/src/parsing/v2/field/index.ts b/src/v2/parsing/field/index.ts similarity index 100% rename from src/parsing/v2/field/index.ts rename to src/v2/parsing/field/index.ts diff --git a/src/parsing/v2/field/inferenceFields.ts b/src/v2/parsing/field/inferenceFields.ts similarity index 97% rename from src/parsing/v2/field/inferenceFields.ts rename to src/v2/parsing/field/inferenceFields.ts index 4c66ad8a..af429761 100644 --- a/src/parsing/v2/field/inferenceFields.ts +++ b/src/v2/parsing/field/inferenceFields.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import type { ListField } from "./listField.js"; import type { ObjectField } from "./objectField.js"; import type { SimpleField } from "./simpleField.js"; diff --git a/src/parsing/v2/field/listField.ts b/src/v2/parsing/field/listField.ts similarity index 88% rename from src/parsing/v2/field/listField.ts rename to src/v2/parsing/field/listField.ts index f51a925e..0133d3aa 100644 --- a/src/parsing/v2/field/listField.ts +++ b/src/v2/parsing/field/listField.ts @@ -1,5 +1,5 @@ -import { MindeeApiV2Error } from "@/errors/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { MindeeDeserializationError } from "@/errors/index.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { BaseField } from "./baseField.js"; import { ObjectField } from "./objectField.js"; import { SimpleField } from "./simpleField.js"; @@ -21,7 +21,7 @@ export class ListField extends BaseField { if (item instanceof SimpleField) { result.push(item); } else { - throw new MindeeApiV2Error( + throw new MindeeDeserializationError( `All items must be SimpleField, found item of type ${item.constructor.name}.` ); } @@ -39,7 +39,7 @@ export class ListField extends BaseField { if (item instanceof ObjectField) { result.push(item); } else { - throw new MindeeApiV2Error( + throw new MindeeDeserializationError( `All items must be ObjectField, found item of type ${item.constructor.name}.` ); } @@ -51,7 +51,7 @@ export class ListField extends BaseField { super(serverResponse, indentLevel); if (!Array.isArray(serverResponse["items"])) { - throw new MindeeApiV2Error( + throw new MindeeDeserializationError( `Expected "items" to be an array in ${JSON.stringify(serverResponse)}.` ); } diff --git a/src/parsing/v2/field/objectField.ts b/src/v2/parsing/field/objectField.ts similarity index 94% rename from src/parsing/v2/field/objectField.ts rename to src/v2/parsing/field/objectField.ts index a5920ca9..614fd5f4 100644 --- a/src/parsing/v2/field/objectField.ts +++ b/src/v2/parsing/field/objectField.ts @@ -1,5 +1,5 @@ import { InferenceFields } from "./inferenceFields.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { BaseField } from "./baseField.js"; import type { SimpleField } from "./simpleField.js"; diff --git a/src/parsing/v2/field/simpleField.ts b/src/v2/parsing/field/simpleField.ts similarity index 96% rename from src/parsing/v2/field/simpleField.ts rename to src/v2/parsing/field/simpleField.ts index 2779e9bb..eff4d103 100644 --- a/src/parsing/v2/field/simpleField.ts +++ b/src/v2/parsing/field/simpleField.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { BaseField } from "./baseField.js"; export class SimpleField extends BaseField { diff --git a/src/parsing/v2/index.ts b/src/v2/parsing/index.ts similarity index 100% rename from src/parsing/v2/index.ts rename to src/v2/parsing/index.ts index e5e212bb..6e952e0b 100644 --- a/src/parsing/v2/index.ts +++ b/src/v2/parsing/index.ts @@ -1,15 +1,15 @@ -export { CommonResponse } from "./commonResponse.js"; export { ErrorResponse } from "./errorResponse.js"; export type { ErrorDetails } from "./errorResponse.js"; export { ErrorItem } from "./errorItem.js"; +export { Job } from "./job.js"; +export { JobResponse } from "./jobResponse.js"; +export { JobWebhook } from "./jobWebhook.js"; +export { InferenceFile } from "./inferenceFile.js"; +export { CommonResponse } from "./commonResponse.js"; export { Inference } from "./inference.js"; export { InferenceActiveOptions } from "./inferenceActiveOptions.js"; -export { InferenceFile } from "./inferenceFile.js"; export { InferenceModel } from "./inferenceModel.js"; export { InferenceResponse } from "./inferenceResponse.js"; export { InferenceResult } from "./inferenceResult.js"; -export { Job } from "./job.js"; -export { JobResponse } from "./jobResponse.js"; export { RawText } from "./rawText.js"; -export { JobWebhook } from "./jobWebhook.js"; export { RagMetadata } from "./ragMetadata.js"; diff --git a/src/parsing/v2/inference.ts b/src/v2/parsing/inference.ts similarity index 95% rename from src/parsing/v2/inference.ts rename to src/v2/parsing/inference.ts index aa8b8e4b..37a91c7c 100644 --- a/src/parsing/v2/inference.ts +++ b/src/v2/parsing/inference.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { InferenceModel } from "./inferenceModel.js"; import { InferenceResult } from "./inferenceResult.js"; import { InferenceFile } from "./inferenceFile.js"; diff --git a/src/parsing/v2/inferenceActiveOptions.ts b/src/v2/parsing/inferenceActiveOptions.ts similarity index 95% rename from src/parsing/v2/inferenceActiveOptions.ts rename to src/v2/parsing/inferenceActiveOptions.ts index 6f23a712..1f5febea 100644 --- a/src/parsing/v2/inferenceActiveOptions.ts +++ b/src/v2/parsing/inferenceActiveOptions.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { DataSchemaActiveOption } from "./dataSchemaActiveOption.js"; export class InferenceActiveOptions { diff --git a/src/parsing/v2/inferenceFile.ts b/src/v2/parsing/inferenceFile.ts similarity index 92% rename from src/parsing/v2/inferenceFile.ts rename to src/v2/parsing/inferenceFile.ts index 4c95edb1..a8b21271 100644 --- a/src/parsing/v2/inferenceFile.ts +++ b/src/v2/parsing/inferenceFile.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class InferenceFile { /** diff --git a/src/parsing/v2/inferenceModel.ts b/src/v2/parsing/inferenceModel.ts similarity index 81% rename from src/parsing/v2/inferenceModel.ts rename to src/v2/parsing/inferenceModel.ts index 15e9adb7..4d45be80 100644 --- a/src/parsing/v2/inferenceModel.ts +++ b/src/v2/parsing/inferenceModel.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class InferenceModel { /** diff --git a/src/parsing/v2/inferenceResponse.ts b/src/v2/parsing/inferenceResponse.ts similarity index 85% rename from src/parsing/v2/inferenceResponse.ts rename to src/v2/parsing/inferenceResponse.ts index 6020a567..7c63d894 100644 --- a/src/parsing/v2/inferenceResponse.ts +++ b/src/v2/parsing/inferenceResponse.ts @@ -1,6 +1,6 @@ import { CommonResponse } from "./commonResponse.js"; import { Inference } from "./inference.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class InferenceResponse extends CommonResponse { /** diff --git a/src/parsing/v2/inferenceResult.ts b/src/v2/parsing/inferenceResult.ts similarity index 92% rename from src/parsing/v2/inferenceResult.ts rename to src/v2/parsing/inferenceResult.ts index 5ce3964e..5acd4284 100644 --- a/src/parsing/v2/inferenceResult.ts +++ b/src/v2/parsing/inferenceResult.ts @@ -1,5 +1,5 @@ import { InferenceFields } from "./field/index.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { RawText } from "./rawText.js"; import { RagMetadata } from "./ragMetadata.js"; diff --git a/src/parsing/v2/job.ts b/src/v2/parsing/job.ts similarity index 93% rename from src/parsing/v2/job.ts rename to src/v2/parsing/job.ts index 738c6cb5..66183cf0 100644 --- a/src/parsing/v2/job.ts +++ b/src/v2/parsing/job.ts @@ -1,7 +1,7 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { ErrorResponse } from "./errorResponse.js"; import { JobWebhook } from "./jobWebhook.js"; -import { parseDate } from "@/parsing/common/index.js"; +import { parseDate } from "@/v1/parsing/common/index.js"; /** * Job information for a V2 polling attempt. diff --git a/src/parsing/v2/jobResponse.ts b/src/v2/parsing/jobResponse.ts similarity index 83% rename from src/parsing/v2/jobResponse.ts rename to src/v2/parsing/jobResponse.ts index 85d0794d..7abef720 100644 --- a/src/parsing/v2/jobResponse.ts +++ b/src/v2/parsing/jobResponse.ts @@ -1,5 +1,5 @@ import { CommonResponse } from "./commonResponse.js"; -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { Job } from "./job.js"; export class JobResponse extends CommonResponse { diff --git a/src/parsing/v2/jobWebhook.ts b/src/v2/parsing/jobWebhook.ts similarity index 90% rename from src/parsing/v2/jobWebhook.ts rename to src/v2/parsing/jobWebhook.ts index e499dc2d..4de7d01c 100644 --- a/src/parsing/v2/jobWebhook.ts +++ b/src/v2/parsing/jobWebhook.ts @@ -1,5 +1,5 @@ import { ErrorResponse } from "./errorResponse.js"; -import { StringDict, parseDate } from "@/parsing/common/index.js"; +import { StringDict, parseDate } from "@/v1/parsing/common/index.js"; /** * JobWebhook information. diff --git a/src/v2/parsing/localResponse.ts b/src/v2/parsing/localResponse.ts new file mode 100644 index 00000000..dd2a36c2 --- /dev/null +++ b/src/v2/parsing/localResponse.ts @@ -0,0 +1,31 @@ +import { StringDict } from "@/parsing/stringDict.js"; +import { MindeeError } from "@/errors/index.js"; +import { CommonResponse } from "@/v2/parsing/index.js"; +import { LocalResponseBase } from "@/parsing/localResponseBase.js"; + +/** + * Local response loaded from a file. + * Note: Has to be initialized through init() before use. + */ +export class LocalResponse extends LocalResponseBase { + + /** + * Deserialize the loaded local response into the requested CommonResponse-derived class. + * + * Typically used when dealing with V2 webhook callbacks. + * + * @typeParam ResponseT - A class that extends `CommonResponse`. + * @param responseClass - The constructor of the class into which the payload should be deserialized. + * @returns An instance of `responseClass` populated with the file content. + * @throws MindeeError If the provided class cannot be instantiated. + */ + public async deserializeResponse( + responseClass: new (serverResponse: StringDict) => ResponseT + ): Promise { + try { + return new responseClass(await this.asDict()); + } catch { + throw new MindeeError("Invalid response provided."); + } + } +} diff --git a/src/parsing/v2/ragMetadata.ts b/src/v2/parsing/ragMetadata.ts similarity index 81% rename from src/parsing/v2/ragMetadata.ts rename to src/v2/parsing/ragMetadata.ts index 1c78bf95..9eb8a417 100644 --- a/src/parsing/v2/ragMetadata.ts +++ b/src/v2/parsing/ragMetadata.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class RagMetadata { /** diff --git a/src/parsing/v2/rawText.ts b/src/v2/parsing/rawText.ts similarity index 88% rename from src/parsing/v2/rawText.ts rename to src/v2/parsing/rawText.ts index c6a7874a..46ccd124 100644 --- a/src/parsing/v2/rawText.ts +++ b/src/v2/parsing/rawText.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; import { RawTextPage } from "./rawTextPage.js"; export class RawText { diff --git a/src/parsing/v2/rawTextPage.ts b/src/v2/parsing/rawTextPage.ts similarity index 81% rename from src/parsing/v2/rawTextPage.ts rename to src/v2/parsing/rawTextPage.ts index 646881f1..822a8c70 100644 --- a/src/parsing/v2/rawTextPage.ts +++ b/src/v2/parsing/rawTextPage.ts @@ -1,4 +1,4 @@ -import { StringDict } from "@/parsing/common/stringDict.js"; +import { StringDict } from "@/parsing/stringDict.js"; export class RawTextPage { /** diff --git a/tests/input/sources.integration.ts b/tests/input/sources.integration.ts index 6b751956..a0452744 100644 --- a/tests/input/sources.integration.ts +++ b/tests/input/sources.integration.ts @@ -1,5 +1,5 @@ import * as mindee from "@/index.js"; -import { InvoiceV4 } from "@/product/index.js"; +import { InvoiceV4 } from "@/v1/product/index.js"; import { expect } from "chai"; import { promises as fs } from "fs"; import { createReadStream } from "node:fs"; @@ -8,11 +8,11 @@ import { V1_PRODUCT_PATH } from "../index.js"; import { PathInput, Base64Input, BufferInput, BytesInput, UrlInput } from "@/index.js"; describe("MindeeV1 - File Input Integration Tests", async () => { - let client: mindee.Client; + let client: mindee.v1.Client; let filePath: string; beforeEach(() => { - client = new mindee.Client(); + client = new mindee.v1.Client(); filePath = path.join(V1_PRODUCT_PATH, "invoices/default_sample.jpg"); }); diff --git a/tests/input/sources.spec.ts b/tests/input/sources.spec.ts index c6349782..9c00759d 100644 --- a/tests/input/sources.spec.ts +++ b/tests/input/sources.spec.ts @@ -16,7 +16,7 @@ import * as path from "path"; import { expect } from "chai"; import sharp from "sharp"; import { Buffer } from "node:buffer"; -import { compressImage } from "@/imageOperations/index.js"; +import { compressImage } from "@/image/index.js"; import { compressPdf } from "@/pdf/index.js"; import { extractTextFromPdf } from "@/pdf/pdfUtils.js"; import { logger } from "@/logger.js"; diff --git a/tests/input/urlInputSource.integration.ts b/tests/input/urlInputSource.integration.ts index c43013b3..5e1d1635 100644 --- a/tests/input/urlInputSource.integration.ts +++ b/tests/input/urlInputSource.integration.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; import { UrlInput } from "@/index.js"; -import { Client } from "@/index.js"; -import { InvoiceV4 } from "@/product/index.js"; +import { Client } from "@/v1/index.js"; +import { InvoiceV4 } from "@/v1/product/index.js"; describe("MindeeV1 - URL Input Integration Test", async () => { it("should retrieve and parse a remote file with redirection", async () => { diff --git a/tests/v1/api/asyncResponse.spec.ts b/tests/v1/api/asyncResponse.spec.ts index 139b977a..4501d95a 100644 --- a/tests/v1/api/asyncResponse.spec.ts +++ b/tests/v1/api/asyncResponse.spec.ts @@ -1,9 +1,9 @@ import { expect } from "chai"; -import { AsyncPredictResponse } from "@/index.js"; +import { AsyncPredictResponse } from "@/v1/index.js"; import { promises as fs } from "fs"; import * as path from "path"; -import { StringDict } from "@/parsing/common/index.js"; -import { InvoiceSplitterV1 } from "@/product/index.js"; +import { StringDict } from "@/v1/parsing/common/index.js"; +import { InvoiceSplitterV1 } from "@/v1/product/index.js"; import { cleanRequestData, isValidAsyncResponse } from "@/http/index.js"; import { RESOURCE_PATH } from "../../index.js"; diff --git a/tests/v1/api/endpoint.spec.ts b/tests/v1/api/endpoint.spec.ts index 31bf9740..460222cd 100644 --- a/tests/v1/api/endpoint.spec.ts +++ b/tests/v1/api/endpoint.spec.ts @@ -2,12 +2,13 @@ import * as fs from "node:fs"; import * as path from "path"; import { expect } from "chai"; import { MockAgent, setGlobalDispatcher } from "undici"; -import { Client, PathInput, product } from "@/index.js"; +import { PathInput } from "@/index.js"; +import { Client, product } from "@/v1/index.js"; import { RESOURCE_PATH, V1_RESOURCE_PATH } from "../../index.js"; import assert from "node:assert/strict"; import { MindeeHttp400Error, MindeeHttp401Error, MindeeHttp429Error, MindeeHttp500Error -} from "@/http/index.js"; +} from "@/v1/http/index.js"; const mockAgent = new MockAgent(); setGlobalDispatcher(mockAgent); diff --git a/tests/v1/api/feedbackResponse.spec.ts b/tests/v1/api/feedbackResponse.spec.ts index f5339c68..eeb26cc5 100644 --- a/tests/v1/api/feedbackResponse.spec.ts +++ b/tests/v1/api/feedbackResponse.spec.ts @@ -1,7 +1,7 @@ import path from "path"; import { expect } from "chai"; import { promises as fs } from "fs"; -import { FeedbackResponse } from "@/parsing/common/index.js"; +import { FeedbackResponse } from "@/v1/parsing/common/index.js"; import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - Feedback response", () => { diff --git a/tests/v1/api/response.spec.ts b/tests/v1/api/response.spec.ts index 12c397d4..226ff069 100644 --- a/tests/v1/api/response.spec.ts +++ b/tests/v1/api/response.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; -import { PredictResponse } from "@/index.js"; -import { InvoiceV4, ReceiptV5 } from "@/product/index.js"; +import { PredictResponse } from "@/v1/index.js"; +import { InvoiceV4, ReceiptV5 } from "@/v1/product/index.js"; import { V1_PRODUCT_PATH } from "../../index.js"; const dataPath = { diff --git a/tests/v1/clientInit.spec.ts b/tests/v1/clientInit.spec.ts index 5ac815d0..bdb59a74 100644 --- a/tests/v1/clientInit.spec.ts +++ b/tests/v1/clientInit.spec.ts @@ -1,4 +1,4 @@ -import { Client } from "@/client.js"; +import { Client } from "@/v1/index.js"; import { expect } from "chai"; import assert from "node:assert/strict"; diff --git a/tests/v1/imageOperations/invoiceSplitterExtractor.spec.ts b/tests/v1/extraction/invoiceSplitterExtractor.spec.ts similarity index 92% rename from tests/v1/imageOperations/invoiceSplitterExtractor.spec.ts rename to tests/v1/extraction/invoiceSplitterExtractor.spec.ts index ed20a3d9..d3d81a87 100644 --- a/tests/v1/imageOperations/invoiceSplitterExtractor.spec.ts +++ b/tests/v1/extraction/invoiceSplitterExtractor.spec.ts @@ -1,8 +1,8 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import path from "path"; -import { InvoiceSplitterV1 } from "@/product/index.js"; -import { extractInvoices } from "@/imageOperations/index.js"; +import { InvoiceSplitterV1 } from "@/v1/product/index.js"; +import { extractInvoices } from "@/v1/extraction/index.js"; import { PathInput } from "@/index.js"; import { V1_PRODUCT_PATH } from "../../index.js"; diff --git a/tests/v1/imageOperations/invoiceSplitterReconstruction.spec.ts b/tests/v1/extraction/invoiceSplitterReconstruction.spec.ts similarity index 92% rename from tests/v1/imageOperations/invoiceSplitterReconstruction.spec.ts rename to tests/v1/extraction/invoiceSplitterReconstruction.spec.ts index 68c26083..d87f9106 100644 --- a/tests/v1/imageOperations/invoiceSplitterReconstruction.spec.ts +++ b/tests/v1/extraction/invoiceSplitterReconstruction.spec.ts @@ -1,9 +1,9 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import * as path from "path"; -import { Document } from "@/index.js"; -import { InvoiceSplitterV1 } from "@/product/index.js"; -import { extractInvoices } from "@/imageOperations/index.js"; +import { Document } from "@/v1/index.js"; +import { InvoiceSplitterV1 } from "@/v1/product/index.js"; +import { extractInvoices } from "@/v1/extraction/index.js"; import { PathInput } from "@/index.js"; import { V1_PRODUCT_PATH } from "../../index.js"; diff --git a/tests/v1/imageOperations/multiReceiptsExtractor.spec.ts b/tests/v1/extraction/multiReceiptsExtractor.spec.ts similarity index 95% rename from tests/v1/imageOperations/multiReceiptsExtractor.spec.ts rename to tests/v1/extraction/multiReceiptsExtractor.spec.ts index 46c61a8f..218da8f4 100644 --- a/tests/v1/imageOperations/multiReceiptsExtractor.spec.ts +++ b/tests/v1/extraction/multiReceiptsExtractor.spec.ts @@ -1,8 +1,8 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import path from "path"; -import { MultiReceiptsDetectorV1 } from "@/product/index.js"; -import { extractReceipts } from "@/imageOperations/index.js"; +import { MultiReceiptsDetectorV1 } from "@/v1/product/index.js"; +import { extractReceipts } from "@/v1/extraction/index.js"; import { PathInput } from "@/index.js"; import { V1_PRODUCT_PATH } from "../../index.js"; diff --git a/tests/v1/imageOperations/multiReceiptsReconstruction.integration.ts b/tests/v1/extraction/multiReceiptsReconstruction.integration.ts similarity index 96% rename from tests/v1/imageOperations/multiReceiptsReconstruction.integration.ts rename to tests/v1/extraction/multiReceiptsReconstruction.integration.ts index 5e15b07c..04b77c00 100644 --- a/tests/v1/imageOperations/multiReceiptsReconstruction.integration.ts +++ b/tests/v1/extraction/multiReceiptsReconstruction.integration.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import * as path from "path"; -import { Client, PathInput } from "@/index.js"; -import { MultiReceiptsDetectorV1, ReceiptV5 } from "@/product/index.js"; -import { extractReceipts } from "@/imageOperations/index.js"; +import { Client } from "@/v1/index.js"; +import { MultiReceiptsDetectorV1, ReceiptV5 } from "@/v1/product/index.js"; +import { extractReceipts } from "@/v1/extraction/index.js"; import { V1_PRODUCT_PATH } from "../../index.js"; -import { LocalInputSource } from "@/input/index.js"; +import { LocalInputSource, PathInput } from "@/input/index.js"; import { setTimeout } from "node:timers/promises"; const apiKey = process.env.MINDEE_API_KEY; diff --git a/tests/v1/imageOperations/multiReceiptsReconstruction.spec.ts b/tests/v1/extraction/multiReceiptsReconstruction.spec.ts similarity index 93% rename from tests/v1/imageOperations/multiReceiptsReconstruction.spec.ts rename to tests/v1/extraction/multiReceiptsReconstruction.spec.ts index 3890fffc..3cc3efec 100644 --- a/tests/v1/imageOperations/multiReceiptsReconstruction.spec.ts +++ b/tests/v1/extraction/multiReceiptsReconstruction.spec.ts @@ -1,9 +1,10 @@ import { expect } from "chai"; import { promises as fs } from "fs"; import * as path from "path"; -import { Document, PathInput } from "@/index.js"; -import { MultiReceiptsDetectorV1 } from "@/product/index.js"; -import { extractReceipts } from "@/imageOperations/index.js"; +import { PathInput } from "@/index.js"; +import { Document } from "@/v1/index.js"; +import { MultiReceiptsDetectorV1 } from "@/v1/product/index.js"; +import { extractReceipts } from "@/v1/extraction/index.js"; import { RESOURCE_PATH, V1_PRODUCT_PATH } from "../../index.js"; const rotations = [ diff --git a/tests/v1/extras/extras.integration.ts b/tests/v1/extras/extras.integration.ts index f58ad306..2d8faeb1 100644 --- a/tests/v1/extras/extras.integration.ts +++ b/tests/v1/extras/extras.integration.ts @@ -5,10 +5,10 @@ import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - Extras Integration Tests", async () => { - let client: mindee.Client; + let client: mindee.v1.Client; beforeEach(() => { - client = new mindee.Client(); + client = new mindee.v1.Client(); }); it("should send cropper extra", async () => { @@ -17,7 +17,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { }); await sample.init(); const response = await client.parse( - mindee.product.InvoiceV4, sample, { cropper: true } + mindee.v1.product.InvoiceV4, sample, { cropper: true } ); expect(response.document.inference.pages[0]?.extras?.cropper).to.exist; }).timeout(70000); @@ -28,7 +28,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { }); await sample.init(); const response = await client.enqueueAndParse( - mindee.product.InternationalIdV2, sample, { fullText: true } + mindee.v1.product.InternationalIdV2, sample, { fullText: true } ); expect(response.document?.extras?.fullTextOcr).to.exist; @@ -40,7 +40,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { }); await sample.init(); const response = await client.parse( - mindee.product.FinancialDocumentV1, sample, { allWords: true } + mindee.v1.product.FinancialDocumentV1, sample, { allWords: true } ); expect(response.document?.ocr).to.exist; expect(response.document?.ocr?.toString()).to.not.be.empty; @@ -53,7 +53,7 @@ describe("MindeeV1 - Extras Integration Tests", async () => { }); await sample.init(); const response = await client.enqueueAndParse( - mindee.product.FinancialDocumentV1, sample, { allWords: true } + mindee.v1.product.FinancialDocumentV1, sample, { allWords: true } ); expect(response.document?.ocr).to.exist; expect(response.document?.ocr?.toString()).to.not.be.empty; diff --git a/tests/v1/extras/fullTextOcr.spec.ts b/tests/v1/extras/fullTextOcr.spec.ts index d20ae737..d91874f3 100644 --- a/tests/v1/extras/fullTextOcr.spec.ts +++ b/tests/v1/extras/fullTextOcr.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import path from "path"; import { expect } from "chai"; -import { AsyncPredictResponse } from "@/index.js"; -import { InternationalIdV2 } from "@/product/index.js"; +import { AsyncPredictResponse } from "@/v1/index.js"; +import { InternationalIdV2 } from "@/v1/product/index.js"; import { RESOURCE_PATH } from "../../index.js"; const fullTextOcrDir = path.join(RESOURCE_PATH, "v1/extras/full_text_ocr"); diff --git a/tests/v1/extras/ocr.spec.ts b/tests/v1/extras/ocr.spec.ts index 96970240..5a109348 100644 --- a/tests/v1/extras/ocr.spec.ts +++ b/tests/v1/extras/ocr.spec.ts @@ -1,8 +1,8 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; -import { ReceiptV5 } from "@/product/index.js"; -import { Document } from "@/index.js"; +import { ReceiptV5 } from "@/v1/product/index.js"; +import { Document } from "@/v1/index.js"; import { RESOURCE_PATH } from "../../index.js"; const dataPath = { diff --git a/tests/v1/input/localResponse.spec.ts b/tests/v1/input/localResponse.spec.ts index a7e74b43..43692071 100644 --- a/tests/v1/input/localResponse.spec.ts +++ b/tests/v1/input/localResponse.spec.ts @@ -1,8 +1,8 @@ import * as fs from "node:fs/promises"; import { expect } from "chai"; -import { Client, PredictResponse, AsyncPredictResponse, LocalResponse } from "@/index.js"; -import { InternationalIdV2, InvoiceV4, MultiReceiptsDetectorV1 } from "@/product/index.js"; import path from "path"; +import { AsyncPredictResponse, LocalResponse, PredictResponse } from "@/v1/index.js"; +import { InternationalIdV2, InvoiceV4, MultiReceiptsDetectorV1 } from "@/v1/product/index.js"; import { V1_RESOURCE_PATH, V1_PRODUCT_PATH } from "../../index.js"; const signature: string = "5ed1673e34421217a5dbfcad905ee62261a3dd66c442f3edd19302072bbf70d0"; @@ -50,8 +50,7 @@ describe("MindeeV1 - Load Local Response", () => { it("should load into a sync prediction.", async () => { const fileObj = await fs.readFile(multiReceiptsDetectorPath, { encoding: "utf-8" }); const localResponse = new LocalResponse(fileObj); - const dummyClient = new Client({ apiKey: "dummy-key" }); - const prediction = await dummyClient.loadPrediction(MultiReceiptsDetectorV1, localResponse); + const prediction = await localResponse.loadPrediction(MultiReceiptsDetectorV1); expect(prediction).to.be.an.instanceof(PredictResponse); expect(JSON.stringify(prediction.getRawHttp())).to.eq(JSON.stringify(JSON.parse(fileObj))); @@ -60,8 +59,7 @@ describe("MindeeV1 - Load Local Response", () => { it("should load a failed prediction.", async () => { const fileObj = await fs.readFile(failedPath, { encoding: "utf-8" }); const localResponse = new LocalResponse(fileObj); - const dummyClient = new Client({ apiKey: "dummy-key" }); - const prediction = await dummyClient.loadPrediction(InvoiceV4, localResponse); + const prediction = await localResponse.loadPrediction(InvoiceV4); expect(prediction).to.be.an.instanceof(AsyncPredictResponse); expect((prediction as AsyncPredictResponse).job.status).to.be.eq("failed"); }); @@ -69,8 +67,7 @@ describe("MindeeV1 - Load Local Response", () => { it("should load into an async prediction.", async () => { const fileObj = await fs.readFile(internationalIdPath, { encoding: "utf-8" }); const localResponse = new LocalResponse(fileObj); - const dummyClient = new Client({ apiKey: "dummy-key" }); - const prediction = await dummyClient.loadPrediction(InternationalIdV2, localResponse); + const prediction = await localResponse.loadPrediction(InternationalIdV2); expect(prediction).to.be.an.instanceof(AsyncPredictResponse); expect(JSON.stringify(prediction.getRawHttp())).to.eq(JSON.stringify(JSON.parse(fileObj))); diff --git a/tests/v1/parsing/standard/amount.spec.ts b/tests/v1/parsing/standard/amount.spec.ts index b9e36e16..584c23f5 100644 --- a/tests/v1/parsing/standard/amount.spec.ts +++ b/tests/v1/parsing/standard/amount.spec.ts @@ -1,4 +1,4 @@ -import { AmountField } from "@/parsing/standard/index.js"; +import { AmountField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test AmountField field", () => { diff --git a/tests/v1/parsing/standard/classification.spec.ts b/tests/v1/parsing/standard/classification.spec.ts index d8ae02b8..cf7674cc 100644 --- a/tests/v1/parsing/standard/classification.spec.ts +++ b/tests/v1/parsing/standard/classification.spec.ts @@ -1,4 +1,4 @@ -import { ClassificationField } from "@/parsing/standard/index.js"; +import { ClassificationField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Classification field", () => { diff --git a/tests/v1/parsing/standard/date.spec.ts b/tests/v1/parsing/standard/date.spec.ts index 20519b2f..a928f97c 100644 --- a/tests/v1/parsing/standard/date.spec.ts +++ b/tests/v1/parsing/standard/date.spec.ts @@ -1,4 +1,4 @@ -import { DateField } from "@/parsing/standard/index.js"; +import { DateField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Date field", () => { diff --git a/tests/v1/parsing/standard/field.spec.ts b/tests/v1/parsing/standard/field.spec.ts index 01c36a10..2bcbfd07 100644 --- a/tests/v1/parsing/standard/field.spec.ts +++ b/tests/v1/parsing/standard/field.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { Field } from "@/parsing/standard/index.js"; +import { Field } from "@/v1/parsing/standard/index.js"; describe("Test different inits of Field", () => { it("Should create a Field", () => { diff --git a/tests/v1/parsing/standard/locale.spec.ts b/tests/v1/parsing/standard/locale.spec.ts index fbde7c86..01a0984b 100644 --- a/tests/v1/parsing/standard/locale.spec.ts +++ b/tests/v1/parsing/standard/locale.spec.ts @@ -1,4 +1,4 @@ -import { LocaleField } from "@/parsing/standard/index.js"; +import { LocaleField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test LocaleField field", () => { diff --git a/tests/v1/parsing/standard/orientation.spec.ts b/tests/v1/parsing/standard/orientation.spec.ts index 45ef4c20..5ec946d5 100644 --- a/tests/v1/parsing/standard/orientation.spec.ts +++ b/tests/v1/parsing/standard/orientation.spec.ts @@ -1,4 +1,4 @@ -import { OrientationField } from "@/parsing/common/index.js"; +import { OrientationField } from "@/v1/parsing/common/index.js"; import { expect } from "chai"; describe("Test Orientation field", () => { diff --git a/tests/v1/parsing/standard/paymentDetails.spec.ts b/tests/v1/parsing/standard/paymentDetails.spec.ts index b2f4c9e8..4506a35a 100644 --- a/tests/v1/parsing/standard/paymentDetails.spec.ts +++ b/tests/v1/parsing/standard/paymentDetails.spec.ts @@ -1,4 +1,4 @@ -import { PaymentDetailsField } from "@/parsing/standard/index.js"; +import { PaymentDetailsField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test PaymentDetailsField field", () => { diff --git a/tests/v1/parsing/standard/position.spec.ts b/tests/v1/parsing/standard/position.spec.ts index 8e8a4c0b..64ef3e8f 100644 --- a/tests/v1/parsing/standard/position.spec.ts +++ b/tests/v1/parsing/standard/position.spec.ts @@ -1,4 +1,4 @@ -import { PositionField } from "@/parsing/standard/index.js"; +import { PositionField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Position field", () => { diff --git a/tests/v1/parsing/standard/tax.spec.ts b/tests/v1/parsing/standard/tax.spec.ts index fb52d9ba..d5c124bb 100644 --- a/tests/v1/parsing/standard/tax.spec.ts +++ b/tests/v1/parsing/standard/tax.spec.ts @@ -1,4 +1,4 @@ -import { TaxField } from "@/parsing/standard/index.js"; +import { TaxField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test Tax field", () => { diff --git a/tests/v1/parsing/standard/text.spec.ts b/tests/v1/parsing/standard/text.spec.ts index 9eaf260c..53986db6 100644 --- a/tests/v1/parsing/standard/text.spec.ts +++ b/tests/v1/parsing/standard/text.spec.ts @@ -1,4 +1,4 @@ -import { StringField } from "@/parsing/standard/index.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; import { expect } from "chai"; describe("Test String field", () => { diff --git a/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts b/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts index cdbc159e..623524c8 100644 --- a/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts +++ b/tests/v1/product/barcodeReader/barcodeReaderV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - BarcodeReaderV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.BarcodeReaderV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.BarcodeReaderV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.codes1D.length).to.be.equals(0); expect(docPrediction.codes2D.length).to.be.equals(0); @@ -25,7 +25,7 @@ describe("MindeeV1 - BarcodeReaderV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.BarcodeReaderV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.BarcodeReaderV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/cropper/cropperV1.spec.ts b/tests/v1/product/cropper/cropperV1.spec.ts index 46be40d1..1fc19cf4 100644 --- a/tests/v1/product/cropper/cropperV1.spec.ts +++ b/tests/v1/product/cropper/cropperV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - CropperV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.CropperV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.CropperV1, response.document); const pagePrediction = doc.inference.pages[0].prediction; expect(pagePrediction.cropping.length).to.be.equals(0); }); @@ -24,14 +24,14 @@ describe("MindeeV1 - CropperV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.CropperV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.CropperV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); it("should load a complete page 0 prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.CropperV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.CropperV1, response.document); const page0 = doc.inference.pages[0]; const docString = await fs.readFile(path.join(dataPath.page0String)); expect(page0.toString()).to.be.equals(docString.toString()); diff --git a/tests/v1/product/driverLicense/driverLicenseV1.spec.ts b/tests/v1/product/driverLicense/driverLicenseV1.spec.ts index 9de62754..e9182729 100644 --- a/tests/v1/product/driverLicense/driverLicenseV1.spec.ts +++ b/tests/v1/product/driverLicense/driverLicenseV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - DriverLicenseV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.DriverLicenseV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.DriverLicenseV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.countryCode.value).to.be.undefined; expect(docPrediction.state.value).to.be.undefined; @@ -36,7 +36,7 @@ describe("MindeeV1 - DriverLicenseV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.DriverLicenseV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.DriverLicenseV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/financialDocument/financialDocumentV1.spec.ts b/tests/v1/product/financialDocument/financialDocumentV1.spec.ts index 7af1f694..b819b4eb 100644 --- a/tests/v1/product/financialDocument/financialDocumentV1.spec.ts +++ b/tests/v1/product/financialDocument/financialDocumentV1.spec.ts @@ -32,7 +32,7 @@ describe("Financial Document V1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.FinancialDocumentV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.FinancialDocumentV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.locale.value).to.be.undefined; expect(docPrediction.totalAmount.value).to.be.undefined; @@ -67,7 +67,7 @@ describe("Financial Document V1 Object initialization", async () => { it("should initialize from an invoice object", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.invoiceComplete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.FinancialDocumentV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.FinancialDocumentV1, response.document); const docString = await fs.readFile(path.join(dataPath.invoiceDocString)); expect(doc.toString()).to.be.equals(docString.toString()); }); @@ -75,7 +75,7 @@ describe("Financial Document V1 Object initialization", async () => { it("should initialize from a receipt object", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.receiptComplete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.FinancialDocumentV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.FinancialDocumentV1, response.document); const docString = await fs.readFile(path.join(dataPath.receiptDocString)); expect(doc.toString()).to.be.equals(docString.toString()); }); @@ -83,7 +83,7 @@ describe("Financial Document V1 Object initialization", async () => { it("should load a complete page 0 invoice prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.invoiceComplete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.FinancialDocumentV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.FinancialDocumentV1, response.document); const page0 = doc.inference.pages[0]; const docString = await fs.readFile(path.join(dataPath.page0InvoiceString)); expect(page0.orientation?.value).to.be.equals(0); @@ -93,7 +93,7 @@ describe("Financial Document V1 Object initialization", async () => { it("should load a complete page 0 receipt prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.receiptComplete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.FinancialDocumentV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.FinancialDocumentV1, response.document); const page0 = doc.inference.pages[0]; const docString = await fs.readFile(path.join(dataPath.page0ReceiptString)); expect(page0.orientation?.value).to.be.equals(0); diff --git a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts index 50b859cc..23a1888d 100644 --- a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts +++ b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.spec.ts @@ -4,7 +4,6 @@ import { V1_PRODUCT_PATH } from "../../../../index.js"; import { expect } from "chai"; import * as mindee from "@/index.js"; - const dataPath = { complete: path.join(V1_PRODUCT_PATH, "bank_account_details/response_v1/complete.json"), empty: path.join(V1_PRODUCT_PATH, "bank_account_details/response_v1/empty.json"), @@ -16,7 +15,7 @@ describe("MindeeV1 - BankAccountDetailsV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.BankAccountDetailsV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.BankAccountDetailsV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.iban.value).to.be.undefined; expect(docPrediction.accountHolderName.value).to.be.undefined; @@ -26,7 +25,7 @@ describe("MindeeV1 - BankAccountDetailsV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.BankAccountDetailsV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.BankAccountDetailsV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts index 7acfa6b1..1f867bd7 100644 --- a/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts +++ b/tests/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - BankAccountDetailsV2 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.BankAccountDetailsV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.BankAccountDetailsV2, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.accountHoldersNames.value).to.be.undefined; expect(docPrediction.bban.bbanBankCode).to.be.null; @@ -30,7 +30,7 @@ describe("MindeeV1 - BankAccountDetailsV2 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.BankAccountDetailsV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.BankAccountDetailsV2, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/fr/carteGrise/carteGriseV1.spec.ts b/tests/v1/product/fr/carteGrise/carteGriseV1.spec.ts index a8901599..4e57f726 100644 --- a/tests/v1/product/fr/carteGrise/carteGriseV1.spec.ts +++ b/tests/v1/product/fr/carteGrise/carteGriseV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - CarteGriseV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.CarteGriseV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.CarteGriseV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.a.value).to.be.undefined; expect(docPrediction.b.value).to.be.undefined; @@ -64,7 +64,7 @@ describe("MindeeV1 - CarteGriseV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.CarteGriseV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.CarteGriseV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/fr/energyBill/energyBillV1.spec.ts b/tests/v1/product/fr/energyBill/energyBillV1.spec.ts index 2147658b..e7a41cc6 100644 --- a/tests/v1/product/fr/energyBill/energyBillV1.spec.ts +++ b/tests/v1/product/fr/energyBill/energyBillV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - EnergyBillV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.EnergyBillV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.EnergyBillV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.invoiceNumber.value).to.be.undefined; expect(docPrediction.contractId.value).to.be.undefined; @@ -41,7 +41,7 @@ describe("MindeeV1 - EnergyBillV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.EnergyBillV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.EnergyBillV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/fr/healthCard/healthCardV1.spec.ts b/tests/v1/product/fr/healthCard/healthCardV1.spec.ts index 9185db9a..bdf2ba94 100644 --- a/tests/v1/product/fr/healthCard/healthCardV1.spec.ts +++ b/tests/v1/product/fr/healthCard/healthCardV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - HealthCardV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.HealthCardV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.HealthCardV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.givenNames.length).to.be.equals(0); expect(docPrediction.surname.value).to.be.undefined; @@ -27,7 +27,7 @@ describe("MindeeV1 - HealthCardV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.HealthCardV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.HealthCardV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/fr/idCard/idCardV1.spec.ts b/tests/v1/product/fr/idCard/idCardV1.spec.ts index c1bb3755..0bb5892b 100644 --- a/tests/v1/product/fr/idCard/idCardV1.spec.ts +++ b/tests/v1/product/fr/idCard/idCardV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - IdCardV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.IdCardV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.IdCardV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.idNumber.value).to.be.undefined; expect(docPrediction.givenNames.length).to.be.equals(0); @@ -33,14 +33,14 @@ describe("MindeeV1 - IdCardV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.IdCardV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.IdCardV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); it("should load a complete page 0 prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.IdCardV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.IdCardV1, response.document); const page0 = doc.inference.pages[0]; const docString = await fs.readFile(path.join(dataPath.page0String)); expect(page0.toString()).to.be.equals(docString.toString()); diff --git a/tests/v1/product/fr/idCard/idCardV2.spec.ts b/tests/v1/product/fr/idCard/idCardV2.spec.ts index f53de20e..bf72915e 100644 --- a/tests/v1/product/fr/idCard/idCardV2.spec.ts +++ b/tests/v1/product/fr/idCard/idCardV2.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - IdCardV2 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.IdCardV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.IdCardV2, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.nationality.value).to.be.undefined; expect(docPrediction.cardAccessNumber.value).to.be.undefined; @@ -38,14 +38,14 @@ describe("MindeeV1 - IdCardV2 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.IdCardV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.IdCardV2, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); it("should load a complete page 0 prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.IdCardV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.IdCardV2, response.document); const page0 = doc.inference.pages[0]; const docString = await fs.readFile(path.join(dataPath.page0String)); expect(page0.toString()).to.be.equals(docString.toString()); diff --git a/tests/v1/product/fr/payslip/payslipV2.spec.ts b/tests/v1/product/fr/payslip/payslipV2.spec.ts index cd07cd3a..9dde43b0 100644 --- a/tests/v1/product/fr/payslip/payslipV2.spec.ts +++ b/tests/v1/product/fr/payslip/payslipV2.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - PayslipV2 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.PayslipV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.PayslipV2, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.employee.address).to.be.null; expect(docPrediction.employee.dateOfBirth).to.be.null; @@ -65,7 +65,7 @@ describe("MindeeV1 - PayslipV2 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.PayslipV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.PayslipV2, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/fr/payslip/payslipV3.spec.ts b/tests/v1/product/fr/payslip/payslipV3.spec.ts index 22da5181..d8034a58 100644 --- a/tests/v1/product/fr/payslip/payslipV3.spec.ts +++ b/tests/v1/product/fr/payslip/payslipV3.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - PayslipV3 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.PayslipV3, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.PayslipV3, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.payPeriod.endDate).to.be.null; expect(docPrediction.payPeriod.month).to.be.null; @@ -64,7 +64,7 @@ describe("MindeeV1 - PayslipV3 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.fr.PayslipV3, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.fr.PayslipV3, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/generated/generatedList.spec.ts b/tests/v1/product/generated/generatedList.spec.ts index a93262a9..8f41be18 100644 --- a/tests/v1/product/generated/generatedList.spec.ts +++ b/tests/v1/product/generated/generatedList.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { GeneratedListField } from "@/parsing/generated"; +import { GeneratedListField } from "@/v1/parsing/generated/index.js"; describe("Generated List Field Objects", async () => { it("should properly format floats.", async () => { diff --git a/tests/v1/product/generated/generatedObject.spec.ts b/tests/v1/product/generated/generatedObject.spec.ts index 7d5aecda..976b2178 100644 --- a/tests/v1/product/generated/generatedObject.spec.ts +++ b/tests/v1/product/generated/generatedObject.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { GeneratedObjectField } from "@/parsing/generated"; +import { GeneratedObjectField } from "@/v1/parsing/generated/index.js"; describe("Generated Object Field", async () => { it("should properly format booleans.", async () => { diff --git a/tests/v1/product/generated/generatedV1.spec.ts b/tests/v1/product/generated/generatedV1.spec.ts index 834c7778..1950ee42 100644 --- a/tests/v1/product/generated/generatedV1.spec.ts +++ b/tests/v1/product/generated/generatedV1.spec.ts @@ -2,11 +2,11 @@ import { promises as fs } from "fs"; import * as path from "path"; import { expect } from "chai"; import * as mindee from "@/index.js"; -import { Page } from "@/index.js"; -import { GeneratedV1 } from "@/product/index.js"; -import { GeneratedListField, GeneratedObjectField } from "@/parsing/generated"; -import { GeneratedV1Page } from "@/product/generated/generatedV1Page"; -import { StringField } from "@/parsing/standard/index.js"; +import { Page } from "@/v1/index.js"; +import { GeneratedV1 } from "@/v1/product/index.js"; +import { GeneratedListField, GeneratedObjectField } from "@/v1/parsing/generated/index.js"; +import { GeneratedV1Page } from "@/v1/product/generated/generatedV1Page.js"; +import { StringField } from "@/v1/parsing/standard/index.js"; import { V1_PRODUCT_PATH } from "../../../index.js"; const dataPathInternationalId = { @@ -30,7 +30,7 @@ describe("Generated Document Object initialization on an OTS invoice", async () it("should load an empty document prediction", async () => { const jsonDataNA = await fs.readFile(dataPathInvoice.empty); const response = JSON.parse(jsonDataNA.toString()); - const doc = new mindee.Document(GeneratedV1, response.document); + const doc = new mindee.v1.Document(GeneratedV1, response.document); expect(doc.inference.prediction.fields.get("customer_address").value).to.be.undefined; expect(doc.inference.prediction.fields.get("customer_company_registrations").values.length).to.equals(0); expect(doc.inference.prediction.fields.get("customer_name").value).to.be.undefined; @@ -99,7 +99,7 @@ describe("Generated Document Object initialization on an OTS invoice", async () it("should load a complete document prediction", async () => { const jsonDataNA = await fs.readFile(path.resolve(dataPathInvoice.complete)); const response = JSON.parse(jsonDataNA.toString()); - const doc = new mindee.Document(GeneratedV1, response.document); + const doc = new mindee.v1.Document(GeneratedV1, response.document); expect(doc.inference.prediction.fields.get("customer_address").value).to.equals( "1954 Bloon Street West Toronto, ON, M6P 3K9 Canada" ); @@ -152,7 +152,7 @@ describe("Generated Document Object initialization on an International ID", asyn it("should load an empty document prediction", async () => { const jsonDataNA = await fs.readFile(path.resolve(dataPathInternationalId.empty)); const response = JSON.parse(jsonDataNA.toString()); - const doc = new mindee.Document(GeneratedV1, response.document); + const doc = new mindee.v1.Document(GeneratedV1, response.document); const docString = await fs.readFile(path.join(dataPathInternationalId.emptyDocString)); expect(doc.inference.prediction.fields.get("document_type")).to.be.an.instanceOf(StringField); expect(doc.inference.prediction.fields.get("document_type").value).to.be.undefined; @@ -191,7 +191,7 @@ describe("Generated Document Object initialization on an International ID", asyn it("should load a complete document prediction", async () => { const jsonDataNA = await fs.readFile(path.resolve(dataPathInternationalId.complete)); const response = JSON.parse(jsonDataNA.toString()); - const doc = new mindee.Document(GeneratedV1, response.document); + const doc = new mindee.v1.Document(GeneratedV1, response.document); expect(doc.inference.prediction.fields.get("document_type")).to.be.an.instanceOf(StringField); expect(doc.inference.prediction.fields.get("document_type").value).to.equals("NATIONAL_ID_CARD"); expect(doc.inference.prediction.fields.get("document_number")).to.be.an.instanceOf(StringField); diff --git a/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts b/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts index 8d68d075..360f151c 100644 --- a/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts +++ b/tests/v1/product/ind/indianPassport/indianPassportV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - IndianPassportV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ind.IndianPassportV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.ind.IndianPassportV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.country.value).to.be.undefined; expect(docPrediction.idNumber.value).to.be.undefined; @@ -44,7 +44,7 @@ describe("MindeeV1 - IndianPassportV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ind.IndianPassportV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.ind.IndianPassportV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/internationalId/internationalIdV2.spec.ts b/tests/v1/product/internationalId/internationalIdV2.spec.ts index 67790b13..53d1550f 100644 --- a/tests/v1/product/internationalId/internationalIdV2.spec.ts +++ b/tests/v1/product/internationalId/internationalIdV2.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - InternationalIdV2 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.InternationalIdV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.InternationalIdV2, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.documentNumber.value).to.be.undefined; expect(docPrediction.surnames.length).to.be.equals(0); @@ -39,7 +39,7 @@ describe("MindeeV1 - InternationalIdV2 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.InternationalIdV2, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.InternationalIdV2, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/invoice/invoiceV4.spec.ts b/tests/v1/product/invoice/invoiceV4.spec.ts index ab27ee89..cd7bb554 100644 --- a/tests/v1/product/invoice/invoiceV4.spec.ts +++ b/tests/v1/product/invoice/invoiceV4.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - InvoiceV4 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.InvoiceV4, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.InvoiceV4, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.locale.value).to.be.undefined; expect(docPrediction.invoiceNumber.value).to.be.undefined; @@ -48,7 +48,7 @@ describe("MindeeV1 - InvoiceV4 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.InvoiceV4, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.InvoiceV4, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts b/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts index 64fdb566..4e497ed1 100644 --- a/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts +++ b/tests/v1/product/invoiceSplitter/invoiceSplitter.integration.ts @@ -1,16 +1,16 @@ import * as mindee from "@/index.js"; -import { InvoiceSplitterV1 } from "@/product/index.js"; +import { InvoiceSplitterV1 } from "@/v1/product/index.js"; import { expect } from "chai"; -import { levenshteinRatio } from "../../../testingUtilities"; +import { levenshteinRatio } from "../../../testingUtilities.js"; import { promises as fs } from "fs"; import path from "path"; import { V1_PRODUCT_PATH } from "../../../index.js"; describe("MindeeV1 - InvoiceSplitterV1 Integration Tests", async () => { - let client: mindee.Client; + let client: mindee.v1.Client; beforeEach(() => { - client = new mindee.Client(); + client = new mindee.v1.Client(); }); it("should extract invoices in strict mode.", async () => { @@ -19,11 +19,11 @@ describe("MindeeV1 - InvoiceSplitterV1 Integration Tests", async () => { }); const response = await client.enqueueAndParse( - mindee.product.InvoiceSplitterV1, sample + mindee.v1.product.InvoiceSplitterV1, sample ); const invoiceSplitterInference = response.document?.inference; expect(invoiceSplitterInference).to.be.an.instanceof(InvoiceSplitterV1); - const invoices = await mindee.imageOperations.extractInvoices( + const invoices = await mindee.v1.extraction.extractInvoices( sample, invoiceSplitterInference as InvoiceSplitterV1 ); @@ -32,7 +32,7 @@ describe("MindeeV1 - InvoiceSplitterV1 Integration Tests", async () => { expect(invoices[1].asSource().filename).to.eq("invoice_p_1-1.pdf"); const invoiceResult = await client.parse( - mindee.product.InvoiceV4, invoices[0].asSource() + mindee.v1.product.InvoiceV4, invoices[0].asSource() ); const testStringRstInvoice = await fs.readFile( path.join(V1_PRODUCT_PATH, "invoices/response_v4/summary_full_invoice_p1.rst") diff --git a/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts b/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts index 9baefa27..8075affe 100644 --- a/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts +++ b/tests/v1/product/invoiceSplitter/invoiceSplitterV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - InvoiceSplitterV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.InvoiceSplitterV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.InvoiceSplitterV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.invoicePageGroups.length).to.be.equals(0); }); @@ -24,7 +24,7 @@ describe("MindeeV1 - InvoiceSplitterV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.InvoiceSplitterV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.InvoiceSplitterV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts b/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts index b742ceb1..cae5ef4f 100644 --- a/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts +++ b/tests/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - MultiReceiptsDetectorV1 Object initialization", async () => it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.MultiReceiptsDetectorV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.MultiReceiptsDetectorV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.receipts.length).to.be.equals(0); }); @@ -24,7 +24,7 @@ describe("MindeeV1 - MultiReceiptsDetectorV1 Object initialization", async () => it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.MultiReceiptsDetectorV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.MultiReceiptsDetectorV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/passport/passportV1.spec.ts b/tests/v1/product/passport/passportV1.spec.ts index c609e2ac..20b54b5d 100644 --- a/tests/v1/product/passport/passportV1.spec.ts +++ b/tests/v1/product/passport/passportV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - PassportV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.PassportV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.PassportV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.country.value).to.be.undefined; expect(docPrediction.idNumber.value).to.be.undefined; @@ -34,7 +34,7 @@ describe("MindeeV1 - PassportV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.PassportV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.PassportV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/receipt/receiptV5.spec.ts b/tests/v1/product/receipt/receiptV5.spec.ts index ff6b90bb..87c8e8c0 100644 --- a/tests/v1/product/receipt/receiptV5.spec.ts +++ b/tests/v1/product/receipt/receiptV5.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - ReceiptV5 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ReceiptV5, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.ReceiptV5, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.locale.value).to.be.undefined; expect(docPrediction.date.value).to.be.undefined; @@ -37,7 +37,7 @@ describe("MindeeV1 - ReceiptV5 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ReceiptV5, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.ReceiptV5, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/resume/resumeV1.spec.ts b/tests/v1/product/resume/resumeV1.spec.ts index 229a0dfa..7635a48e 100644 --- a/tests/v1/product/resume/resumeV1.spec.ts +++ b/tests/v1/product/resume/resumeV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - ResumeV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ResumeV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.ResumeV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.documentLanguage.value).to.be.undefined; expect(docPrediction.givenNames.length).to.be.equals(0); @@ -39,7 +39,7 @@ describe("MindeeV1 - ResumeV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.ResumeV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.ResumeV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts b/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts index 1536dd92..eaeca795 100644 --- a/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts +++ b/tests/v1/product/us/bankCheck/bankCheckV1.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - BankCheckV1 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.BankCheckV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.us.BankCheckV1, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.date.value).to.be.undefined; expect(docPrediction.amount.value).to.be.undefined; @@ -29,14 +29,14 @@ describe("MindeeV1 - BankCheckV1 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.BankCheckV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.us.BankCheckV1, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); it("should load a complete page 0 prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.BankCheckV1, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.us.BankCheckV1, response.document); const page0 = doc.inference.pages[0]; const docString = await fs.readFile(path.join(dataPath.page0String)); expect(page0.toString()).to.be.equals(docString.toString()); diff --git a/tests/v1/product/us/usMail/usMailV3.spec.ts b/tests/v1/product/us/usMail/usMailV3.spec.ts index cac767ed..fd51beb5 100644 --- a/tests/v1/product/us/usMail/usMailV3.spec.ts +++ b/tests/v1/product/us/usMail/usMailV3.spec.ts @@ -16,7 +16,7 @@ describe("MindeeV1 - UsMailV3 Object initialization", async () => { it("should load an empty document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.empty)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.UsMailV3, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.us.UsMailV3, response.document); const docPrediction = doc.inference.prediction; expect(docPrediction.senderName.value).to.be.undefined; expect(docPrediction.senderAddress.city).to.be.null; @@ -32,7 +32,7 @@ describe("MindeeV1 - UsMailV3 Object initialization", async () => { it("should load a complete document prediction", async () => { const jsonData = await fs.readFile(path.resolve(dataPath.complete)); const response = JSON.parse(jsonData.toString()); - const doc = new mindee.Document(mindee.product.us.UsMailV3, response.document); + const doc = new mindee.v1.Document(mindee.v1.product.us.UsMailV3, response.document); const docString = await fs.readFile(path.join(dataPath.docString)); expect(doc.toString()).to.be.equals(docString.toString()); }); diff --git a/tests/v1/workflows/workflow.integration.ts b/tests/v1/workflows/workflow.integration.ts index 319da6e5..1167af9b 100644 --- a/tests/v1/workflows/workflow.integration.ts +++ b/tests/v1/workflows/workflow.integration.ts @@ -1,20 +1,20 @@ import * as mindee from "@/index.js"; -import { ExecutionPriority } from "@/parsing/common/index.js"; +import { ExecutionPriority } from "@/v1/parsing/common/index.js"; import { expect } from "chai"; import { LocalInputSource } from "@/input/index.js"; -import { OptionalAsyncOptions } from "@/client.js"; -import { FinancialDocumentV1 } from "@/product/index.js"; -import { RAGExtra } from "@/parsing/common/extras/ragExtra.js"; +import { OptionalAsyncOptions } from "@/v1/index.js"; +import { FinancialDocumentV1 } from "@/v1/product/index.js"; +import { RAGExtra } from "@/v1/parsing/common/extras/ragExtra.js"; import path from "path"; import { V1_PRODUCT_PATH } from "../../index.js"; describe("MindeeV1 - Workflow calls", () => { - let client: mindee.Client; + let client: mindee.v1.Client; let sample: LocalInputSource; let workflowId: string; beforeEach(async () => { - client = new mindee.Client(); + client = new mindee.v1.Client(); workflowId = process.env["WORKFLOW_ID"] ?? ""; sample = new mindee.PathInput({ inputPath: path.join(V1_PRODUCT_PATH, "financial_document/default_sample.jpg") diff --git a/tests/v1/workflows/workflow.spec.ts b/tests/v1/workflows/workflow.spec.ts index 83d62eb2..edda1c51 100644 --- a/tests/v1/workflows/workflow.spec.ts +++ b/tests/v1/workflows/workflow.spec.ts @@ -3,7 +3,8 @@ import { MockAgent, setGlobalDispatcher } from "undici"; import { promises as fs } from "fs"; import path from "path"; import { RESOURCE_PATH, V1_RESOURCE_PATH } from "../../index.js"; -import { Client, PathInput } from "@/index.js"; +import { Client } from "@/v1/index.js"; +import { PathInput } from "@/index.js"; const mockAgent = new MockAgent(); setGlobalDispatcher(mockAgent); diff --git a/tests/v2/clientV2.integration.ts b/tests/v2/client.integration.ts similarity index 96% rename from tests/v2/clientV2.integration.ts rename to tests/v2/client.integration.ts index 59867519..a58515f0 100644 --- a/tests/v2/clientV2.integration.ts +++ b/tests/v2/client.integration.ts @@ -2,16 +2,16 @@ import { expect } from "chai"; import path from "node:path"; import { - ClientV2, + Client, InferenceParameters, PathInput, UrlInput, Base64Input, InferenceResponse, } from "@/index.js"; -import { Inference } from "@/parsing/v2/index.js"; -import { SimpleField } from "@/parsing/v2/field/index.js"; -import { MindeeHttpErrorV2 } from "@/errors/mindeeError.js"; +import { Inference } from "@/v2/parsing/index.js"; +import { SimpleField } from "@/v2/parsing/field/index.js"; +import { MindeeHttpErrorV2 } from "@/v2/http/index.js"; import * as fs from "node:fs"; import { RESOURCE_PATH, V2_PRODUCT_PATH, V2_RESOURCE_PATH } from "../index.js"; @@ -35,7 +35,7 @@ function checkEmptyActiveOptions(inference: Inference) { } describe("MindeeV2 – Client Integration Tests", () => { - let client: ClientV2; + let client: Client; let modelId: string; const emptyPdfPath = path.join( @@ -63,7 +63,7 @@ describe("MindeeV2 – Client Integration Tests", () => { const apiKey = process.env["MINDEE_V2_API_KEY"] ?? ""; modelId = process.env["MINDEE_V2_FINDOC_MODEL_ID"] ?? ""; - client = new ClientV2({ apiKey: apiKey, debug: true }); + client = new Client({ apiKey: apiKey, debug: true }); }); before(async () => { dataSchemaReplace = fs.readFileSync(dataSchemaReplacePath).toString(); diff --git a/tests/v2/clientV2.spec.ts b/tests/v2/client.spec.ts similarity index 94% rename from tests/v2/clientV2.spec.ts rename to tests/v2/client.spec.ts index 95363b36..03c130fc 100644 --- a/tests/v2/clientV2.spec.ts +++ b/tests/v2/client.spec.ts @@ -1,10 +1,11 @@ import { expect } from "chai"; import { MockAgent, setGlobalDispatcher } from "undici"; import path from "node:path"; -import { ClientV2, LocalResponse, PathInput, InferenceResponse } from "@/index.js"; -import { MindeeHttpErrorV2 } from "@/errors/mindeeError.js"; +import { Client, PathInput, InferenceResponse } from "@/index.js"; +import { MindeeHttpErrorV2 } from "@/v2/http/index.js"; import assert from "node:assert/strict"; import { RESOURCE_PATH, V2_RESOURCE_PATH } from "../index.js"; +import { LocalResponse } from "@/v2/index.js"; const mockAgent = new MockAgent(); setGlobalDispatcher(mockAgent); @@ -59,11 +60,11 @@ describe("MindeeV2 - ClientV2", () => { }); describe("Client configured via environment variables", () => { - let client: ClientV2; + let client: Client; beforeEach(() => { setNockInterceptors(); - client = new ClientV2({ apiKey: "dummy", debug: true, dispatcher: mockAgent }); + client = new Client({ apiKey: "dummy", debug: true, dispatcher: mockAgent }); }); it("inherits base URL, token & headers from the env / options", () => { diff --git a/tests/v2/input/inferenceParameter.spec.ts b/tests/v2/input/inferenceParameter.spec.ts index 72325c8f..eb5b3e80 100644 --- a/tests/v2/input/inferenceParameter.spec.ts +++ b/tests/v2/input/inferenceParameter.spec.ts @@ -1,9 +1,9 @@ -import { StringDict } from "@/parsing/common/index.js"; +import { StringDict } from "@/parsing/index.js"; import path from "path"; import { V2_RESOURCE_PATH } from "../../index.js"; import { InferenceParameters } from "@/index.js"; import { expect } from "chai"; -import { DataSchema } from "@/input/index.js"; +import { DataSchema } from "@/index.js"; import { promises as fs } from "fs"; let expectedDataSchemaDict: StringDict; diff --git a/tests/v2/input/localResponse.spec.ts b/tests/v2/input/localResponse.spec.ts index c8fe35a0..9e423704 100644 --- a/tests/v2/input/localResponse.spec.ts +++ b/tests/v2/input/localResponse.spec.ts @@ -1,6 +1,6 @@ import * as fs from "node:fs/promises"; import { expect } from "chai"; -import { InferenceResponse, LocalResponse } from "@/index.js"; +import { InferenceResponse, LocalResponse } from "@/v2/index.js"; import path from "path"; import { V2_RESOURCE_PATH } from "../../index.js"; diff --git a/tests/v2/parsing/inference.spec.ts b/tests/v2/parsing/inference.spec.ts index 3523780d..13a81749 100644 --- a/tests/v2/parsing/inference.spec.ts +++ b/tests/v2/parsing/inference.spec.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; import path from "node:path"; -import { LocalResponse, InferenceResponse, RawText, RagMetadata } from "@/index.js"; -import { FieldConfidence, ListField, ObjectField, SimpleField } from "@/parsing/v2/field/index.js"; +import { LocalResponse, InferenceResponse, RawText, RagMetadata } from "@/v2/index.js"; +import { FieldConfidence, ListField, ObjectField, SimpleField } from "@/v2/parsing/field/index.js"; import { promises as fs } from "node:fs"; import { Polygon } from "@/geometry/index.js"; import { V2_RESOURCE_PATH } from "../../index.js"; diff --git a/tests/v2/parsing/job.spec.ts b/tests/v2/parsing/job.spec.ts index 9e65874b..1c6a291b 100644 --- a/tests/v2/parsing/job.spec.ts +++ b/tests/v2/parsing/job.spec.ts @@ -1,8 +1,7 @@ -import { JobResponse, LocalResponse } from "@/index.js"; +import { JobResponse, LocalResponse, ErrorResponse } from "@/v2/index.js"; import path from "node:path"; import { V2_RESOURCE_PATH } from "../../index.js"; import { expect } from "chai"; -import { ErrorResponse } from "@/parsing/v2/index.js"; const jobPath = path.join(V2_RESOURCE_PATH, "job"); From 66a9cc19621c375df1fab6682d4f6beb957ba9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Tue, 13 Jan 2026 12:18:10 +0100 Subject: [PATCH 3/6] :bug: fix examples (#416) --- .../invoiceSplitterCustomSplitsTutorial.js | 25 +++++++++------ example/invoiceSplitterTutorial.js | 27 +++++++++------- example/multiReceiptsTutorial.js | 32 ++++++++++++------- 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/example/invoiceSplitterCustomSplitsTutorial.js b/example/invoiceSplitterCustomSplitsTutorial.js index 0028a6ee..95c2df57 100644 --- a/example/invoiceSplitterCustomSplitsTutorial.js +++ b/example/invoiceSplitterCustomSplitsTutorial.js @@ -1,26 +1,31 @@ -const { Client, product, imageOperations, PathInput } = require("mindee"); const { setTimeout } = require("node:timers/promises"); +const mindee = require("mindee"); -async function parseInvoicesWithCustomSplitsThreshold(customSplits) { +async function parseInvoicesWithCustomSplitsThreshold(inputPath, customSplits) { // fill in your API key or add it as an environment variable - const mindeeClient = new Client(); + const mindeeClient = new mindee.v1.Client(); // Load a file from disk - const inputSource = new PathInput( - { inputPath: "/path/to/the/file.ext" } + const inputSource = new mindee.PathInput( + { inputPath: inputPath } ); - let invoices = await imageOperations.extractInvoices(inputSource, customSplits); + let invoices = await mindee.v1.extraction.extractInvoices(inputSource, customSplits); for (const invoice of invoices) { // optional: save the documents locally invoice.saveToFile(`/tmp/invoice_p_${invoice.pageIdMin}-${invoice.pageIdMax}.pdf`); - const respInvoice = await mindeeClient.parse(product.InvoiceV4, invoice.asSource()); + const respInvoice = await mindeeClient.parse( + mindee.v1.product.InvoiceV4, invoice.asSource() + ); console.log(respInvoice.document.toString()); - await setTimeout(1000); // wait some time between requests as to not overload the server + // wait some time between requests as to not overload the server + await setTimeout(1000); } - } const customSplits = [[0, 1], [1, 2]]; -parseInvoicesWithCustomSplitsThreshold(customSplits); +parseInvoicesWithCustomSplitsThreshold( + "/path/to/the/file.ext", + customSplits +); diff --git a/example/invoiceSplitterTutorial.js b/example/invoiceSplitterTutorial.js index 03b69c08..8bdece0e 100644 --- a/example/invoiceSplitterTutorial.js +++ b/example/invoiceSplitterTutorial.js @@ -1,27 +1,32 @@ -const { Client, product, imageOperations, PathInput } = require("mindee"); const { setTimeout } = require("node:timers/promises"); +const mindee = require("mindee"); -async function parseInvoices() { +async function parseInvoices(inputPath) { // fill in your API key or add it as an environment variable - const mindeeClient = new Client(); + const mindeeClient = new mindee.v1.Client(); // Load a file from disk - const inputSource = new PathInput( - { inputPath: "/path/to/the/file.ext" } + const inputSource = new mindee.PathInput( + { inputPath: inputPath } ); const resp = await mindeeClient.enqueueAndParse( - product.InvoiceSplitterV1, inputSource + mindee.v1.product.InvoiceSplitterV1, + inputSource + ); + let invoices = await mindee.v1.extraction.extractInvoices( + inputSource, resp.document.inference ); - let invoices = await imageOperations.extractInvoices(inputSource, resp.document.inference); for (const invoice of invoices) { // optional: save the documents locally invoice.saveToFile(`/tmp/invoice_p_${invoice.pageIdMin}-${invoice.pageIdMax}.pdf`); - const respInvoice = await mindeeClient.parse(product.InvoiceV4, invoice.asSource()); + const respInvoice = await mindeeClient.parse( + mindee.v1.product.InvoiceV4, invoice.asSource() + ); console.log(respInvoice.document.toString()); - await setTimeout(1000); // wait some time between requests as to not overload the server + // wait some time between requests as to not overload the server + await setTimeout(1000); } - } -parseInvoices(); +parseInvoices("/path/to/the/file.ext"); diff --git a/example/multiReceiptsTutorial.js b/example/multiReceiptsTutorial.js index 96f77c6e..f52654a8 100644 --- a/example/multiReceiptsTutorial.js +++ b/example/multiReceiptsTutorial.js @@ -1,24 +1,32 @@ -const { Client, product, imageOperations, PathInput } = require("mindee"); const { setTimeout } = require("node:timers/promises"); +const mindee = require("mindee"); -async function parseReceipts() { +async function parseReceipts(inputPath) { // fill in your API key or add it as an environment variable - const mindeeClient = new Client(); + const mindeeClient = new mindee.v1.Client(); // Load a file from disk - const inputSource = new PathInput( - { inputPath: "/path/to/the/file.ext" } + const inputSource = new mindee.PathInput( + { inputPath: inputPath } ); - const resp = await mindeeClient.parse(product.MultiReceiptsDetectorV1, inputSource); - let receipts = await imageOperations.extractReceipts(inputSource, resp.document.inference); + const resp = await mindeeClient.parse( + mindee.v1.product.MultiReceiptsDetectorV1, inputSource + ); + let receipts = await mindee.v1.extraction.extractReceipts( + inputSource, resp.document.inference + ); for (const receipt of receipts) { - const respReceipt = await mindeeClient.parse(product.ReceiptV5, receipt.asSource()); + const respReceipt = await mindeeClient.parse( + mindee.v1.product.ReceiptV5, receipt.asSource() + ); console.log(respReceipt.document.toString()); - receipt.saveToFile(`/tmp/receipt_p${receipt.pageId}_${receipt.receiptId}.pdf`); //optional: save to a file - await setTimeout(1000); // wait some time between requests as to not overload the server - } + // optional: save to a file + receipt.saveToFile(`/tmp/receipt_p${receipt.pageId}_${receipt.receiptId}.pdf`); + // wait some time between requests as to not overload the server + await setTimeout(1000); + } } -parseReceipts(); +parseReceipts("/path/to/the/file.ext"); From 4945538db60097352d1716cddd6d812da30fec41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Wed, 14 Jan 2026 11:10:02 +0100 Subject: [PATCH 4/6] :recycle: rework v2 client parameters (#417) --- src/index.ts | 3 +- src/v2/client.ts | 102 ++++--------- src/v2/client/dataSchema.ts | 8 - src/v2/client/index.ts | 1 + src/v2/client/inferenceParameters.ts | 144 ++++++++++++++++++ src/v2/client/pollingOptions.ts | 41 +---- src/v2/http/mindeeApiV2.ts | 2 +- src/v2/index.ts | 3 +- tests/v2/client.integration.ts | 20 ++- tests/v2/client/inferenceParameter.spec.ts | 65 ++++++++ tests/v2/input/inferenceParameter.spec.ts | 49 ------ .../{input => parsing}/localResponse.spec.ts | 0 12 files changed, 251 insertions(+), 187 deletions(-) create mode 100644 src/v2/client/inferenceParameters.ts create mode 100644 tests/v2/client/inferenceParameter.spec.ts delete mode 100644 tests/v2/input/inferenceParameter.spec.ts rename tests/v2/{input => parsing}/localResponse.spec.ts (100%) diff --git a/src/index.ts b/src/index.ts index c40ab2be..06aef230 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,6 +23,7 @@ export { JobResponse, RawText, RagMetadata, + InferenceParameters, DataSchema, } from "./v2/index.js"; -export type { InferenceParameters, PollingOptions } from "./v2/index.js"; +export type { PollingOptions } from "./v2/index.js"; diff --git a/src/v2/client.ts b/src/v2/client.ts index 53e17c29..698b9ac6 100644 --- a/src/v2/client.ts +++ b/src/v2/client.ts @@ -3,62 +3,10 @@ import { Dispatcher } from "undici"; import { InputSource } from "@/input/index.js"; import { errorHandler } from "@/errors/handler.js"; import { LOG_LEVELS, logger } from "@/logger.js"; -import { StringDict } from "@/parsing/stringDict.js"; import { ErrorResponse, InferenceResponse, JobResponse } from "./parsing/index.js"; import { MindeeApiV2 } from "./http/mindeeApiV2.js"; import { MindeeHttpErrorV2 } from "./http/errors.js"; -import { PollingOptions, DataSchema } from "./client/index.js"; -import { setAsyncParams } from "./client/pollingOptions.js"; - -/** - * Parameters accepted by the asynchronous **inference** v2 endpoint. - * - * All fields are optional except `modelId`. - * - * @category ClientV2 - * @example - * const params = { - * modelId: "YOUR_MODEL_ID", - * rag: true, - * alias: "YOUR_ALIAS", - * webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"], - * pollingOptions: { - * initialDelaySec: 2, - * delaySec: 1.5, - * } - * }; - */ -export interface InferenceParameters { - /** Model ID to use for the inference. **Required** */ - modelId: string; - /** Use Retrieval-Augmented Generation during inference. */ - rag?: boolean; - /** Extract the entire text from the document as strings, and fill the `rawText` attribute. */ - rawText?: boolean; - /** Calculate bounding box polygons for values, and fill the `locations` attribute of fields. */ - polygon?: boolean; - /** Calculate confidence scores for values, and fill the `confidence` attribute of fields. - * Useful for automation.*/ - confidence?: boolean; - /** Use an alias to link the file to your own DB. If empty, no alias will be used. */ - alias?: string; - /** Additional text context used by the model during inference. - * *Not recommended*, for specific use only. */ - textContext?: string; - /** Webhook IDs to call after all processing is finished. - * If empty, no webhooks will be used. */ - webhookIds?: string[]; - /** Client-side polling configuration (see {@link PollingOptions}). */ - pollingOptions?: PollingOptions; - /** By default, the file is closed once the upload is finished. - * Set to `false` to keep it open. */ - closeFile?: boolean; - /** - * Dynamic changes to the data schema of the model for this inference. - * Not recommended, for specific use only. - */ - dataSchema?: DataSchema|StringDict|string; -} +import { InferenceParameters } from "./client/index.js"; /** * Options for the V2 Mindee Client. @@ -111,18 +59,6 @@ export class Client { logger.debug("Client V2 Initialized"); } - /** - * Checks the Data Schema. - * @param params Input Inference parameters. - */ - validateDataSchema(params: InferenceParameters): void { - if (params.dataSchema !== undefined && params.dataSchema !== null){ - if (!(params.dataSchema instanceof DataSchema)){ - params.dataSchema = new DataSchema(params.dataSchema); - } - } - } - /** * Send the document to an asynchronous endpoint and return its ID in the queue. * @param inputSource file or URL to parse. @@ -132,15 +68,18 @@ export class Client { */ async enqueueInference( inputSource: InputSource, - params: InferenceParameters + params: InferenceParameters| ConstructorParameters[0] ): Promise { if (inputSource === undefined) { throw new Error("The 'enqueue' function requires an input document."); } - this.validateDataSchema(params); + const inferenceParams = params instanceof InferenceParameters + ? params + : new InferenceParameters(params); + await inputSource.init(); - return await this.mindeeApi.reqPostInferenceEnqueue(inputSource, params); + return await this.mindeeApi.reqPostInferenceEnqueue(inputSource, inferenceParams); } /** @@ -183,9 +122,14 @@ export class Client { */ async enqueueAndGetInference( inputSource: InputSource, - params: InferenceParameters + params: InferenceParameters| ConstructorParameters[0] ): Promise { - const validatedAsyncParams = setAsyncParams(params.pollingOptions); + const inferenceParams = params instanceof InferenceParameters + ? params + : new InferenceParameters(params); + + const pollingOptions = inferenceParams.getValidatedPollingOptions(); + const enqueueResponse: JobResponse = await this.enqueueInference(inputSource, params); if (enqueueResponse.job.id === undefined || enqueueResponse.job.id.length === 0) { logger.error(`Failed enqueueing:\n${enqueueResponse.getRawHttp()}`); @@ -196,10 +140,14 @@ export class Client { `Successfully enqueued document with job id: ${queueId}.` ); - await setTimeout(validatedAsyncParams.initialDelaySec * 1000, undefined, validatedAsyncParams.initialTimerOptions); + await setTimeout( + pollingOptions.initialDelaySec * 1000, + undefined, + pollingOptions.initialTimerOptions + ); let retryCounter: number = 1; let pollResults: JobResponse = await this.getJob(queueId); - while (retryCounter < validatedAsyncParams.maxRetries) { + while (retryCounter < pollingOptions.maxRetries) { if (pollResults.job.status === "Failed") { break; } @@ -208,10 +156,14 @@ export class Client { } logger.debug( `Polling server for parsing result with queueId: ${queueId}. -Attempt no. ${retryCounter} of ${validatedAsyncParams.maxRetries}. +Attempt no. ${retryCounter} of ${pollingOptions.maxRetries}. Job status: ${pollResults.job.status}.` ); - await setTimeout(validatedAsyncParams.delaySec * 1000, undefined, validatedAsyncParams.recurringTimerOptions); + await setTimeout( + pollingOptions.delaySec * 1000, + undefined, + pollingOptions.recurringTimerOptions + ); pollResults = await this.getJob(queueId); retryCounter++; } @@ -221,7 +173,7 @@ Job status: ${pollResults.job.status}.` } throw Error( "Asynchronous parsing request timed out after " + - validatedAsyncParams.delaySec * retryCounter + + pollingOptions.delaySec * retryCounter + " seconds" ); } diff --git a/src/v2/client/dataSchema.ts b/src/v2/client/dataSchema.ts index 19787dc2..90579c9f 100644 --- a/src/v2/client/dataSchema.ts +++ b/src/v2/client/dataSchema.ts @@ -6,43 +6,35 @@ export class DataSchemaField { * Display name for the field, also impacts inference results. */ public title: string; - /** * Name of the field in the data schema. */ public name: string; - /** * Whether this field can contain multiple values. */ public isArray: boolean; - /** * Data type of the field. */ public type: string; - /** * Allowed values when type is `classification`. Leave empty for other types. */ public classificationValues?: Array; - /** * Whether to remove duplicate values in the array. * Only applicable if `is_array` is True. */ public uniqueValues?: boolean; - /** * Detailed description of what this field represents. */ public description?: string; - /** * Optional extraction guidelines. */ public guidelines?: string; - /** * Subfields when type is `nested_object`. Leave empty for other types. */ diff --git a/src/v2/client/index.ts b/src/v2/client/index.ts index c31c7b5d..a871d3bf 100644 --- a/src/v2/client/index.ts +++ b/src/v2/client/index.ts @@ -1,2 +1,3 @@ export { DataSchema } from "./dataSchema.js"; export type { PollingOptions, ValidatedPollingOptions } from "./pollingOptions.js"; +export { InferenceParameters } from "./inferenceParameters.js"; diff --git a/src/v2/client/inferenceParameters.ts b/src/v2/client/inferenceParameters.ts new file mode 100644 index 00000000..13687a30 --- /dev/null +++ b/src/v2/client/inferenceParameters.ts @@ -0,0 +1,144 @@ +import { StringDict } from "@/parsing/stringDict.js"; +import { PollingOptions, ValidatedPollingOptions } from "./pollingOptions.js"; +import { DataSchema } from "./dataSchema.js"; + +/** + * Parameters accepted by the asynchronous **inference** v2 endpoint. + * + * All fields are optional except `modelId`. + * + * @category ClientV2 + * @example + * const params = { + * modelId: "YOUR_MODEL_ID", + * rag: true, + * alias: "YOUR_ALIAS", + * webhookIds: ["YOUR_WEBHOOK_ID_1", "YOUR_WEBHOOK_ID_2"], + * pollingOptions: { + * initialDelaySec: 2, + * delaySec: 1.5, + * } + * }; + */ +export class InferenceParameters { + /** + * Model ID to use for the inference. **Required.** + */ + modelId: string; + /** + * Use Retrieval-Augmented Generation during inference. + */ + rag?: boolean; + /** + * Extract the entire text from the document as strings, and fill the `rawText` attribute. + */ + rawText?: boolean; + /** + * Calculate bounding box polygons for values, and fill the `locations` attribute of fields. + */ + polygon?: boolean; + /** + * Calculate confidence scores for values, and fill the `confidence` attribute of fields. + * Useful for automation. + */ + confidence?: boolean; + /** + * Use an alias to link the file to your own DB. + * If empty, no alias will be used. + */ + alias?: string; + /** + * Additional text context used by the model during inference. + * *Not recommended*, for specific use only. + */ + textContext?: string; + /** + * Webhook IDs to call after all processing is finished. + * If empty, no webhooks will be used. + */ + webhookIds?: string[]; + /** + * Client-side polling configuration (see {@link PollingOptions}). + */ + pollingOptions?: PollingOptions; + /** + * By default, the file is closed once the upload is finished. + * Set to `false` to keep it open. + */ + closeFile?: boolean; + /** + * Dynamic changes to the data schema of the model for this inference. + * Not recommended, for specific use only. + */ + dataSchema?: DataSchema | StringDict | string; + + constructor(params: { + modelId: string; + rag?: boolean; + rawText?: boolean; + polygon?: boolean; + confidence?: boolean; + alias?: string; + textContext?: string; + webhookIds?: string[]; + pollingOptions?: PollingOptions; + closeFile?: boolean; + dataSchema?: DataSchema | StringDict | string; + }) { + this.modelId = params.modelId; + this.rag = params.rag; + this.rawText = params.rawText; + this.polygon = params.polygon; + this.confidence = params.confidence; + this.alias = params.alias; + this.textContext = params.textContext; + this.webhookIds = params.webhookIds; + this.closeFile = params.closeFile; + this.pollingOptions = params.pollingOptions; + + if (params.dataSchema !== undefined && params.dataSchema !== null) { + if (!(params.dataSchema instanceof DataSchema)){ + this.dataSchema = new DataSchema(params.dataSchema); + } else { + this.dataSchema = params.dataSchema; + } + } + } + + /** + * Checks the values for asynchronous parsing. Returns their corrected value if they are undefined. + * @returns A valid `AsyncOptions`. + */ + getValidatedPollingOptions(): ValidatedPollingOptions { + const minDelaySec = 1; + const minInitialDelay = 1; + const minRetries = 2; + let newAsyncParams: PollingOptions; + if (this.pollingOptions === undefined) { + newAsyncParams = { + delaySec: 1.5, + initialDelaySec: 2, + maxRetries: 80 + }; + } else { + newAsyncParams = { ...this.pollingOptions }; + if ( + !newAsyncParams.delaySec || + !newAsyncParams.initialDelaySec || + !newAsyncParams.maxRetries + ) { + throw Error("Invalid polling options."); + } + if (newAsyncParams.delaySec < minDelaySec) { + throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`); + } + if (newAsyncParams.initialDelaySec < minInitialDelay) { + throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`); + } + if (newAsyncParams.maxRetries < minRetries) { + throw Error(`Cannot set retry to less than ${minRetries}.`); + } + } + return newAsyncParams as ValidatedPollingOptions; + } +} diff --git a/src/v2/client/pollingOptions.ts b/src/v2/client/pollingOptions.ts index 2ad4a5c8..0a99a5e0 100644 --- a/src/v2/client/pollingOptions.ts +++ b/src/v2/client/pollingOptions.ts @@ -1,5 +1,5 @@ /** - * Parameters for the internal polling loop in {@link ClientV2.enqueueAndGetInference | enqueueAndGetInference()}. + * Parameters for the internal polling loop in {@link v2.Client.enqueueAndGetInference | enqueueAndGetInference()}. * * Default behavior: * - `initialDelaySec` = 2s @@ -24,7 +24,6 @@ * * const inference = await client.enqueueAndGetInference(inputDoc, params); */ - export interface PollingOptions { /** Number of seconds to wait *before the first poll*. */ initialDelaySec?: number; @@ -49,41 +48,3 @@ export interface ValidatedPollingOptions extends PollingOptions { delaySec: number; maxRetries: number; } - -/** - * Checks the values for asynchronous parsing. Returns their corrected value if they are undefined. - * @param asyncParams parameters related to asynchronous parsing - * @returns A valid `AsyncOptions`. - */ -export function setAsyncParams(asyncParams: PollingOptions | undefined = undefined): ValidatedPollingOptions { - const minDelaySec = 1; - const minInitialDelay = 1; - const minRetries = 2; - let newAsyncParams: PollingOptions; - if (asyncParams === undefined) { - newAsyncParams = { - delaySec: 1.5, - initialDelaySec: 2, - maxRetries: 80 - }; - } else { - newAsyncParams = { ...asyncParams }; - if ( - !newAsyncParams.delaySec || - !newAsyncParams.initialDelaySec || - !newAsyncParams.maxRetries - ) { - throw Error("Invalid polling options."); - } - if (newAsyncParams.delaySec < minDelaySec) { - throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`); - } - if (newAsyncParams.initialDelaySec < minInitialDelay) { - throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`); - } - if (newAsyncParams.maxRetries < minRetries) { - throw Error(`Cannot set retry to less than ${minRetries}.`); - } - } - return newAsyncParams as ValidatedPollingOptions; -} diff --git a/src/v2/http/mindeeApiV2.ts b/src/v2/http/mindeeApiV2.ts index 201f750c..3f89533e 100644 --- a/src/v2/http/mindeeApiV2.ts +++ b/src/v2/http/mindeeApiV2.ts @@ -1,6 +1,6 @@ import { ApiSettingsV2 } from "./apiSettingsV2.js"; import { Dispatcher } from "undici"; -import { InferenceParameters } from "@/v2/client.js"; +import { InferenceParameters } from "@/v2/client/index.js"; import { ErrorResponse, InferenceResponse, JobResponse } from "@/v2/parsing/index.js"; import { sendRequestAndReadResponse, BaseHttpResponse } from "@/http/apiCore.js"; import { InputSource, LocalInputSource, UrlInput } from "@/input/index.js"; diff --git a/src/v2/index.ts b/src/v2/index.ts index d36b8748..b9f968f6 100644 --- a/src/v2/index.ts +++ b/src/v2/index.ts @@ -10,6 +10,5 @@ export { RagMetadata, ErrorResponse, } from "./parsing/index.js"; -export type { InferenceParameters } from "./client.js"; -export { DataSchema } from "./client/index.js"; +export { InferenceParameters, DataSchema } from "./client/index.js"; export type { PollingOptions } from "./client/index.js"; diff --git a/tests/v2/client.integration.ts b/tests/v2/client.integration.ts index a58515f0..1dcb4e44 100644 --- a/tests/v2/client.integration.ts +++ b/tests/v2/client.integration.ts @@ -71,7 +71,7 @@ describe("MindeeV2 – Client Integration Tests", () => { it("Empty, multi-page PDF – PathInput - enqueueAndGetInference must succeed", async () => { const source = new PathInput({ inputPath: emptyPdfPath }); - const params: InferenceParameters = { + const params = { modelId, rag: false, rawText: false, @@ -80,7 +80,6 @@ describe("MindeeV2 – Client Integration Tests", () => { webhookIds: [], alias: "ts_integration_empty_multiple" }; - const response = await client.enqueueAndGetInference(source, params); expect(response).to.exist; @@ -98,7 +97,7 @@ describe("MindeeV2 – Client Integration Tests", () => { it("Filled, single-page image – PathInput - enqueueAndGetInference must succeed", async () => { const source = new PathInput({ inputPath: sampleImagePath }); - const params: InferenceParameters = { + const params = { modelId, rag: false, rawText: true, @@ -137,7 +136,7 @@ describe("MindeeV2 – Client Integration Tests", () => { it("Filled, single-page image – Base64Input - enqueueAndGetInference must succeed", async () => { const data = fs.readFileSync(sampleBase64Path, "utf8"); const source = new Base64Input({ inputString: data, filename: "receipt.jpg" }); - const params: InferenceParameters = { + const params = new InferenceParameters({ modelId, rag: false, rawText: false, @@ -145,7 +144,7 @@ describe("MindeeV2 – Client Integration Tests", () => { confidence: false, webhookIds: [], alias: "ts_integration_base64_filled_single" - }; + }); const response = await client.enqueueAndGetInference(source, params); @@ -166,7 +165,7 @@ describe("MindeeV2 – Client Integration Tests", () => { it("Invalid model ID – enqueue must raise 422", async () => { const source = new PathInput({ inputPath: emptyPdfPath }); - const badParams: InferenceParameters = { modelId: "00000000-0000-0000-0000-000000000000" }; + const badParams = { modelId: "00000000-0000-0000-0000-000000000000" }; try { await client.enqueueInference(source, badParams); @@ -188,7 +187,7 @@ describe("MindeeV2 – Client Integration Tests", () => { it("HTTPS URL – enqueue & get inference must succeed", async () => { const url = process.env.MINDEE_V2_SE_TESTS_BLANK_PDF_URL ?? "error-no-url-found"; const source = new UrlInput({ url }); - const params: InferenceParameters = { + const params = new InferenceParameters({ modelId, rag: false, rawText: false, @@ -196,8 +195,7 @@ describe("MindeeV2 – Client Integration Tests", () => { confidence: false, webhookIds: [], alias: "ts_integration_url_source" - }; - + }); const response: InferenceResponse = await client.enqueueAndGetInference(source, params); expect(response).to.exist; @@ -206,7 +204,7 @@ describe("MindeeV2 – Client Integration Tests", () => { it("Data Schema Override - Overrides the data schema successfully", async () => { const source = new PathInput({ inputPath: emptyPdfPath }); - const params: InferenceParameters = { + const params = new InferenceParameters({ modelId, rag: false, rawText: false, @@ -215,7 +213,7 @@ describe("MindeeV2 – Client Integration Tests", () => { webhookIds: [], dataSchema: dataSchemaReplace, alias: "ts_integration_data_schema_replace" - }; + }); const response = await client.enqueueAndGetInference(source, params); expect(response).to.exist; diff --git a/tests/v2/client/inferenceParameter.spec.ts b/tests/v2/client/inferenceParameter.spec.ts new file mode 100644 index 00000000..a3fab355 --- /dev/null +++ b/tests/v2/client/inferenceParameter.spec.ts @@ -0,0 +1,65 @@ +import { StringDict } from "@/parsing/index.js"; +import path from "path"; +import { V2_RESOURCE_PATH } from "../../index.js"; +import { InferenceParameters } from "@/index.js"; +import { expect } from "chai"; +import { DataSchema } from "@/index.js"; +import { promises as fs } from "fs"; + +let expectedDataSchemaDict: StringDict; +let expectedDataSchemaString: string; +let expectedDataSchemaObject: DataSchema; + +describe("MindeeV2 - Inference Parameter", () => { + const modelIdValue = "test-model-id"; + + describe("Polling Options", () => { + it("should provide sensible defaults", () => { + + const paramsInstance = new InferenceParameters({ + modelId: modelIdValue, + }); + expect(paramsInstance.modelId).to.equal(modelIdValue); + expect(paramsInstance.getValidatedPollingOptions()).to.deep.equal({ + delaySec: 1.5, + initialDelaySec: 2, + maxRetries: 80 + }); + }); + }); + + describe("Data Schema", () => { + before(async () => { + const fileContents = await fs.readFile(path.join(V2_RESOURCE_PATH, "inference/data_schema_replace_param.json")); + expectedDataSchemaDict = JSON.parse(fileContents.toString()); + expectedDataSchemaString = JSON.stringify(expectedDataSchemaDict); + expectedDataSchemaObject = new DataSchema(expectedDataSchemaDict); + }); + + it("shouldn't replace when unset", () => { + const params = new InferenceParameters({ + modelId: modelIdValue, + }); + expect(params.dataSchema).to.be.undefined; + }); + + it("should equate no matter the type", () => { + const paramsDict = new InferenceParameters({ + modelId: modelIdValue, + dataSchema: expectedDataSchemaDict, + }); + const paramsString = new InferenceParameters({ + modelId: modelIdValue, + dataSchema: expectedDataSchemaString, + }); + const paramsObject = new InferenceParameters({ + modelId: modelIdValue, + dataSchema: expectedDataSchemaObject, + }); + + expect(JSON.stringify(paramsDict.dataSchema)).to.eq(expectedDataSchemaString); + expect(paramsObject.dataSchema?.toString()).to.eq(expectedDataSchemaString); + expect(paramsString.dataSchema?.toString()).to.eq(expectedDataSchemaString); + }); + }); +}); diff --git a/tests/v2/input/inferenceParameter.spec.ts b/tests/v2/input/inferenceParameter.spec.ts deleted file mode 100644 index eb5b3e80..00000000 --- a/tests/v2/input/inferenceParameter.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { StringDict } from "@/parsing/index.js"; -import path from "path"; -import { V2_RESOURCE_PATH } from "../../index.js"; -import { InferenceParameters } from "@/index.js"; -import { expect } from "chai"; -import { DataSchema } from "@/index.js"; -import { promises as fs } from "fs"; - -let expectedDataSchemaDict: StringDict; -let expectedDataSchemaString: string; -let expectedDataSchemaObject: DataSchema; - -describe("MindeeV2 - Inference Parameter", () => { - before(async () => { - const fileContents = await fs.readFile(path.join(V2_RESOURCE_PATH, "inference/data_schema_replace_param.json")); - expectedDataSchemaDict = JSON.parse(fileContents.toString()); - expectedDataSchemaString = JSON.stringify(expectedDataSchemaDict); - expectedDataSchemaObject = new DataSchema(expectedDataSchemaDict); - }); - - describe("dataSchema", () => { - it("shouldn't replace when unset", async () => { - const params: InferenceParameters = { - modelId: "test-model-id", - }; - - expect(params.dataSchema).to.be.undefined; - }); - - it("should equate no matter the type", async () => { - const paramsDict: InferenceParameters = { - modelId: "test-model-id", - dataSchema: expectedDataSchemaDict, - }; - const paramsString: InferenceParameters = { - modelId: "test-model-id", - dataSchema: expectedDataSchemaString, - }; - const paramsObject: InferenceParameters = { - modelId: "test-model-id", - dataSchema: expectedDataSchemaObject, - }; - - expect(JSON.stringify(paramsDict.dataSchema)).to.eq(expectedDataSchemaString); - expect(paramsObject.dataSchema?.toString()).to.eq(expectedDataSchemaString); - expect(paramsString.dataSchema?.toString()).to.eq(expectedDataSchemaString); - }); - }); -}); diff --git a/tests/v2/input/localResponse.spec.ts b/tests/v2/parsing/localResponse.spec.ts similarity index 100% rename from tests/v2/input/localResponse.spec.ts rename to tests/v2/parsing/localResponse.spec.ts From 2226550e443ba832db78ec328374553e6c187b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9=20s=C3=A9vi?= Date: Wed, 21 Jan 2026 16:30:20 +0100 Subject: [PATCH 5/6] rework input source errors --- src/errors/index.ts | 2 +- src/errors/mindeeError.ts | 17 ++++++-------- src/input/localInputSource.ts | 22 +++++++------------ .../invoiceSplitterExtractor.ts | 10 ++++++--- .../multiReceiptsExtractor.ts | 4 ++-- 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/errors/index.ts b/src/errors/index.ts index 5789ab53..726e67f7 100644 --- a/src/errors/index.ts +++ b/src/errors/index.ts @@ -1,8 +1,8 @@ export { MindeeError, - MindeeMimeTypeError, MindeeImageError, MindeePdfError, MindeeDeserializationError, MindeeConfigurationError, + MindeeInputSourceError, } from "./mindeeError.js"; diff --git a/src/errors/mindeeError.ts b/src/errors/mindeeError.ts index 0274f8b3..b3e65a2d 100644 --- a/src/errors/mindeeError.ts +++ b/src/errors/mindeeError.ts @@ -8,16 +8,6 @@ export class MindeeError extends Error { } } -/** - * Custom Mindee error relating to improper mimetypes in inputs. - */ -export class MindeeMimeTypeError extends MindeeError { - constructor(message: string) { - super(message); - this.name = "MindeeMimeTypeError"; - } -} - export class MindeeImageError extends MindeeError { constructor(message: string) { super(message); @@ -45,3 +35,10 @@ export class MindeePdfError extends MindeeError { this.name = "MindeePdfError"; } } + +export class MindeeInputSourceError extends MindeeError { + constructor(message: string) { + super(message); + this.name = "MindeeInputSourceError"; + } +} diff --git a/src/input/localInputSource.ts b/src/input/localInputSource.ts index 68af1c1b..ec27955a 100644 --- a/src/input/localInputSource.ts +++ b/src/input/localInputSource.ts @@ -1,8 +1,9 @@ +import path from "path"; +import { MindeeInputSourceError } from "@/errors/index.js"; import { errorHandler } from "@/errors/handler.js"; import { logger } from "@/logger.js"; import { compressImage } from "@/image/index.js"; import { compressPdf, countPages, extractPages, hasSourceText } from "@/pdf/index.js"; -import path from "path"; import { fileTypeFromBuffer } from "file-type"; import { PageOptions } from "../input/pageOptions.js"; import { @@ -49,7 +50,7 @@ export abstract class LocalInputSource extends InputSource { if (!ALLOWED_INPUT_TYPES.includes(inputType)) { const allowed = Array.from(ALLOWED_INPUT_TYPES.keys()).join(", "); errorHandler.throw( - new Error(`Invalid input type, must be one of ${allowed}.`) + new MindeeInputSourceError(`Invalid input type, must be one of ${allowed}.`) ); } this.inputType = inputType; @@ -58,7 +59,7 @@ export abstract class LocalInputSource extends InputSource { protected async checkMimetype(): Promise { if (!(this.fileObject instanceof Buffer)) { - throw new Error( + throw new MindeeInputSourceError( `MIME type cannot be verified on input source of type ${this.inputType}.` ); } @@ -76,7 +77,9 @@ export abstract class LocalInputSource extends InputSource { } if (!mimeType) { const allowed = Array.from(MIMETYPES.keys()).join(", "); - const err = new Error(`Invalid file type, must be one of ${allowed}.`); + const err = new MindeeInputSourceError( + `Invalid file type, must be one of ${allowed}.` + ); errorHandler.throw(err); } logger.debug(`File is of type: ${mimeType}`); @@ -101,7 +104,7 @@ export abstract class LocalInputSource extends InputSource { */ isPdf(): boolean { if (!this.initialized) { - throw new Error( + throw new MindeeInputSourceError( "The `init()` method must be called before calling `isPdf()`." ); } @@ -119,15 +122,6 @@ export abstract class LocalInputSource extends InputSource { this.fileObject = processedPdf.file; } - /** - * Cut PDF pages. - * @param pageOptions - * @deprecated Deprecated in favor of {@link LocalInputSource.applyPageOptions}. - */ - async cutPdf(pageOptions: PageOptions) { - return this.applyPageOptions(pageOptions); - } - /** * Compresses the file object, either as a PDF or an image. * diff --git a/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts b/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts index cfc14cb9..e38916aa 100644 --- a/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts +++ b/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.ts @@ -1,5 +1,5 @@ import { PDFDocument } from "@cantoo/pdf-lib"; -import { MindeeError, MindeeMimeTypeError } from "@/errors/index.js"; +import { MindeeError, MindeeInputSourceError } from "@/errors/index.js"; import { InvoiceSplitterV1 } from "@/v1/product/index.js"; import { LocalInputSource } from "@/input/index.js"; import { ExtractedInvoiceSplitterImage } from "./extractedInvoiceSplitterImage.js"; @@ -32,7 +32,9 @@ async function splitPdf(pdfDoc: PDFDocument, invoicePageGroups: number[][]): Pro async function getPdfDoc(inputFile: LocalInputSource): Promise { await inputFile.init(); if (!inputFile.isPdf()) { - throw new MindeeMimeTypeError("Invoice Splitter is only compatible with pdf documents."); + throw new MindeeInputSourceError( + "Invoice Splitter is only compatible with PDF documents." + ); } const pdfDoc = await PDFDocument.load(inputFile.fileObject, { @@ -40,7 +42,9 @@ async function getPdfDoc(inputFile: LocalInputSource): Promise { password: "" }); if (pdfDoc.getPageCount() < 2) { - throw new MindeeError("Invoice Splitter is only compatible with multi-page-pdf documents."); + throw new MindeeInputSourceError( + "Invoice Splitter is only compatible with multi-page PDF documents." + ); } return pdfDoc; } diff --git a/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts b/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts index ce830799..5ffb783d 100644 --- a/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts +++ b/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.ts @@ -1,5 +1,5 @@ import { PDFDocument, PDFImage, PDFPage, degrees } from "@cantoo/pdf-lib"; -import { MindeeError, MindeeMimeTypeError } from "@/errors/index.js"; +import { MindeeError, MindeeInputSourceError } from "@/errors/index.js"; import { Polygon } from "@/geometry/index.js"; import { MultiReceiptsDetectorV1 } from "@/v1/product/index.js"; import { ExtractedMultiReceiptImage } from "./extractedMultiReceiptImage.js"; @@ -31,7 +31,7 @@ async function extractReceiptsFromPage( async function loadPdfDoc(inputFile: LocalInputSource) { let pdfDoc: PDFDocument; if (!["image/jpeg", "image/jpg", "image/png", "application/pdf"].includes(inputFile.mimeType)) { - throw new MindeeMimeTypeError( + throw new MindeeInputSourceError( 'Unsupported file type "' + inputFile.mimeType + '" Currently supported types are .png, .jpg and .pdf' From c2ec82c773d974fd1f40637dacd6bc64343b3f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9=20s=C3=A9vi?= Date: Wed, 21 Jan 2026 19:01:24 +0100 Subject: [PATCH 6/6] :recycle: separate error and job parsing classes --- package.json | 1 + .../{commonResponse.ts => baseResponse.ts} | 6 ++++- src/v2/parsing/error/errorDetails.ts | 24 +++++++++++++++++++ src/v2/parsing/{ => error}/errorItem.ts | 0 src/v2/parsing/{ => error}/errorResponse.ts | 24 +------------------ src/v2/parsing/error/index.ts | 3 +++ src/v2/parsing/index.ts | 18 ++++++++------ src/v2/parsing/inferenceResponse.ts | 4 ++-- src/v2/parsing/job/index.ts | 3 +++ src/v2/parsing/{ => job}/job.ts | 5 ++-- src/v2/parsing/{ => job}/jobResponse.ts | 4 ++-- src/v2/parsing/{ => job}/jobWebhook.ts | 4 ++-- src/v2/parsing/localResponse.ts | 4 ++-- tests/data | 2 +- 14 files changed, 59 insertions(+), 43 deletions(-) rename src/v2/parsing/{commonResponse.ts => baseResponse.ts} (66%) create mode 100644 src/v2/parsing/error/errorDetails.ts rename src/v2/parsing/{ => error}/errorItem.ts (100%) rename src/v2/parsing/{ => error}/errorResponse.ts (63%) create mode 100644 src/v2/parsing/error/index.ts create mode 100644 src/v2/parsing/job/index.ts rename src/v2/parsing/{ => job}/job.ts (90%) rename src/v2/parsing/{ => job}/jobResponse.ts (71%) rename src/v2/parsing/{ => job}/jobWebhook.ts (83%) diff --git a/package.json b/package.json index e182aa9a..bb25e9a4 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "clean": "rm -rf ./dist ./docs/_build", "test": "mocha \"tests/**/*.spec.ts\"", "test-integration": "mocha \"tests/**/*.integration.ts\"", + "test-v2": "mocha \"tests/v2/**/*.spec.ts\"", "lint": "tsc --noEmit && eslint './src/**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'", "lint-fix": "eslint './src/**/*.ts' --fix", "docs": "typedoc --out docs/_build ./src/index.ts", diff --git a/src/v2/parsing/commonResponse.ts b/src/v2/parsing/baseResponse.ts similarity index 66% rename from src/v2/parsing/commonResponse.ts rename to src/v2/parsing/baseResponse.ts index 21a81e3e..b2068107 100644 --- a/src/v2/parsing/commonResponse.ts +++ b/src/v2/parsing/baseResponse.ts @@ -1,7 +1,8 @@ import { StringDict } from "@/parsing/stringDict.js"; +import { logger } from "@/logger.js"; -export abstract class CommonResponse { +export abstract class BaseResponse { /** * Raw text representation of the API's response. */ @@ -12,6 +13,7 @@ export abstract class CommonResponse { */ protected constructor(serverResponse: StringDict) { this.rawHttp = serverResponse; + logger.debug("Constructing response instance from plain object."); } /** @@ -22,3 +24,5 @@ export abstract class CommonResponse { return this.rawHttp; } } + +export type ResponseConstructor = new (serverResponse: StringDict) => T; diff --git a/src/v2/parsing/error/errorDetails.ts b/src/v2/parsing/error/errorDetails.ts new file mode 100644 index 00000000..6989e1ef --- /dev/null +++ b/src/v2/parsing/error/errorDetails.ts @@ -0,0 +1,24 @@ +import { ErrorItem } from "./errorItem.js"; + +export interface ErrorDetails { + /** + * The HTTP status code returned by the server. + */ + status: number; + /** + * A human-readable explanation specific to the occurrence of the problem. + */ + detail: string; + /** + * A short, human-readable summary of the problem. + */ + title: string; + /** + * A machine-readable code specific to the occurrence of the problem. + */ + code: string; + /** + * A list of explicit error details. + */ + errors: ErrorItem[]; +} diff --git a/src/v2/parsing/errorItem.ts b/src/v2/parsing/error/errorItem.ts similarity index 100% rename from src/v2/parsing/errorItem.ts rename to src/v2/parsing/error/errorItem.ts diff --git a/src/v2/parsing/errorResponse.ts b/src/v2/parsing/error/errorResponse.ts similarity index 63% rename from src/v2/parsing/errorResponse.ts rename to src/v2/parsing/error/errorResponse.ts index 4510ef78..f32ab273 100644 --- a/src/v2/parsing/errorResponse.ts +++ b/src/v2/parsing/error/errorResponse.ts @@ -1,28 +1,6 @@ import { StringDict } from "@/parsing/stringDict.js"; import { ErrorItem } from "./errorItem.js"; - -export interface ErrorDetails { - /** - * The HTTP status code returned by the server. - */ - status: number; - /** - * A human-readable explanation specific to the occurrence of the problem. - */ - detail: string; - /** - * A short, human-readable summary of the problem. - */ - title: string; - /** - * A machine-readable code specific to the occurrence of the problem. - */ - code: string; - /** - * A list of explicit error details. - */ - errors: ErrorItem[]; -} +import { ErrorDetails } from "./errorDetails.js"; /** * Error response detailing a problem. The format adheres to RFC 9457. diff --git a/src/v2/parsing/error/index.ts b/src/v2/parsing/error/index.ts new file mode 100644 index 00000000..93166e73 --- /dev/null +++ b/src/v2/parsing/error/index.ts @@ -0,0 +1,3 @@ +export { ErrorResponse } from "./errorResponse.js"; +export { ErrorItem } from "./errorItem.js"; +export type { ErrorDetails } from "./errorDetails.js"; diff --git a/src/v2/parsing/index.ts b/src/v2/parsing/index.ts index 6e952e0b..60652919 100644 --- a/src/v2/parsing/index.ts +++ b/src/v2/parsing/index.ts @@ -1,11 +1,15 @@ -export { ErrorResponse } from "./errorResponse.js"; -export type { ErrorDetails } from "./errorResponse.js"; -export { ErrorItem } from "./errorItem.js"; -export { Job } from "./job.js"; -export { JobResponse } from "./jobResponse.js"; -export { JobWebhook } from "./jobWebhook.js"; +export { + ErrorResponse, + ErrorItem, +} from "./error/index.js"; +export type { ErrorDetails } from "./error/index.js"; +export { + Job, + JobResponse, + JobWebhook, +} from "./job/index.js"; export { InferenceFile } from "./inferenceFile.js"; -export { CommonResponse } from "./commonResponse.js"; +export { BaseResponse } from "./baseResponse.js"; export { Inference } from "./inference.js"; export { InferenceActiveOptions } from "./inferenceActiveOptions.js"; export { InferenceModel } from "./inferenceModel.js"; diff --git a/src/v2/parsing/inferenceResponse.ts b/src/v2/parsing/inferenceResponse.ts index 7c63d894..95090df2 100644 --- a/src/v2/parsing/inferenceResponse.ts +++ b/src/v2/parsing/inferenceResponse.ts @@ -1,8 +1,8 @@ -import { CommonResponse } from "./commonResponse.js"; +import { BaseResponse } from "./baseResponse.js"; import { Inference } from "./inference.js"; import { StringDict } from "@/parsing/stringDict.js"; -export class InferenceResponse extends CommonResponse { +export class InferenceResponse extends BaseResponse { /** * Inference result. */ diff --git a/src/v2/parsing/job/index.ts b/src/v2/parsing/job/index.ts new file mode 100644 index 00000000..e67e54a2 --- /dev/null +++ b/src/v2/parsing/job/index.ts @@ -0,0 +1,3 @@ +export { Job } from "./job.js"; +export { JobResponse } from "./jobResponse.js"; +export { JobWebhook } from "./jobWebhook.js"; diff --git a/src/v2/parsing/job.ts b/src/v2/parsing/job/job.ts similarity index 90% rename from src/v2/parsing/job.ts rename to src/v2/parsing/job/job.ts index 66183cf0..f1262428 100644 --- a/src/v2/parsing/job.ts +++ b/src/v2/parsing/job/job.ts @@ -1,7 +1,6 @@ -import { StringDict } from "@/parsing/stringDict.js"; -import { ErrorResponse } from "./errorResponse.js"; +import { StringDict, parseDate } from "@/parsing/index.js"; +import { ErrorResponse } from "@/v2/index.js"; import { JobWebhook } from "./jobWebhook.js"; -import { parseDate } from "@/v1/parsing/common/index.js"; /** * Job information for a V2 polling attempt. diff --git a/src/v2/parsing/jobResponse.ts b/src/v2/parsing/job/jobResponse.ts similarity index 71% rename from src/v2/parsing/jobResponse.ts rename to src/v2/parsing/job/jobResponse.ts index 7abef720..2d42a89a 100644 --- a/src/v2/parsing/jobResponse.ts +++ b/src/v2/parsing/job/jobResponse.ts @@ -1,8 +1,8 @@ -import { CommonResponse } from "./commonResponse.js"; +import { BaseResponse } from "@/v2/parsing/baseResponse.js"; import { StringDict } from "@/parsing/stringDict.js"; import { Job } from "./job.js"; -export class JobResponse extends CommonResponse { +export class JobResponse extends BaseResponse { /** * Job for the polling. */ diff --git a/src/v2/parsing/jobWebhook.ts b/src/v2/parsing/job/jobWebhook.ts similarity index 83% rename from src/v2/parsing/jobWebhook.ts rename to src/v2/parsing/job/jobWebhook.ts index 4de7d01c..48491e95 100644 --- a/src/v2/parsing/jobWebhook.ts +++ b/src/v2/parsing/job/jobWebhook.ts @@ -1,5 +1,5 @@ -import { ErrorResponse } from "./errorResponse.js"; -import { StringDict, parseDate } from "@/v1/parsing/common/index.js"; +import { ErrorResponse } from "@/v2/parsing/index.js"; +import { StringDict, parseDate } from "@/parsing/index.js"; /** * JobWebhook information. diff --git a/src/v2/parsing/localResponse.ts b/src/v2/parsing/localResponse.ts index dd2a36c2..4f0399ab 100644 --- a/src/v2/parsing/localResponse.ts +++ b/src/v2/parsing/localResponse.ts @@ -1,6 +1,6 @@ import { StringDict } from "@/parsing/stringDict.js"; import { MindeeError } from "@/errors/index.js"; -import { CommonResponse } from "@/v2/parsing/index.js"; +import { BaseResponse } from "./baseResponse.js"; import { LocalResponseBase } from "@/parsing/localResponseBase.js"; /** @@ -19,7 +19,7 @@ export class LocalResponse extends LocalResponseBase { * @returns An instance of `responseClass` populated with the file content. * @throws MindeeError If the provided class cannot be instantiated. */ - public async deserializeResponse( + public async deserializeResponse( responseClass: new (serverResponse: StringDict) => ResponseT ): Promise { try { diff --git a/tests/data b/tests/data index 359d5e88..7bed8f9b 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 359d5e88e33f95f44ac9e5d7324ff6825dfec667 +Subproject commit 7bed8f9b059f6ba3debc31e71375ea8437b6fbe2