From 2c580ab1b93c2ecfb4d8a82f039b601038a7aa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Fri, 18 Sep 2026 18:23:59 +0200 Subject: [PATCH 1/4] :wrench: add some basic unicorn rules to linter --- eslint.config.mjs | 17 +- package-lock.json | 375 ++++++++++++++++++ package.json | 3 +- src/geometry/bbox.ts | 24 +- src/geometry/boundingBox.ts | 4 +- src/geometry/minMax.ts | 12 +- src/geometry/point.ts | 4 +- src/geometry/polygon.ts | 4 +- src/http/baseSettings.ts | 20 +- src/http/dispatcher.ts | 4 +- src/image/extractedImage.ts | 18 +- src/image/extractedImages.ts | 4 +- src/input/base64Input.ts | 12 +- src/input/bufferInput.ts | 8 +- src/input/inputSource.ts | 5 +- src/input/localInputSource.ts | 24 +- src/input/pageOptions.ts | 12 +- src/input/pathInput.ts | 16 +- src/input/streamInput.ts | 16 +- src/input/urlInput.ts | 24 +- src/parsing/baseLocalResponse.ts | 8 +- src/parsing/stringDict.ts | 4 +- src/pdf/extractedPdf.ts | 20 +- src/pdf/extractedPdfs.ts | 4 +- src/pdf/pdfOperation.ts | 13 +- src/v1/client.ts | 56 ++- .../extractedInvoiceSplitterImage.ts | 8 +- .../extractedMultiReceiptImage.ts | 8 +- src/v1/http/apiSettingsV1.ts | 20 +- src/v1/http/baseEndpoint.ts | 8 +- src/v1/http/endpoint.ts | 12 +- src/v1/http/errors.ts | 12 +- src/v1/http/httpParams.ts | 48 ++- src/v1/parsing/common/apiRequest.ts | 20 +- src/v1/parsing/common/apiResponse.ts | 8 +- src/v1/parsing/common/asyncPredictResponse.ts | 28 +- src/v1/parsing/common/document.ts | 24 +- src/v1/parsing/common/execution.ts | 52 ++- src/v1/parsing/common/executionFile.ts | 8 +- src/v1/parsing/common/executionPriority.ts | 16 +- src/v1/parsing/common/extras/cropperExtra.ts | 8 +- src/v1/parsing/common/extras/extras.ts | 12 +- .../parsing/common/extras/fullTextOcrExtra.ts | 12 +- src/v1/parsing/common/extras/ragExtra.ts | 4 +- .../common/feedback/feedbackResponse.ts | 4 +- src/v1/parsing/common/inference.ts | 32 +- src/v1/parsing/common/mvisionV1.ts | 4 +- src/v1/parsing/common/ocr.ts | 4 +- src/v1/parsing/common/ocrPage.ts | 8 +- src/v1/parsing/common/orientation.ts | 8 +- src/v1/parsing/common/page.ts | 16 +- src/v1/parsing/common/predictResponse.ts | 4 +- src/v1/parsing/common/prediction.ts | 4 +- src/v1/parsing/generated/generatedList.ts | 8 +- src/v1/parsing/generated/generatedObject.ts | 32 +- src/v1/parsing/localResponse.ts | 4 +- src/v1/parsing/standard/addressField.ts | 32 +- src/v1/parsing/standard/amount.ts | 4 +- src/v1/parsing/standard/base.ts | 36 +- src/v1/parsing/standard/boolean.ts | 4 +- src/v1/parsing/standard/classification.ts | 8 +- .../parsing/standard/companyRegistration.ts | 12 +- src/v1/parsing/standard/date.ts | 16 +- src/v1/parsing/standard/field.ts | 4 +- src/v1/parsing/standard/locale.ts | 20 +- src/v1/parsing/standard/paymentDetails.ts | 20 +- src/v1/parsing/standard/position.ts | 20 +- src/v1/parsing/standard/tax.ts | 24 +- src/v1/parsing/standard/text.ts | 8 +- src/v1/parsing/standard/word.ts | 12 +- .../product/barcodeReader/barcodeReaderV1.ts | 16 +- .../barcodeReader/barcodeReaderV1Document.ts | 8 +- src/v1/product/cropper/cropperV1.ts | 16 +- src/v1/product/cropper/cropperV1Page.ts | 4 +- .../product/driverLicense/driverLicenseV1.ts | 16 +- .../driverLicense/driverLicenseV1Document.ts | 52 ++- .../financialDocument/financialDocumentV1.ts | 16 +- .../financialDocumentV1Document.ts | 128 ++++-- .../financialDocumentV1LineItem.ts | 40 +- .../bankAccountDetailsV1.ts | 16 +- .../bankAccountDetailsV1Document.ts | 12 +- .../bankAccountDetailsV2.ts | 16 +- .../bankAccountDetailsV2Bban.ts | 24 +- .../bankAccountDetailsV2Document.ts | 16 +- src/v1/product/fr/carteGrise/carteGriseV1.ts | 16 +- .../fr/carteGrise/carteGriseV1Document.ts | 164 ++++++-- src/v1/product/fr/idCard/idCardV2.ts | 16 +- src/v1/product/fr/idCard/idCardV2Document.ts | 60 ++- src/v1/product/fr/idCard/idCardV2Page.ts | 8 +- src/v1/product/generated/generatedV1.ts | 16 +- .../generated/generatedV1Prediction.ts | 8 +- .../internationalId/internationalIdV2.ts | 16 +- .../internationalIdV2Document.ts | 68 +++- src/v1/product/invoice/invoiceV4.ts | 16 +- src/v1/product/invoice/invoiceV4Document.ts | 116 ++++-- src/v1/product/invoice/invoiceV4LineItem.ts | 40 +- .../invoiceSplitter/invoiceSplitterV1.ts | 16 +- .../invoiceSplitterV1Document.ts | 4 +- .../invoiceSplitterV1InvoicePageGroup.ts | 12 +- .../multiReceiptsDetectorV1.ts | 16 +- .../multiReceiptsDetectorV1Document.ts | 4 +- src/v1/product/passport/passportV1.ts | 16 +- src/v1/product/passport/passportV1Document.ts | 44 +- src/v1/product/receipt/receiptV5.ts | 16 +- src/v1/product/receipt/receiptV5Document.ts | 68 +++- src/v1/product/receipt/receiptV5LineItem.ts | 24 +- src/v1/product/resume/resumeV1.ts | 16 +- src/v1/product/resume/resumeV1Certificate.ts | 24 +- src/v1/product/resume/resumeV1Document.ts | 68 +++- src/v1/product/resume/resumeV1Education.ts | 36 +- src/v1/product/resume/resumeV1Language.ts | 16 +- .../resume/resumeV1ProfessionalExperience.ts | 44 +- .../resume/resumeV1SocialNetworksUrl.ts | 16 +- src/v1/product/us/bankCheck/bankCheckV1.ts | 16 +- .../us/bankCheck/bankCheckV1Document.ts | 24 +- .../product/us/bankCheck/bankCheckV1Page.ts | 8 +- src/v2/client.ts | 12 +- src/v2/clientOptions/pollingOptions.ts | 40 +- src/v2/parsing/error/errorDetails.ts | 4 +- src/v2/parsing/inference/baseInference.ts | 8 +- src/v2/parsing/inference/field/baseField.ts | 12 +- .../inference/field/fieldConfidence.ts | 16 +- .../parsing/inference/field/fieldLocation.ts | 12 +- .../inference/field/inferenceFields.ts | 8 +- src/v2/parsing/inference/field/listField.ts | 8 +- src/v2/parsing/inference/field/objectField.ts | 8 +- src/v2/parsing/inference/field/ragMetadata.ts | 4 +- src/v2/parsing/inference/field/rawText.ts | 8 +- src/v2/parsing/inference/field/simpleField.ts | 4 +- src/v2/parsing/inference/inferenceFile.ts | 8 +- src/v2/parsing/inference/inferenceModel.ts | 8 +- .../product/classification/classification.ts | 12 +- .../classificationClassifier.ts | 8 +- .../classification/classificationInference.ts | 8 +- .../classification/classificationResponse.ts | 4 +- .../classification/classificationResult.ts | 8 +- src/v2/product/crop/crop.ts | 12 +- src/v2/product/crop/cropInference.ts | 8 +- src/v2/product/crop/cropItem.ts | 8 +- src/v2/product/crop/cropResponse.ts | 4 +- src/v2/product/crop/cropResult.ts | 8 +- .../extraction/dataSchemaActiveOption.ts | 4 +- src/v2/product/extraction/extraction.ts | 24 +- .../extraction/extractionActiveOptions.ts | 8 +- .../product/extraction/extractionInference.ts | 8 +- .../product/extraction/extractionResponse.ts | 4 +- src/v2/product/extraction/extractionResult.ts | 8 +- .../product/extraction/params/dataSchema.ts | 16 +- .../extraction/params/dataSchemaField.ts | 52 ++- .../extraction/params/dataSchemaReplace.ts | 16 +- .../ragDocuments/annotatedListField.ts | 4 +- src/v2/product/ocr/ocr.ts | 12 +- src/v2/product/ocr/ocrInference.ts | 8 +- src/v2/product/ocr/ocrPage.ts | 8 +- src/v2/product/ocr/ocrResponse.ts | 4 +- src/v2/product/ocr/ocrResult.ts | 4 +- src/v2/product/ocr/ocrWord.ts | 8 +- src/v2/product/split/split.ts | 12 +- src/v2/product/split/splitInference.ts | 8 +- src/v2/product/split/splitRange.ts | 4 +- src/v2/product/split/splitResponse.ts | 4 +- src/v2/product/split/splitResult.ts | 4 +- src/v2/search/baseSearch.ts | 12 +- src/v2/search/models/modelSearch.ts | 12 +- src/v2/search/models/modelSearchParameters.ts | 4 +- .../search/ragDocuments/ragDocumentSearch.ts | 12 +- .../ragDocumentSearchParameters.ts | 4 +- 167 files changed, 2553 insertions(+), 730 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 357ac4917..1abe845a4 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -2,6 +2,7 @@ import typescriptEslint from "@typescript-eslint/eslint-plugin"; import jsdoc from "eslint-plugin-jsdoc"; import security from "eslint-plugin-security"; import sonarjs from "eslint-plugin-sonarjs"; +import unicorn from "eslint-plugin-unicorn"; import globals from "globals"; import tsParser from "@typescript-eslint/parser"; import path from "node:path"; @@ -29,20 +30,22 @@ export default [ "@typescript-eslint": typescriptEslint, jsdoc, security, + unicorn, }, languageOptions: { globals: { ...globals.node, - ...globals.mocha, Promise: true, }, parser: tsParser, }, rules: { - "max-len": ["error", { - code: 120, - }], + "unicorn/import-style": "error", + "unicorn/prefer-node-protocol": "error", + "unicorn/text-encoding-identifier-case": "error", + "unicorn/explicit-length-check": "error", + "unicorn/single-line-block-comment-style": "error", semi: ["error"], "jsdoc/require-asterisk-prefix": "error", @@ -82,7 +85,6 @@ export default [ "@typescript-eslint/no-unused-expressions": "error", "no-eval": "error", "no-unexpected-multiline": "error", - indent: ["error", 2], "eol-last": "error", "preserve-caught-error": "off", "security/detect-non-literal-fs-filename": "off", @@ -93,6 +95,11 @@ export default [ "message": "Import can be shortened. Please use the @/ path alias instead of relative parent paths.", }], }], + + indent: ["error", 2], + "max-len": ["error", { + code: 120, + }], }, }, { diff --git a/package-lock.json b/package-lock.json index 9fc00da06..4d0ecd02d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "eslint-plugin-jsdoc": "^62.7.1", "eslint-plugin-security": "^4.0.1", "eslint-plugin-sonarjs": "^4.2.0", + "eslint-plugin-unicorn": "^75.0.0", "globals": "^17.4.0", "husky": "^9.1.7", "license-checker-rseidelsohn": "^4.4.2", @@ -802,6 +803,20 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, + "node_modules/@eslint/css-tree": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@eslint/css-tree/-/css-tree-4.1.1.tgz", + "integrity": "sha512-A+s89eP+yDAPkKjnIOfjlkGifg5J7GPn01nWx14UjBVWktfkxOU4975F9ZZ13xNxkGiblNcBaAqgKhnQrW6SWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.35.0", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, "node_modules/@eslint/eslintrc": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.6.tgz", @@ -2540,6 +2555,19 @@ "dev": true, "license": "MIT" }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.25", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.25.tgz", + "integrity": "sha512-gMmEShwwq7FJqMwvfRwvCl00v4kN+KOfJqXn+f4nrufak5gNHJOksd/60Dvjuz7sI8Y5WiSFBa8FEYr+zoyqCw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", @@ -2600,6 +2628,40 @@ "node": ">=8" } }, + "node_modules/browserslist": { + "version": "4.29.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.0.tgz", + "integrity": "sha512-3GSvyjvDI4Dur1Meg2BekJquu5uF+9R9a1+5M1Mde192eZoXbeXjzgOsgqPS2V8D5wrrip0gR5Hf/GhWQ9ZzaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.23", + "caniuse-lite": "^1.0.30001810", + "electron-to-chromium": "^1.5.427", + "node-releases": "^2.0.55", + "update-browserslist-db": "^1.3.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, "node_modules/builtin-modules": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", @@ -2646,6 +2708,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2663,6 +2746,13 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/change-case": { + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.4.tgz", + "integrity": "sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==", + "dev": true, + "license": "MIT" + }, "node_modules/char-regex": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", @@ -2711,6 +2801,22 @@ "node": ">= 6" } }, + "node_modules/ci-info": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", + "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/cjs-module-lexer": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz", @@ -2880,6 +2986,23 @@ "dev": true, "license": "MIT" }, + "node_modules/core-js-compat": { + "version": "3.50.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.50.0.tgz", + "integrity": "sha512-XGpFGbMLHwSt74YLTKho7Ib242qi6O8MSX+sRokV4oz7iKXvQWGYZthjIhjRGMxjzVkAubBO512dKGYcefmX3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.28.7" + }, + "engines": { + "node": ">=6.4.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2919,6 +3042,19 @@ "dev": true, "license": "MIT" }, + "node_modules/detect-indent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.2.tgz", + "integrity": "sha512-y+8xyqdGLL+6sh0tVeHcfP/QDd8gUgbasolJJpY7NgeQGSZ739bDtSiaiDgtoicy+mtYB81dKLxO9xRhCyIB3A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -2973,6 +3109,13 @@ "url": "https://bevry.me/fund" } }, + "node_modules/electron-to-chromium": { + "version": "1.5.431", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.431.tgz", + "integrity": "sha512-AAVihz2YwJeOdAynX8MUtqpvjY0gaiARp/7+r4kwqgzqXMrfG1qDN7vwT80uxAoOQRPcZH8t73EI+CA/1OJN8A==", + "dev": true, + "license": "ISC" + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -3277,6 +3420,57 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/eslint-plugin-unicorn": { + "version": "75.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-75.0.0.tgz", + "integrity": "sha512-72I7eSn+/z5CpgValFBl9mp2JE5UPD+nUUyB/VIGUMF1rCP1i37mA05zfIAVIU312A+qCZ38T8tSZr3oaMv4Mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.10.1", + "@eslint/css-tree": "^4.0.5", + "browserslist": "^4.28.8", + "change-case": "^5.4.4", + "ci-info": "^4.4.0", + "core-js-compat": "^3.50.0", + "detect-indent": "^7.0.2", + "entities": "^8.0.0", + "find-up-simple": "^1.0.1", + "globals": "^17.11.0", + "identifier-regex": "^1.1.0", + "indent-string": "^5.0.0", + "is-builtin-module": "^5.0.0", + "pluralize": "^8.0.0", + "quote-js-string": "^0.1.0", + "regjsparser": "^0.13.2", + "reserved-identifiers": "^1.2.0", + "semver": "^7.8.5", + "strip-indent": "^4.1.1", + "yaml": "^2.9.0" + }, + "engines": { + "node": ">=22" + }, + "funding": { + "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" + }, + "peerDependencies": { + "eslint": ">=10.4" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/entities": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", + "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/eslint-scope": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", @@ -3620,6 +3814,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/find-up-simple": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.1.tgz", + "integrity": "sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/flat-cache": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", @@ -3918,6 +4125,22 @@ "url": "https://github.com/sponsors/Fdawgs" } }, + "node_modules/identifier-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/identifier-regex/-/identifier-regex-1.1.0.tgz", + "integrity": "sha512-SLX4H/vtcYlYnL7XqnuJKHU7Z8517TgsW9nmQiGOgMCjQ8V/deLYu6bEmbGoXe7WMMhc9+EUGyFFneHja8KabA==", + "dev": true, + "license": "MIT", + "dependencies": { + "reserved-identifiers": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -3975,6 +4198,19 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/index-to-position": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/index-to-position/-/index-to-position-1.2.0.tgz", @@ -4008,6 +4244,35 @@ "node": ">=8" } }, + "node_modules/is-builtin-module": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-5.0.0.tgz", + "integrity": "sha512-f4RqJKBUe5rQkJ2eJEJBXSticB3hGbN9j0yxxMQFqIW89Jp9WYFtzfTcRlstDKVUTRzSOTLKRfO9vIztenwtxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "builtin-modules": "^5.0.0" + }, + "engines": { + "node": ">=18.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-builtin-module/node_modules/builtin-modules": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-5.4.0.tgz", + "integrity": "sha512-JCWSCdun+4Ovd9BhM/Vtlmwb7oD6Wl4YiPRXXwhAuwlPhW1un/MKgXn7GZoFm53ginnoNzus69V8JWx0K393jg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-core-module": { "version": "2.16.2", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", @@ -4148,6 +4413,19 @@ "node": ">=20.0.0" } }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -4421,6 +4699,13 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/mdn-data": { + "version": "2.35.0", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.35.0.tgz", + "integrity": "sha512-k+1+dEIm2z/BEfdvYzT/fIyAGeDBo/1AJNJI4ilFXJRYoxP/3Ds+GP8shAOIq8jYXY9N5nGB3Ag104NsagmLAA==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/mdurl": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", @@ -4616,6 +4901,16 @@ "url": "https://github.com/sponsors/Fdawgs" } }, + "node_modules/node-releases": { + "version": "2.0.56", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.56.tgz", + "integrity": "sha512-x0InOIyzgdk+eyaWaRJFH5snEtiImgBgblZ2CyPrLmqqcuMQkEvcDPHbzqbD8eDsSeJbVOjn+crzyzHaM4D+/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/nopt": { "version": "7.2.1", "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.1.tgz", @@ -5058,6 +5353,19 @@ ], "license": "MIT" }, + "node_modules/quote-js-string": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/quote-js-string/-/quote-js-string-0.1.0.tgz", + "integrity": "sha512-Y3NoRtprEEZQD8RfxMCfS0ZTqc4e+i18OrXEXAvpM6TfC/3y+0L5rNbZiSnbBBEkDfFzbpd8o+cE8q3/anjMGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22" + }, + "funding": { + "url": "https://github.com/sindresorhus/quote-js-string?sponsor=1" + } + }, "node_modules/rc-config-loader": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/rc-config-loader/-/rc-config-loader-4.1.4.tgz", @@ -5219,6 +5527,19 @@ "regexp-tree": "bin/regexp-tree" } }, + "node_modules/regjsparser": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.3.tgz", + "integrity": "sha512-ycwFAS14Jw4mppvmK4GR/J6u3WpWpjkEApehuHtLc/8VpPNpDMbQ4WjqwplXifGeyKOzHSFLmSPqzksDQE2Sfg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~3.1.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -5528,6 +5849,16 @@ "node": "*" } }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/spdx-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/spdx-compare/-/spdx-compare-1.0.0.tgz", @@ -5745,6 +6076,19 @@ "node": ">=8" } }, + "node_modules/strip-indent": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-4.1.1.tgz", + "integrity": "sha512-SlyRoSkdh1dYP0PzclLE7r0M9sgbFKKMFXpFRUMNuKhQSbC6VQIGzq3E0qsfvGJaUFJPGv6Ws1NZ/haTAjfbMA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -6330,6 +6674,37 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/update-browserslist-db": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", + "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 7e9eb95fa..d0a822b16 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "lint:fix": "tsc --noEmit && eslint --fix --report-unused-disable-directives './src/**/*.ts' './tests/**/*.ts'", "lint:package": "npm run build:dist && publint ./dist && attw --pack ./dist --profile esm-only", "lint:secrets": "secretlint '**/*'", - "license:check": "license-checker-rseidelsohn --onlyAllow \"MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;LGPL-3.0-or-later;Python-2.0;BlueOak-1.0.0;CC-BY-3.0;CC0-1.0;0BSD;LGPL-3.0-only;WTFPL;Artistic-2.0;Unlicense\"", + "license:check": "license-checker-rseidelsohn --onlyAllow \"MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;LGPL-3.0-or-later;LGPL-3.0-only;Python-2.0;BlueOak-1.0.0;CC-BY-3.0;CC-BY-4.0;CC0-1.0;0BSD;WTFPL;Artistic-2.0;Unlicense\"", "docs": "typedoc --out docs/_build ./src/index.ts", "docs:dist": "typedoc --out docs/_build ./src/index.ts && cp -r ./docs/code_samples ./docs/_build/", "prepare": "husky" @@ -84,6 +84,7 @@ "eslint-plugin-jsdoc": "^62.7.1", "eslint-plugin-security": "^4.0.1", "eslint-plugin-sonarjs": "^4.2.0", + "eslint-plugin-unicorn": "^75.0.0", "globals": "^17.4.0", "husky": "^9.1.7", "license-checker-rseidelsohn": "^4.4.2", diff --git a/src/geometry/bbox.ts b/src/geometry/bbox.ts index 5462efa3e..5a5cfa128 100644 --- a/src/geometry/bbox.ts +++ b/src/geometry/bbox.ts @@ -1,14 +1,24 @@ import { mergeBbox } from "@/geometry/boundingBoxUtils.js"; -/** A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax */ +/** + * A simple bounding box defined by 4 coordinates: xMin, yMin, xMax, yMax + */ export class BBox { - /** Minimum X coordinate. */ + /** + * Minimum X coordinate. + */ xMin: number; - /** Minimum Y coordinate. */ + /** + * Minimum Y coordinate. + */ yMin: number; - /** Maximum X coordinate. */ + /** + * Maximum X coordinate. + */ xMax: number; - /** Maximum Y coordinate. */ + /** + * Maximum Y coordinate. + */ yMax: number; constructor(xMin: number, yMin: number, xMax: number, yMax: number) { @@ -18,7 +28,9 @@ export class BBox { this.yMax = yMax; } - /** Returns a bounding box that contains this box and another one. */ + /** + * Returns a bounding box that contains this box and another one. + */ mergeBbox(bbox: BBox) { return mergeBbox(this, bbox); } diff --git a/src/geometry/boundingBox.ts b/src/geometry/boundingBox.ts index 9f331fac4..552ac1546 100644 --- a/src/geometry/boundingBox.ts +++ b/src/geometry/boundingBox.ts @@ -1,7 +1,9 @@ import { Point } from "./point.js"; import { Polygon } from "./polygon.js"; -/** A bounding box defined by 4 points. */ +/** + * A bounding box defined by 4 points. + */ export class BoundingBox extends Polygon { constructor(topLeft: Point, topRight: Point, bottomRight: Point, bottomLeft: Point) { super(topLeft, topRight, bottomRight, bottomLeft); diff --git a/src/geometry/minMax.ts b/src/geometry/minMax.ts index 14d2338f3..9edf49ae1 100644 --- a/src/geometry/minMax.ts +++ b/src/geometry/minMax.ts @@ -1,7 +1,13 @@ -/** Numeric range boundaries. */ +/** + * Numeric range boundaries. + */ export type MinMax = { - /** Lower bound. */ + /** + * Lower bound. + */ min: number; - /** Upper bound. */ + /** + * Upper bound. + */ max: number; }; diff --git a/src/geometry/point.ts b/src/geometry/point.ts index 808365e66..266b5ddb4 100644 --- a/src/geometry/point.ts +++ b/src/geometry/point.ts @@ -1,2 +1,4 @@ -/** A point on the document defined by 2 coordinates: X, Y */ +/** + * A point on the document defined by 2 coordinates: X, Y + */ export type Point = [number, number]; diff --git a/src/geometry/polygon.ts b/src/geometry/polygon.ts index 104a77cb8..de152cbe6 100644 --- a/src/geometry/polygon.ts +++ b/src/geometry/polygon.ts @@ -2,7 +2,9 @@ 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. */ +/** + * A polygon, composed of several Points. + */ export class Polygon extends Array { constructor(...args: Point[]) { diff --git a/src/http/baseSettings.ts b/src/http/baseSettings.ts index 85432fc40..adc7fe783 100644 --- a/src/http/baseSettings.ts +++ b/src/http/baseSettings.ts @@ -12,13 +12,21 @@ export interface MindeeApiConstructorProps { } export abstract class BaseSettings { - /** API key used for authenticated requests. */ + /** + * API key used for authenticated requests. + */ apiKey: string; - /** API hostname used for requests. */ + /** + * API hostname used for requests. + */ hostname: string; - /** Request timeout in seconds. */ + /** + * Request timeout in seconds. + */ timeoutSecs: number; - /** HTTP dispatcher used by undici. */ + /** + * HTTP dispatcher used by undici. + */ dispatcher: Dispatcher; protected constructor(apiKey?: string, dispatcher?: Dispatcher) { @@ -34,7 +42,9 @@ export abstract class BaseSettings { : TIMEOUT_SECS_DEFAULT; } - /** Builds a default user-agent string for outgoing requests. */ + /** + * Builds a default user-agent string for outgoing requests. + */ protected getUserAgent(): string { let platform = os.type().toLowerCase(); if (platform.includes("darwin")) { diff --git a/src/http/dispatcher.ts b/src/http/dispatcher.ts index a7938bf00..d150c0950 100644 --- a/src/http/dispatcher.ts +++ b/src/http/dispatcher.ts @@ -2,7 +2,9 @@ import { Agent, Dispatcher, getGlobalDispatcher } from "undici"; import { logger } from "@/logger.js"; -/** Library-owned fallback dispatcher, shared across all components. */ +/** + * Library-owned fallback dispatcher, shared across all components. + */ let fallbackDispatcher: Dispatcher | undefined; /** diff --git a/src/image/extractedImage.ts b/src/image/extractedImage.ts index 79a10c005..3a0d4ddef 100644 --- a/src/image/extractedImage.ts +++ b/src/image/extractedImage.ts @@ -15,13 +15,21 @@ import { loadOptionalDependency } from "@/dependency/index.js"; * Generic class for image extraction. */ export class ExtractedImage { - /** Raw file bytes for the extracted image artifact. */ + /** + * Raw file bytes for the extracted image artifact. + */ public buffer: Buffer; - /** Filename used when exporting the extracted image. */ + /** + * Filename used when exporting the extracted image. + */ public filename: string; - /** 1-based source page identifier. */ + /** + * 1-based source page identifier. + */ public readonly pageId: number; - /** Identifier of the extracted element on the page. */ + /** + * Identifier of the extracted element on the page. + */ public readonly elementId: number; constructor(buffer: Uint8Array, fileName: string, pageId: number, elementId: number) { @@ -80,7 +88,7 @@ export class ExtractedImage { } /** - * Attempts to saves the document to a file synchronously. + * Attempts to save 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. * * @param outputPath Path to save the file to. diff --git a/src/image/extractedImages.ts b/src/image/extractedImages.ts index 3f917f355..455011023 100644 --- a/src/image/extractedImages.ts +++ b/src/image/extractedImages.ts @@ -1,6 +1,8 @@ import { ExtractedImage } from "@/image/index.js"; -/** Collection of extracted image artifacts. */ +/** + * Collection of extracted image artifacts. + */ export class ExtractedImages extends Array { constructor(...items: ExtractedImage[]) { super(...items); diff --git a/src/input/base64Input.ts b/src/input/base64Input.ts index 4f07815a0..51a5b2481 100644 --- a/src/input/base64Input.ts +++ b/src/input/base64Input.ts @@ -7,10 +7,14 @@ interface Base64InputProps { filename: string; } -/** Local input source backed by a base64-encoded payload. */ +/** + * Local input source backed by a base64-encoded payload. + */ export class Base64Input extends LocalInputSource { private inputString: string; - /** Decoded binary payload built from the base64 input. */ + /** + * Decoded binary payload built from the base64 input. + */ fileObject: Buffer = Buffer.alloc(0); constructor({ inputString, filename }: Base64InputProps) { @@ -21,7 +25,9 @@ export class Base64Input extends LocalInputSource { this.inputString = inputString; } - /** Decodes and validates the provided base64 content. */ + /** + * Decodes and validates the provided base64 content. + */ async init() { if (this.initialized) { return; diff --git a/src/input/bufferInput.ts b/src/input/bufferInput.ts index a4527def9..fd4ee26e7 100644 --- a/src/input/bufferInput.ts +++ b/src/input/bufferInput.ts @@ -8,7 +8,9 @@ interface BufferInputProps { filename: string; } -/** Local input source backed by an in-memory `Buffer`. */ +/** + * Local input source backed by an in-memory `Buffer`. + */ export class BufferInput extends LocalInputSource { constructor({ buffer, filename }: BufferInputProps) { super({ @@ -18,7 +20,9 @@ export class BufferInput extends LocalInputSource { this.filename = filename; } - /** Validates and initializes the in-memory buffer input. */ + /** + * Validates and initializes the in-memory buffer input. + */ async init(): Promise { if (this.initialized) { return; diff --git a/src/input/inputSource.ts b/src/input/inputSource.ts index 28e3c1662..e4d9270a5 100644 --- a/src/input/inputSource.ts +++ b/src/input/inputSource.ts @@ -27,10 +27,11 @@ export abstract class InputSource { * Whether the input source has been initialized. * @protected */ - /** Whether the source has already been initialized. */ protected initialized: boolean = false; - /** Initializes the input source and populates its file object. */ + /** + * Initializes the input source and populates its file object. + */ async init() { throw new MindeeInputSourceError("not Implemented"); } diff --git a/src/input/localInputSource.ts b/src/input/localInputSource.ts index 13adfc2ea..511fe17fb 100644 --- a/src/input/localInputSource.ts +++ b/src/input/localInputSource.ts @@ -36,15 +36,25 @@ const ALLOWED_INPUT_TYPES = [ ]; export abstract class LocalInputSource extends InputSource { - /** Type of local input source (path, stream, bytes, ...). */ + /** + * Type of local input source (path, stream, bytes, ...). + */ public inputType: string; - /** Original filename associated with the input. */ + /** + * Original filename associated with the input. + */ public filename: string = ""; - /** Original filepath when available. */ + /** + * Original filepath when available. + */ public filepath?: string; - /** MIME type detected for the source content. */ + /** + * MIME type detected for the source content. + */ public mimeType: string = ""; - /** Binary payload for local sources. */ + /** + * Binary payload for local sources. + */ public fileObject!: Buffer | string; /** @@ -63,7 +73,9 @@ export abstract class LocalInputSource extends InputSource { logger.debug(`Initialized local input source of type: ${inputType}`); } - /** Detects and validates the MIME type from the current file object. */ + /** + * Detects and validates the MIME type from the current file object. + */ protected async checkMimetype(): Promise { if (!(this.fileObject instanceof Buffer)) { throw new MindeeInputSourceError( diff --git a/src/input/pageOptions.ts b/src/input/pageOptions.ts index 1781c9369..3c85b3730 100644 --- a/src/input/pageOptions.ts +++ b/src/input/pageOptions.ts @@ -10,7 +10,9 @@ export interface PageOptions { * [0, -1] represents the first and last pages of the document. */ pageIndexes: number[]; - /** Operation to apply on the document, given the `pageIndexes` specified. */ + /** + * Operation to apply on the document, given the `pageIndexes` specified. + */ operation: PageOptionsOperation; /** * Apply the operation only if the document has at least this many pages. @@ -23,8 +25,12 @@ export interface PageOptions { */ /* eslint-disable @typescript-eslint/naming-convention */ export enum PageOptionsOperation { - /** Only keep pages matching the provided indexes. */ + /** + * Only keep pages matching the provided indexes. + */ KeepOnly = "KEEP_ONLY", - /** Remove pages matching the provided indexes. */ + /** + * Remove pages matching the provided indexes. + */ Remove = "REMOVE", } diff --git a/src/input/pathInput.ts b/src/input/pathInput.ts index eb0accbdf..b0f772a5b 100644 --- a/src/input/pathInput.ts +++ b/src/input/pathInput.ts @@ -8,11 +8,17 @@ interface PathInputProps { inputPath: string; } -/** Local input source that reads a file from disk by path. */ +/** + * Local input source that reads a file from disk by path. + */ export class PathInput extends LocalInputSource { - /** Path used to read the local file. */ + /** + * Path used to read the local file. + */ readonly inputPath: string; - /** File content loaded from disk. */ + /** + * File content loaded from disk. + */ fileObject: Buffer = Buffer.alloc(0); constructor({ inputPath }: PathInputProps) { @@ -23,7 +29,9 @@ export class PathInput extends LocalInputSource { this.filename = path.basename(this.inputPath); } - /** Reads the file from disk and validates MIME type. */ + /** + * Reads the file from disk and validates MIME type. + */ async init() { if (this.initialized) { return; diff --git a/src/input/streamInput.ts b/src/input/streamInput.ts index 91a2ba140..4a62bd9bf 100644 --- a/src/input/streamInput.ts +++ b/src/input/streamInput.ts @@ -10,10 +10,14 @@ interface StreamInputProps { filename: string; } -/** Local input source backed by a readable stream. */ +/** + * Local input source backed by a readable stream. + */ export class StreamInput extends LocalInputSource { private readonly inputStream: Readable; - /** Buffered payload created from the stream. */ + /** + * Buffered payload created from the stream. + */ fileObject: Buffer = Buffer.alloc(0); constructor({ inputStream, filename }: StreamInputProps) { @@ -24,7 +28,9 @@ export class StreamInput extends LocalInputSource { this.inputStream = inputStream; } - /** Reads the stream to completion and validates MIME type. */ + /** + * Reads the stream to completion and validates MIME type. + */ async init() { if (this.initialized) { return; @@ -35,7 +41,9 @@ export class StreamInput extends LocalInputSource { this.initialized = true; } - /** Converts a readable stream into a single buffer. */ + /** + * Converts a readable stream into a single buffer. + */ async stream2buffer(stream: Readable, signal?: AbortSignal): Promise { return new Promise((resolve, reject) => { if (stream.closed || stream.destroyed) { diff --git a/src/input/urlInput.ts b/src/input/urlInput.ts index 9589dab66..7ea031462 100644 --- a/src/input/urlInput.ts +++ b/src/input/urlInput.ts @@ -10,11 +10,17 @@ import { MindeeInputSourceError } from "@/errors/index.js"; import { resolveDefaultDispatcher } from "@/http/dispatcher.js"; import { BytesInput } from "./bytesInput.js"; -/** Remote input source represented by a validated HTTPS URL. */ +/** + * Remote input source represented by a validated HTTPS URL. + */ export class UrlInput extends InputSource { - /** HTTPS URL of the remote input file. */ + /** + * HTTPS URL of the remote input file. + */ public readonly url: string; - /** Dispatcher used for HTTP requests. */ + /** + * Dispatcher used for HTTP requests. + */ public readonly dispatcher; constructor( @@ -26,7 +32,9 @@ export class UrlInput extends InputSource { logger.debug("Initialized URL input source."); } - /** Initializes this source by validating and storing the URL. */ + /** + * Initializes this source by validating and storing the URL. + */ async init() { if (this.initialized) { return; @@ -72,7 +80,9 @@ export class UrlInput extends InputSource { return await this.makeRequest(this.url, headers, 0, maxRedirects); } - /** Downloads the URL content and writes it to disk. */ + /** + * Downloads the URL content and writes it to disk. + */ async saveToFile(options: { filepath: string; filename?: string; @@ -90,7 +100,9 @@ export class UrlInput extends InputSource { return fullPath; } - /** Downloads the URL content and returns it as a local bytes source. */ + /** + * Downloads the URL content and returns it as a local bytes source. + */ async asLocalInputSource(options: { filename?: string; username?: string; diff --git a/src/parsing/baseLocalResponse.ts b/src/parsing/baseLocalResponse.ts index 172fd160a..09c75baf8 100644 --- a/src/parsing/baseLocalResponse.ts +++ b/src/parsing/baseLocalResponse.ts @@ -12,7 +12,9 @@ import { MindeeError } from "@/errors/index.js"; export abstract class BaseLocalResponse { private fileBytes: Buffer; private readonly inputHandle: Buffer | string; - /** Whether the local response payload has been loaded. */ + /** + * Whether the local response payload has been loaded. + */ protected initialized = false; /** @@ -29,7 +31,9 @@ export abstract class BaseLocalResponse { this.inputHandle = inputFile; } - /** Loads the local payload from a string, buffer, or file path. */ + /** + * Loads the local payload from a string, buffer, or file path. + */ public async init() { /** * @param inputFile - The input file, which can be a Buffer, string, or PathLike. diff --git a/src/parsing/stringDict.ts b/src/parsing/stringDict.ts index 8412a10b4..c99218207 100644 --- a/src/parsing/stringDict.ts +++ b/src/parsing/stringDict.ts @@ -1,2 +1,4 @@ -/** Generic string-keyed dictionary used for raw API payloads. */ +/** + * Generic string-keyed dictionary used for raw API payloads. + */ export type StringDict = { [index: string]: any }; diff --git a/src/pdf/extractedPdf.ts b/src/pdf/extractedPdf.ts index 862f8bc75..18c5c40eb 100644 --- a/src/pdf/extractedPdf.ts +++ b/src/pdf/extractedPdf.ts @@ -7,15 +7,25 @@ import { BufferInput, MIMETYPES } from "@/input/index.js"; import { MindeeError } from "@/errors/index.js"; import { logger } from "@/logger.js"; -/** Represents a PDF artifact produced by an extraction/splitting operation. */ +/** + * Represents a PDF artifact produced by an extraction/splitting operation. + */ export class ExtractedPdf { - /** Raw bytes of the extracted PDF segment. */ + /** + * Raw bytes of the extracted PDF segment. + */ public readonly buffer: Buffer; - /** Filename suggested for export. */ + /** + * Filename suggested for export. + */ public readonly filename: string; - /** Number of pages in this extracted PDF. */ + /** + * Number of pages in this extracted PDF. + */ public readonly pageCount: number; - /** Zero-based indexes of pages included in this extracted PDF. */ + /** + * Zero-based indexes of pages included in this extracted PDF. + */ public readonly pageIndexes: number[]; constructor(pdfData: Buffer, filename: string, pageIndexes: number[]) { diff --git a/src/pdf/extractedPdfs.ts b/src/pdf/extractedPdfs.ts index fd72e9a4e..512590609 100644 --- a/src/pdf/extractedPdfs.ts +++ b/src/pdf/extractedPdfs.ts @@ -1,6 +1,8 @@ import { ExtractedPdf } from "@/pdf/extractedPdf.js"; -/** Collection of extracted PDF artifacts. */ +/** + * Collection of extracted PDF artifacts. + */ export class ExtractedPdfs extends Array { constructor(...items: ExtractedPdf[]) { super(...items); diff --git a/src/pdf/pdfOperation.ts b/src/pdf/pdfOperation.ts index 341fea5f1..320c2ad66 100644 --- a/src/pdf/pdfOperation.ts +++ b/src/pdf/pdfOperation.ts @@ -22,11 +22,17 @@ async function getPdfLib(): Promise { return pdfLib!; } -/** Result of a PDF split/extract operation. */ +/** + * Result of a PDF split/extract operation. + */ export interface SplitPdf { - /** PDF content after page extraction. */ + /** + * PDF content after page extraction. + */ file: Buffer; - /** Number of pages removed from the source PDF. */ + /** + * Number of pages removed from the source PDF. + */ totalPagesRemoved: number; } @@ -120,7 +126,6 @@ export async function countPages(file: Buffer): Promise { return currentPdf.getPageCount(); } - /** * Creates a PDF from a local file. Converts images to PDFs if needed. * @param inputSource The input source to create a PDF from. diff --git a/src/v1/client.ts b/src/v1/client.ts index b437eb608..10a7628f9 100644 --- a/src/v1/client.ts +++ b/src/v1/client.ts @@ -49,7 +49,9 @@ interface BaseOptions { * Options relating to predictions. */ export interface PredictOptions extends BaseOptions { - /** A custom endpoint. */ + /** + * A custom endpoint. + */ endpoint?: Endpoint; /** * Whether to include the full text for each page. @@ -86,11 +88,17 @@ export interface WorkflowOptions extends BaseOptions { publicUrl?: string; } -/** Timer options forwarded to `setTimeout` in polling loops. */ +/** + * Timer options forwarded to `setTimeout` in polling loops. + */ export interface TimerOptions { - /** Whether the timer should keep the event loop active. */ + /** + * Whether the timer should keep the event loop active. + */ ref?: boolean, - /** Optional signal used to abort timer waits. */ + /** + * Optional signal used to abort timer waits. + */ signal?: AbortSignal } @@ -98,15 +106,25 @@ export interface TimerOptions { * Asynchronous polling parameters. */ export interface OptionalAsyncOptions extends PredictOptions { - /** Delay in seconds before the first polling attempt. */ + /** + * Delay in seconds before the first polling attempt. + */ initialDelaySec?: number; - /** Delay in seconds between polling attempts. */ + /** + * Delay in seconds between polling attempts. + */ delaySec?: number; - /** Maximum number of polling attempts. */ + /** + * Maximum number of polling attempts. + */ maxRetries?: number; - /** Timer options used for the first delay. */ + /** + * Timer options used for the first delay. + */ initialTimerOptions?: TimerOptions; - /** Timer options used for recurring polling delays. */ + /** + * Timer options used for recurring polling delays. + */ recurringTimerOptions?: TimerOptions; } @@ -119,13 +137,21 @@ export interface AsyncOptions extends PredictOptions { } export interface ClientOptions { - /** Your API key for all endpoints. */ + /** + * Your API key for all endpoints. + */ apiKey?: string; - /** Raise an `Error` on errors. */ + /** + * Raise an `Error` on errors. + */ throwOnError?: boolean; - /** Log debug messages. */ + /** + * Log debug messages. + */ debug?: boolean; - /** Custom dispatcher for HTTP requests. */ + /** + * Custom dispatcher for HTTP requests. + */ dispatcher?: Dispatcher; } @@ -135,7 +161,9 @@ export interface ClientOptions { * @category Client */ export class Client { - /** Mindee V1 API settings. */ + /** + * Mindee V1 API settings. + */ protected apiSettings: ApiSettingsV1; /** diff --git a/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts b/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts index bd422a94a..1875f70cd 100644 --- a/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts +++ b/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.ts @@ -4,9 +4,13 @@ import { ExtractedPdf } from "@/pdf/index.js"; * Wrapper class for extracted invoice pages. */ export class ExtractedInvoiceSplitterImage extends ExtractedPdf { - /** Start page index of the extracted invoice segment. */ + /** + * Start page index of the extracted invoice segment. + */ readonly pageIdMin: number; - /** End page index of the extracted invoice segment. */ + /** + * End page index of the extracted invoice segment. + */ readonly pageIdMax: number; constructor(bytes: Uint8Array, pageIndices: [number, number]) { diff --git a/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts b/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts index 0da6d6779..f54b9c378 100644 --- a/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts +++ b/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.ts @@ -4,9 +4,13 @@ import { ExtractedImage } from "@/image/index.js"; * Wrapper class for extracted multiple-receipts images. */ export class ExtractedMultiReceiptImage extends ExtractedImage { - /** Receipt index within the source page. */ + /** + * Receipt index within the source page. + */ readonly receiptId: number; - /** Source page identifier. */ + /** + * Source page identifier. + */ readonly pageId: number; constructor(buffer: Uint8Array, pageId: number, receiptId: number) { diff --git a/src/v1/http/apiSettingsV1.ts b/src/v1/http/apiSettingsV1.ts index d75cf3d1b..7a3ccf252 100644 --- a/src/v1/http/apiSettingsV1.ts +++ b/src/v1/http/apiSettingsV1.ts @@ -2,15 +2,21 @@ import { logger } from "@/logger.js"; import { BaseSettings, MindeeApiConstructorProps } from "@/http/baseSettings.js"; import { MindeeConfigurationError } from "@/errors/index.js"; -/** Default account owner for built-in v1 APIs. */ +/** + * Default account owner for built-in v1 APIs. + */ 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"; -/** Runtime settings container for v1 API calls. */ +/** + * Runtime settings container for v1 API calls. + */ export class ApiSettingsV1 extends BaseSettings { - /** Default headers sent with each v1 API request. */ + /** + * Default headers sent with each v1 API request. + */ baseHeaders: Record; constructor({ @@ -31,7 +37,9 @@ export class ApiSettingsV1 extends BaseSettings { }; } - /** Resolves the API key from environment variables. */ + /** + * Resolves the API key from environment variables. + */ protected apiKeyFromEnv(): string { const envVarValue = process.env[API_V1_KEY_ENVVAR_NAME]; if (envVarValue) { @@ -43,7 +51,9 @@ export class ApiSettingsV1 extends BaseSettings { return ""; } - /** Resolves the API hostname from environment variables. */ + /** + * Resolves the API hostname from environment variables. + */ protected hostnameFromEnv(): string { const envVarValue = process.env[API_V1_HOST_ENVVAR_NAME]; if (envVarValue) { diff --git a/src/v1/http/baseEndpoint.ts b/src/v1/http/baseEndpoint.ts index 49bbf15c3..d63e9b2e7 100644 --- a/src/v1/http/baseEndpoint.ts +++ b/src/v1/http/baseEndpoint.ts @@ -2,10 +2,14 @@ import { InputSource, PageOptions, LocalInputSource } from "@/input/index.js"; import { ApiSettingsV1 } from "@/v1/http/apiSettingsV1.js"; export abstract class BaseEndpoint { - /** Settings relating to the API. */ + /** + * Settings relating to the API. + */ settings: ApiSettingsV1; - /** Root of the URL for API calls. */ + /** + * Root of the URL for API calls. + */ urlRoot: string; protected constructor( diff --git a/src/v1/http/endpoint.ts b/src/v1/http/endpoint.ts index eac84137d..e7b263dd7 100644 --- a/src/v1/http/endpoint.ts +++ b/src/v1/http/endpoint.ts @@ -18,11 +18,17 @@ import { BaseEndpoint } from "@/v1/http/baseEndpoint.js"; * Endpoint for a product (OTS or Custom). */ export class Endpoint extends BaseEndpoint { - /** URL of a product. */ + /** + * URL of a product. + */ urlName: string; - /** Account owning the product. */ + /** + * Account owning the product. + */ owner: string; - /** Product's version, as a string. */ + /** + * Product's version, as a string. + */ version: string; constructor( diff --git a/src/v1/http/errors.ts b/src/v1/http/errors.ts index 9367df6d5..55ab20f60 100644 --- a/src/v1/http/errors.ts +++ b/src/v1/http/errors.ts @@ -96,11 +96,17 @@ export function handleError( * Is used when an error is lacking a handled error code. */ export class MindeeHttpErrorV1 extends MindeeError { - /** Description of the error. */ + /** + * Description of the error. + */ message: string = ""; - /** Additional details on the error. */ + /** + * Additional details on the error. + */ details: string | StringDict = ""; - /** Standard HTTP error code. */ + /** + * Standard HTTP error code. + */ code?: number; constructor(httpError: StringDict, urlName: string, code?: number) { diff --git a/src/v1/http/httpParams.ts b/src/v1/http/httpParams.ts index 9611780e9..53864d6c0 100644 --- a/src/v1/http/httpParams.ts +++ b/src/v1/http/httpParams.ts @@ -2,32 +2,56 @@ import { InputSource, PageOptions } from "@/input/index.js"; import { ExecutionPriority } from "@/v1/parsing/common/index.js"; interface HTTPParams { - /** Input source to submit to the API. */ + /** + * Input source to submit to the API. + */ inputDoc: InputSource; - /** Enables full-text OCR output when supported. */ + /** + * Enables full-text OCR output when supported. + */ fullText: boolean; - /** Optional local page filtering options applied before upload. */ + /** + * Optional local page filtering options applied before upload. + */ pageOptions?: PageOptions; - /** Enables Retrieval-Augmented Generation when supported. */ + /** + * Enables Retrieval-Augmented Generation when supported. + */ rag?: boolean; } -/** Parameters sent to synchronous/asynchronous prediction endpoints. */ +/** + * Parameters sent to synchronous/asynchronous prediction endpoints. + */ export interface PredictParams extends HTTPParams { - /** Enables word-level OCR details in the response. */ + /** + * Enables word-level OCR details in the response. + */ includeWords: boolean; - /** Enables cropper extras in the response. */ + /** + * Enables cropper extras in the response. + */ cropper: boolean; - /** Optional workflow ID used for workflow-backed inference. */ + /** + * Optional workflow ID used for workflow-backed inference. + */ workflowId?: string; } -/** Parameters sent to workflow execution endpoints. */ +/** + * Parameters sent to workflow execution endpoints. + */ export interface WorkflowParams extends HTTPParams { - /** Custom alias assigned to the submitted file. */ + /** + * Custom alias assigned to the submitted file. + */ alias?: string; - /** Processing priority of the workflow execution. */ + /** + * Processing priority of the workflow execution. + */ priority?: ExecutionPriority; - /** Whether to request a public validation URL. */ + /** + * Whether to request a public validation URL. + */ publicUrl?: string; } diff --git a/src/v1/parsing/common/apiRequest.ts b/src/v1/parsing/common/apiRequest.ts index 3d28d3db6..b2c849b5f 100644 --- a/src/v1/parsing/common/apiRequest.ts +++ b/src/v1/parsing/common/apiRequest.ts @@ -5,15 +5,25 @@ import { StringDict } from "@/parsing/stringDict.js"; * @category API Response */ export class ApiRequest { - /** An object detailing the error. */ + /** + * An object detailing the error. + */ error: StringDict; - /** Target of the request. */ + /** + * Target of the request. + */ resources: string[]; - /** Status of the request. Either "failure" or "success". */ + /** + * Status of the request. Either "failure" or "success". + */ status: "failure" | "success"; - /** HTTP status code */ + /** + * HTTP status code + */ statusCode: number; - /** URL of the request. */ + /** + * URL of the request. + */ url: string; constructor(serverResponse: StringDict) { diff --git a/src/v1/parsing/common/apiResponse.ts b/src/v1/parsing/common/apiResponse.ts index b900eccd1..bed6708c8 100644 --- a/src/v1/parsing/common/apiResponse.ts +++ b/src/v1/parsing/common/apiResponse.ts @@ -7,9 +7,13 @@ import { StringDict } from "@/parsing/stringDict.js"; * @category API Response */ export abstract class ApiResponse { - /** Initial request sent to the API. */ + /** + * Initial request sent to the API. + */ apiRequest: ApiRequest; - /** Raw text representation of the API's response. */ + /** + * Raw text representation of the API's response. + */ private readonly rawHttp: StringDict; /** diff --git a/src/v1/parsing/common/asyncPredictResponse.ts b/src/v1/parsing/common/asyncPredictResponse.ts index 3eb7cc6a1..631e723d2 100644 --- a/src/v1/parsing/common/asyncPredictResponse.ts +++ b/src/v1/parsing/common/asyncPredictResponse.ts @@ -9,17 +9,29 @@ import { Document } from "./document.js"; * @category Asynchronous */ export class Job { - /** Timestamp noting the enqueueing of a document. */ + /** + * Timestamp noting the enqueueing of a document. + */ issuedAt: Date; - /** Timestamp noting the availability of a prediction for an enqueued document. */ + /** + * Timestamp noting the availability of a prediction for an enqueued document. + */ availableAt?: Date; - /** Information about an error that occurred during the job processing. */ + /** + * Information about an error that occurred during the job processing. + */ error?: StringDict; - /** ID of the job. */ + /** + * ID of the job. + */ id: string; - /** Status of the job. */ + /** + * Status of the job. + */ status?: "waiting" | "processing" | "completed" | "failed"; - /** The time taken to process the job, in milliseconds. */ + /** + * The time taken to process the job, in milliseconds. + */ milliSecsTaken?: number; constructor(jsonResponse: StringDict) { @@ -58,7 +70,9 @@ export function datetimeWithTimezone(date: string): Date { * @category Asynchronous */ export class AsyncPredictResponse extends ApiResponse { - /** Job for a queue. */ + /** + * Job for a queue. + */ job: Job; /** Prediction for an asynchronous request. Will not be available so long as the job is not * `completed`. diff --git a/src/v1/parsing/common/document.ts b/src/v1/parsing/common/document.ts index f5b993583..2e146150d 100644 --- a/src/v1/parsing/common/document.ts +++ b/src/v1/parsing/common/document.ts @@ -9,17 +9,29 @@ import { RAGExtra } from "./extras/ragExtra.js"; * @typeParam T an extension of an `Inference`. Mandatory in order to properly create an inference. */ export class Document { - /** File name as sent back by the server. */ + /** + * File name as sent back by the server. + */ filename: string; - /** Result of the base inference. */ + /** + * Result of the base inference. + */ inference: T; - /** ID of the document as sent back by the server. */ + /** + * ID of the document as sent back by the server. + */ id: string; - /** Potential `Extras` fields sent back along the prediction. */ + /** + * Potential `Extras` fields sent back along the prediction. + */ extras?: Extras; - /** Raw-text response for `allWords` parsing. */ + /** + * Raw-text response for `allWords` parsing. + */ ocr?: Ocr; - /** Page number as sent back by the API. */ + /** + * Page number as sent back by the API. + */ nPages: number; /** diff --git a/src/v1/parsing/common/execution.ts b/src/v1/parsing/common/execution.ts index 8c4ace8c5..1cc40a9ab 100644 --- a/src/v1/parsing/common/execution.ts +++ b/src/v1/parsing/common/execution.ts @@ -10,43 +10,69 @@ import { parseDate } from "@/parsing/dateParser.js"; * @category Workflow */ export class Execution { - /** Identifier for the batch to which the execution belongs. */ + /** + * Identifier for the batch to which the execution belongs. + */ batchName: string; - /** The time at which the execution started. */ + /** + * The time at which the execution started. + */ createdAt: Date | null; - /** File representation within a workflow execution. */ + /** + * File representation within a workflow execution. + */ file: ExecutionFile; - /** Identifier for the execution. */ + /** + * Identifier for the execution. + */ id: string; - /** Deserialized inference object. */ + /** + * Deserialized inference object. + */ inference: T | null; - /** Priority of the execution. */ + /** + * Priority of the execution. + */ priority: ExecutionPriority | null; - /** The time at which the file was tagged as reviewed. */ + /** + * The time at which the file was tagged as reviewed. + */ reviewedAt: Date | null; - /** The time at which the file was uploaded to a workflow. */ + /** + * The time at which the file was uploaded to a workflow. + */ availableAt: Date | null; - /** Reviewed fields and values. */ + /** + * Reviewed fields and values. + */ reviewedPrediction: GeneratedV1Document | null; - /** Execution Status. */ + /** + * Execution Status. + */ status: string; - /** Execution type. */ + /** + * Execution type. + */ type: string | null; - /** The time at which the file was uploaded to a workflow. */ + /** + * The time at which the file was uploaded to a workflow. + */ uploadedAt: Date | null; - /** Identifier for the workflow. */ + /** + * Identifier for the workflow. + */ workflowId: string; constructor(inferenceClass: new (serverResponse: StringDict) => T, jsonResponse: StringDict) { diff --git a/src/v1/parsing/common/executionFile.ts b/src/v1/parsing/common/executionFile.ts index b13530b3e..a0ca415b5 100644 --- a/src/v1/parsing/common/executionFile.ts +++ b/src/v1/parsing/common/executionFile.ts @@ -6,10 +6,14 @@ import { StringDict } from "@/parsing/stringDict.js"; */ export class ExecutionFile { - /** File name. */ + /** + * File name. + */ name: string|null; - /** Optional alias for the fil. */ + /** + * Optional alias for the fil. + */ alias: string|null; constructor(jsonResponse: StringDict) { diff --git a/src/v1/parsing/common/executionPriority.ts b/src/v1/parsing/common/executionPriority.ts index 708b481c0..d35ec8f73 100644 --- a/src/v1/parsing/common/executionPriority.ts +++ b/src/v1/parsing/common/executionPriority.ts @@ -1,9 +1,17 @@ -/** Execution priority levels available for workflow requests. */ +/** + * Execution priority levels available for workflow requests. + */ export enum ExecutionPriority { - /** Low-priority background processing. */ + /** + * Low-priority background processing. + */ low = "low", - /** Standard processing priority. */ + /** + * Standard processing priority. + */ medium = "medium", - /** High-priority processing. */ + /** + * High-priority processing. + */ high = "high" } diff --git a/src/v1/parsing/common/extras/cropperExtra.ts b/src/v1/parsing/common/extras/cropperExtra.ts index 32aae5eb8..1f1d8f28c 100644 --- a/src/v1/parsing/common/extras/cropperExtra.ts +++ b/src/v1/parsing/common/extras/cropperExtra.ts @@ -3,9 +3,13 @@ import { PositionField } from "@/v1/parsing/standard/position.js"; import { cleanOutString } from "@/v1/parsing/common/summaryHelper.js"; import { ExtraField } from "./extras.js"; -/** Cropper extra payload returned by compatible APIs. */ +/** + * Cropper extra payload returned by compatible APIs. + */ export class CropperExtra extends ExtraField { - /** Cropped regions detected on the page. */ + /** + * Cropped regions detected on the page. + */ cropping: PositionField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { super(); diff --git a/src/v1/parsing/common/extras/extras.ts b/src/v1/parsing/common/extras/extras.ts index c290bbe94..f582e7df0 100644 --- a/src/v1/parsing/common/extras/extras.ts +++ b/src/v1/parsing/common/extras/extras.ts @@ -1,4 +1,6 @@ -/** Base class for optional extras attached to predictions. */ +/** + * Base class for optional extras attached to predictions. + */ export abstract class ExtraField { } @@ -6,10 +8,14 @@ interface ExtraDict { [key: string]: T | (() => string); } -/** Dictionary-like container for extra fields. */ +/** + * Dictionary-like container for extra fields. + */ export class Extras implements ExtraDict { - /** Dynamic map of extra values keyed by extra name. */ + /** + * Dynamic map of extra values keyed by extra name. + */ [key: string]: ExtraT | (() => string); constructor(fields: Record) { diff --git a/src/v1/parsing/common/extras/fullTextOcrExtra.ts b/src/v1/parsing/common/extras/fullTextOcrExtra.ts index a4ebca17d..dec1fc60a 100644 --- a/src/v1/parsing/common/extras/fullTextOcrExtra.ts +++ b/src/v1/parsing/common/extras/fullTextOcrExtra.ts @@ -1,11 +1,17 @@ import { StringDict } from "@/parsing/stringDict.js"; import { ExtraField } from "./extras.js"; -/** Full-text OCR extra payload returned by compatible APIs. */ +/** + * Full-text OCR extra payload returned by compatible APIs. + */ export class FullTextOcrExtra extends ExtraField { - /** Concatenated OCR content. */ + /** + * Concatenated OCR content. + */ content?: string; - /** OCR language hints associated with the content. */ + /** + * OCR language hints associated with the content. + */ languages?: string; constructor(rawPrediction: StringDict) { diff --git a/src/v1/parsing/common/extras/ragExtra.ts b/src/v1/parsing/common/extras/ragExtra.ts index 22db08971..e7daeb4a3 100644 --- a/src/v1/parsing/common/extras/ragExtra.ts +++ b/src/v1/parsing/common/extras/ragExtra.ts @@ -1,7 +1,9 @@ import { ExtraField } from "./extras.js"; import { StringDict } from "@/parsing/stringDict.js"; -/** RAG extra payload returned by compatible APIs. */ +/** + * RAG extra payload returned by compatible APIs. + */ export class RAGExtra extends ExtraField { /** * ID reference of the document matched by the Retrieval-Augmented Generation. diff --git a/src/v1/parsing/common/feedback/feedbackResponse.ts b/src/v1/parsing/common/feedback/feedbackResponse.ts index 599a30c20..f1d3e2324 100644 --- a/src/v1/parsing/common/feedback/feedbackResponse.ts +++ b/src/v1/parsing/common/feedback/feedbackResponse.ts @@ -7,7 +7,9 @@ import { StringDict } from "@/parsing/stringDict.js"; * @category Synchronous */ export class FeedbackResponse extends ApiResponse { - /** A document feedback response. */ + /** + * A document feedback response. + */ feedback: StringDict; /** diff --git a/src/v1/parsing/common/inference.ts b/src/v1/parsing/common/inference.ts index d61019d77..e61b39e43 100644 --- a/src/v1/parsing/common/inference.ts +++ b/src/v1/parsing/common/inference.ts @@ -19,19 +19,33 @@ export abstract class Inference< DocT extends Prediction = Prediction, PageT extends DocT = DocT > { - /** A boolean denoting whether a given inference result was rotated. */ + /** + * A boolean denoting whether a given inference result was rotated. + */ isRotationApplied?: boolean; - /** Name and version of a given product. */ + /** + * Name and version of a given product. + */ product: Product; - /** Wrapper for a document's pages prediction. */ + /** + * Wrapper for a document's pages prediction. + */ pages: Page[] = []; - /** A document's top-level `Prediction`. */ + /** + * A document's top-level `Prediction`. + */ prediction!: DocT; - /** Extraneous fields relating to specific tools for some APIs. */ + /** + * Extraneous fields relating to specific tools for some APIs. + */ extras?: Extras; - /** Name of a document's endpoint. Has a default value for OTS APIs. */ + /** + * Name of a document's endpoint. Has a default value for OTS APIs. + */ endpointName?: string; - /** A document's version. Has a default value for OTS APIs. */ + /** + * A document's version. Has a default value for OTS APIs. + */ endpointVersion?: string; constructor(rawPrediction: StringDict) { @@ -65,7 +79,9 @@ export abstract class Inference< /** * Default string representation. */ - /** Returns a human-readable representation of the inference payload. */ + /** + * Returns a human-readable representation of the inference payload. + */ toString() { let pages = ""; diff --git a/src/v1/parsing/common/mvisionV1.ts b/src/v1/parsing/common/mvisionV1.ts index ca392aa86..9fe4abd37 100644 --- a/src/v1/parsing/common/mvisionV1.ts +++ b/src/v1/parsing/common/mvisionV1.ts @@ -3,7 +3,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { OcrPage } from "./ocrPage.js"; export class MvisionV1 { - /** List of words found on the page. */ + /** + * List of words found on the page. + */ pages: OcrPage[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/parsing/common/ocr.ts b/src/v1/parsing/common/ocr.ts index 477ea3940..3bf67876c 100644 --- a/src/v1/parsing/common/ocr.ts +++ b/src/v1/parsing/common/ocr.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { MvisionV1 } from "./mvisionV1.js"; export class Ocr { - /** Default Mindee OCR */ + /** + * Default Mindee OCR + */ mVisionV1: MvisionV1; constructor(rawPrediction: StringDict) { diff --git a/src/v1/parsing/common/ocrPage.ts b/src/v1/parsing/common/ocrPage.ts index c81ab3dfc..0cad67f4f 100644 --- a/src/v1/parsing/common/ocrPage.ts +++ b/src/v1/parsing/common/ocrPage.ts @@ -7,9 +7,13 @@ import { Word } from "@/v1/parsing/standard/index.js"; import { StringDict } from "@/parsing/stringDict.js"; export class OcrPage { - /** Flat list of all words read */ + /** + * Flat list of all words read + */ allWords: Word[] = []; - /** List of words by which line they are on */ + /** + * List of words by which line they are on + */ allLines: Word[][] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/parsing/common/orientation.ts b/src/v1/parsing/common/orientation.ts index 967555c85..ab094317d 100644 --- a/src/v1/parsing/common/orientation.ts +++ b/src/v1/parsing/common/orientation.ts @@ -8,9 +8,13 @@ interface OrientationFieldConstructor extends BaseFieldConstructor { * The clockwise rotation to apply (in degrees) to make the image upright. */ export class OrientationField extends BaseField { - /** Degrees of the rotation. */ + /** + * Degrees of the rotation. + */ value: number; - /** Page id. */ + /** + * Page id. + */ pageId!: number; /** diff --git a/src/v1/parsing/common/page.ts b/src/v1/parsing/common/page.ts index 206c44954..c514f133a 100644 --- a/src/v1/parsing/common/page.ts +++ b/src/v1/parsing/common/page.ts @@ -10,13 +10,21 @@ import { StringDict } from "@/parsing/stringDict.js"; * @typeParam T an extension of an `Prediction`. Mandatory in order to properly create a page-level prediction. */ export class Page { - /** The page's index (identifier). */ + /** + * The page's index (identifier). + */ id: number; - /** The page's orientation */ + /** + * The page's orientation + */ orientation?: OrientationField; - /** A page-level prediction. Can either be specific to pages or identical to the document prediction. */ + /** + * A page-level prediction. Can either be specific to pages or identical to the document prediction. + */ prediction: T; - /** Potential `Extras` fields sent back along with the prediction. */ + /** + * Potential `Extras` fields sent back along with the prediction. + */ extras?: Extras; /** diff --git a/src/v1/parsing/common/predictResponse.ts b/src/v1/parsing/common/predictResponse.ts index a801bbdbb..240c5780f 100644 --- a/src/v1/parsing/common/predictResponse.ts +++ b/src/v1/parsing/common/predictResponse.ts @@ -9,7 +9,9 @@ import { StringDict } from "@/parsing/stringDict.js"; * @category Synchronous */ export class PredictResponse extends ApiResponse { - /** A document prediction response. */ + /** + * A document prediction response. + */ document: Document; /** diff --git a/src/v1/parsing/common/prediction.ts b/src/v1/parsing/common/prediction.ts index b8da52b14..a23476fe6 100644 --- a/src/v1/parsing/common/prediction.ts +++ b/src/v1/parsing/common/prediction.ts @@ -1,2 +1,4 @@ -/** Marker base type for v1 prediction payload models. */ +/** + * Marker base type for v1 prediction payload models. + */ export class Prediction {} diff --git a/src/v1/parsing/generated/generatedList.ts b/src/v1/parsing/generated/generatedList.ts index 86c966148..ebe2f91d8 100644 --- a/src/v1/parsing/generated/generatedList.ts +++ b/src/v1/parsing/generated/generatedList.ts @@ -11,9 +11,13 @@ export interface GeneratedListFieldConstructor { * A list of values or objects, used in generated APIs. */ export class GeneratedListField { - /** Id of the page the object was found on. */ + /** + * Id of the page the object was found on. + */ pageId?: number; - /** List of word values. */ + /** + * List of word values. + */ values: Array; constructor({ diff --git a/src/v1/parsing/generated/generatedObject.ts b/src/v1/parsing/generated/generatedObject.ts index 6bbbf64ab..83ec6f562 100644 --- a/src/v1/parsing/generated/generatedObject.ts +++ b/src/v1/parsing/generated/generatedObject.ts @@ -2,19 +2,31 @@ import { StringDict } from "@/parsing/stringDict.js"; import { BaseFieldConstructor, PositionField } from "@/v1/parsing/standard/index.js"; -/** A JSON-like object, with miscellaneous values. */ +/** + * A JSON-like object, with miscellaneous values. + */ export class GeneratedObjectField { - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId?: number; - /** Confidence with which the value was assessed. */ + /** + * Confidence with which the value was assessed. + */ confidence?: number; - /** Raw unprocessed value, as it was sent by the server. */ + /** + * Raw unprocessed value, as it was sent by the server. + */ rawValue?: string; - /** List of all printable field names. */ + /** + * List of all printable field names. + */ private printableValues: string[]; - /** All potentially present fields. */ + /** + * All potentially present fields. + */ [key: string]: string | number | boolean | object | undefined; constructor({ @@ -102,12 +114,16 @@ export class GeneratedObjectField { return n.toString(); } - /** Returns the default string representation. */ + /** + * Returns the default string representation. + */ toString() { return this.toStringLevel(); } - /** Returns a field value by key from this generated object. */ + /** + * Returns a field value by key from this generated object. + */ get(fieldName: string): string | number | boolean | object | undefined { return this[fieldName]; } diff --git a/src/v1/parsing/localResponse.ts b/src/v1/parsing/localResponse.ts index 23cf63910..cdcbb4273 100644 --- a/src/v1/parsing/localResponse.ts +++ b/src/v1/parsing/localResponse.ts @@ -8,7 +8,9 @@ import { MindeeError } from "@/errors/index.js"; * Note: Has to be initialized through init() before use. */ export class LocalResponse extends BaseLocalResponse { - /** Loads a local JSON payload into a typed prediction response wrapper. */ + /** + * Loads a local JSON payload into a typed prediction response wrapper. + */ async loadPrediction( productClass: new (httpResponse: StringDict) => T ) { diff --git a/src/v1/parsing/standard/addressField.ts b/src/v1/parsing/standard/addressField.ts index bacbdbc0e..32771ae06 100644 --- a/src/v1/parsing/standard/addressField.ts +++ b/src/v1/parsing/standard/addressField.ts @@ -6,21 +6,37 @@ import { StringField, FieldConstructor } from "./text.js"; * address string through {@link StringField.value}. */ export class AddressField extends StringField { - /** Street number. */ + /** + * Street number. + */ streetNumber?: string; - /** Street name. */ + /** + * Street name. + */ streetName?: string; - /** PO-box number. */ + /** + * PO-box number. + */ poBox?: string; - /** Additional address complement. */ + /** + * Additional address complement. + */ addressComplement?: string; - /** City or locality. */ + /** + * City or locality. + */ city?: string; - /** Postal / ZIP code. */ + /** + * Postal / ZIP code. + */ postalCode?: string; - /** State, province or region. */ + /** + * State, province or region. + */ state?: string; - /** Country. */ + /** + * Country. + */ country?: string; constructor({ diff --git a/src/v1/parsing/standard/amount.ts b/src/v1/parsing/standard/amount.ts index af4892c04..d0fb992ab 100644 --- a/src/v1/parsing/standard/amount.ts +++ b/src/v1/parsing/standard/amount.ts @@ -6,7 +6,9 @@ import { floatToString } from "@/v1/parsing/common/index.js"; * A field containing an amount value. */ export class AmountField extends Field { - /** The value. */ + /** + * The value. + */ value?: number = undefined; /** diff --git a/src/v1/parsing/standard/base.ts b/src/v1/parsing/standard/base.ts index afc766212..20f210b3e 100644 --- a/src/v1/parsing/standard/base.ts +++ b/src/v1/parsing/standard/base.ts @@ -6,15 +6,25 @@ import { StringDict } from "@/parsing/stringDict.js"; * @property {boolean} reconstructed - Is the object reconstructed (not extracted by the API). * @property {number} pageId - Page ID for multi-page document. */ -/** Constructor payload shared by standard v1 fields. */ +/** + * Constructor payload shared by standard v1 fields. + */ export interface BaseFieldConstructor { - /** Raw field payload from API response. */ + /** + * Raw field payload from API response. + */ prediction: StringDict; - /** Key to read from `prediction` as field value. */ + /** + * Key to read from `prediction` as field value. + */ valueKey?: string; - /** Whether the field was reconstructed locally. */ + /** + * Whether the field was reconstructed locally. + */ reconstructed?: boolean; - /** Optional page identifier for multi-page documents. */ + /** + * Optional page identifier for multi-page documents. + */ pageId?: number; } @@ -22,11 +32,17 @@ export interface BaseFieldConstructor { * Base class for most fields. */ export class BaseField { - /** The value. */ + /** + * The value. + */ value?: string | number | boolean = undefined; - /** `true` when the field was reconstructed or computed using other fields. */ + /** + * `true` when the field was reconstructed or computed using other fields. + */ reconstructed: boolean; - /** Page ID for multi-page document. */ + /** + * Page ID for multi-page document. + */ pageId?: number; /** @@ -50,7 +66,9 @@ export class BaseField { } } - /** Compares two field values for semantic equality. */ + /** + * Compares two field values for semantic equality. + */ compare(other: BaseField) { if (this.value === null && other.value === null) return true; if (this.value === null || other.value === null) return false; diff --git a/src/v1/parsing/standard/boolean.ts b/src/v1/parsing/standard/boolean.ts index 866383504..c6ca9710a 100644 --- a/src/v1/parsing/standard/boolean.ts +++ b/src/v1/parsing/standard/boolean.ts @@ -12,7 +12,9 @@ export interface FieldConstructor { * A field containing a text value. */ export class BooleanField extends Field { - /** The value. */ + /** + * The value. + */ value?: boolean; constructor({ diff --git a/src/v1/parsing/standard/classification.ts b/src/v1/parsing/standard/classification.ts index d33cdfbbd..6556dc78a 100644 --- a/src/v1/parsing/standard/classification.ts +++ b/src/v1/parsing/standard/classification.ts @@ -4,9 +4,13 @@ import { BaseField, BaseFieldConstructor } from "./base.js"; * Represents a classifier value. */ export class ClassificationField extends BaseField { - /** The confidence score of the prediction. */ + /** + * The confidence score of the prediction. + */ confidence: number; - /** The classification. */ + /** + * The classification. + */ value?: string; constructor({ diff --git a/src/v1/parsing/standard/companyRegistration.ts b/src/v1/parsing/standard/companyRegistration.ts index 2d3ea50da..2ec584cf5 100644 --- a/src/v1/parsing/standard/companyRegistration.ts +++ b/src/v1/parsing/standard/companyRegistration.ts @@ -6,9 +6,13 @@ import { cleanOutString } from "@/v1/parsing/common/index.js"; * A company registration item. */ export class CompanyRegistrationField extends Field { - /** Registration identifier. */ + /** + * Registration identifier. + */ value?: string; - /** Type of company registration. */ + /** + * Type of company registration. + */ type: string; constructor({ @@ -20,7 +24,9 @@ export class CompanyRegistrationField extends Field { super({ prediction, valueKey, reconstructed, pageId }); this.type = prediction["type"]; } - /** Returns a row-formatted representation for table output. */ + /** + * Returns a row-formatted representation for table output. + */ toTableLine(): string { const printable = this.printableValues(); return `| ${printable["type"].padEnd(15)} | ${printable["value"].padEnd(20)} `; diff --git a/src/v1/parsing/standard/date.ts b/src/v1/parsing/standard/date.ts index a67e65e4a..fb8e3cd55 100644 --- a/src/v1/parsing/standard/date.ts +++ b/src/v1/parsing/standard/date.ts @@ -5,11 +5,17 @@ import { BaseFieldConstructor } from "./base.js"; * A field containing a date value. */ export class DateField extends Field { - /** Date string in ISO format. */ + /** + * Date string in ISO format. + */ value?: string; - /** Date as a standard JavaScript `Date` object. */ + /** + * Date as a standard JavaScript `Date` object. + */ public dateObject?: Date; - /** Whether the field was computed or retrieved directly from the document. */ + /** + * Whether the field was computed or retrieved directly from the document. + */ public isComputed?: boolean; /** @@ -38,7 +44,9 @@ export class DateField extends Field { } } - /** Compares two dates by calendar day (year/month/day). */ + /** + * Compares two dates by calendar day (year/month/day). + */ static compareDates(date1: Date, date2: Date): boolean { return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && diff --git a/src/v1/parsing/standard/field.ts b/src/v1/parsing/standard/field.ts index c709b5552..99d5c67fb 100644 --- a/src/v1/parsing/standard/field.ts +++ b/src/v1/parsing/standard/field.ts @@ -15,7 +15,9 @@ export class Field extends BaseField { * the field in the document. */ polygon: Polygon = new Polygon(); - /** The confidence score of the prediction. */ + /** + * The confidence score of the prediction. + */ confidence: number; /** diff --git a/src/v1/parsing/standard/locale.ts b/src/v1/parsing/standard/locale.ts index f5a41ba5a..9004db985 100644 --- a/src/v1/parsing/standard/locale.ts +++ b/src/v1/parsing/standard/locale.ts @@ -4,15 +4,25 @@ import { BaseField, BaseFieldConstructor } from "./base.js"; * The locale detected on the document. */ export class LocaleField extends BaseField { - /** Locale in ISO format. */ + /** + * Locale in ISO format. + */ value?: string; - /** The confidence score of the prediction. */ + /** + * The confidence score of the prediction. + */ confidence: number; - /** ISO 639-1 language code */ + /** + * ISO 639-1 language code + */ language?: string; - /** ISO 3166-1 alpha-2 (or alpha-3) country code */ + /** + * ISO 3166-1 alpha-2 (or alpha-3) country code + */ country?: string; - /** ISO 4217 currency code */ + /** + * ISO 4217 currency code + */ currency?: string; /** diff --git a/src/v1/parsing/standard/paymentDetails.ts b/src/v1/parsing/standard/paymentDetails.ts index e38fd94a2..42ce9bf9e 100644 --- a/src/v1/parsing/standard/paymentDetails.ts +++ b/src/v1/parsing/standard/paymentDetails.ts @@ -26,15 +26,25 @@ interface PaymentDetailsConstructor { * Information on a single payment. */ export class PaymentDetailsField extends Field { - /** Synonym for the `iban` property */ + /** + * Synonym for the `iban` property + */ value?: string; - /** The account number. */ + /** + * The account number. + */ accountNumber?: string; - /** The International Bank Account Number (IBAN). */ + /** + * The International Bank Account Number (IBAN). + */ iban?: string; - /** The routing number. */ + /** + * The routing number. + */ routingNumber?: string; - /** The bank's SWIFT Business Identifier Code (BIC). */ + /** + * The bank's SWIFT Business Identifier Code (BIC). + */ swift?: string; /** diff --git a/src/v1/parsing/standard/position.ts b/src/v1/parsing/standard/position.ts index 519b1c2f1..3df2bc907 100644 --- a/src/v1/parsing/standard/position.ts +++ b/src/v1/parsing/standard/position.ts @@ -11,15 +11,25 @@ export interface PositionFieldConstructor { * A field indicating a position or area on the document. */ export class PositionField { - /** Straight rectangle. */ + /** + * Straight rectangle. + */ boundingBox: Polygon; - /** Free polygon with up to 30 vertices. */ + /** + * Free polygon with up to 30 vertices. + */ polygon: Polygon; - /** Free polygon with 4 vertices. */ + /** + * Free polygon with 4 vertices. + */ quadrangle: Polygon; - /** Rectangle that may be oriented (can go beyond the canvas). */ + /** + * Rectangle that may be oriented (can go beyond the canvas). + */ rectangle: Polygon; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId?: number; constructor({ prediction = {}, pageId }: PositionFieldConstructor) { diff --git a/src/v1/parsing/standard/tax.ts b/src/v1/parsing/standard/tax.ts index 858916f5c..e961e64cd 100644 --- a/src/v1/parsing/standard/tax.ts +++ b/src/v1/parsing/standard/tax.ts @@ -17,15 +17,25 @@ interface TaxConstructor extends BaseFieldConstructor { * Represent a single tax line. */ export class TaxField extends Field { - /** The tax amount. */ + /** + * The tax amount. + */ value?: number = undefined; - /** The tax rate. */ + /** + * The tax rate. + */ rate?: number = undefined; - /** The tax code (HST, GST... for Canadian; City Tax, State tax for US, etc..). */ + /** + * The tax code (HST, GST... for Canadian; City Tax, State tax for US, etc..). + */ code?: string = undefined; - /** The tax base */ + /** + * The tax base + */ base?: number = undefined; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId!: number; /** @@ -109,7 +119,9 @@ export class TaxField extends Field { * Represent all items. */ export class Taxes extends Array { - /** Populates the taxes collection from raw prediction entries. */ + /** + * Populates the taxes collection from raw prediction entries. + */ init(prediction: StringDict[] = [], pageId: number | undefined) { for (const entry of prediction) { this.push( diff --git a/src/v1/parsing/standard/text.ts b/src/v1/parsing/standard/text.ts index 17ee6053f..71e982573 100644 --- a/src/v1/parsing/standard/text.ts +++ b/src/v1/parsing/standard/text.ts @@ -12,9 +12,13 @@ export interface FieldConstructor { * A field containing a text value. */ export class StringField extends Field { - /** The value. */ + /** + * The value. + */ value?: string; - /** Value as it appears on the document. */ + /** + * Value as it appears on the document. + */ rawValue?: string; constructor({ diff --git a/src/v1/parsing/standard/word.ts b/src/v1/parsing/standard/word.ts index 7c732442e..1f20f88ba 100644 --- a/src/v1/parsing/standard/word.ts +++ b/src/v1/parsing/standard/word.ts @@ -1,16 +1,22 @@ import { Polygon } from "@/geometry/index.js"; import { StringDict } from "@/parsing/index.js"; -/** OCR word item with text, confidence, and location polygon. */ +/** + * OCR word item with text, confidence, and location polygon. + */ export class Word { /** * Contains the relative vertices coordinates (points) of a polygon containing * the field in the document. */ polygon: Polygon; - /** OCR text content for the word. */ + /** + * OCR text content for the word. + */ text: string; - /** Confidence score for the OCR word. */ + /** + * Confidence score for the OCR word. + */ confidence: number; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/barcodeReader/barcodeReaderV1.ts b/src/v1/product/barcodeReader/barcodeReaderV1.ts index b5e9d0223..6a6ae7112 100644 --- a/src/v1/product/barcodeReader/barcodeReaderV1.ts +++ b/src/v1/product/barcodeReader/barcodeReaderV1.ts @@ -5,13 +5,21 @@ import { BarcodeReaderV1Document } from "./barcodeReaderV1Document.js"; * Barcode Reader API version 1 inference prediction. */ export class BarcodeReaderV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "barcode_reader"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: BarcodeReaderV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/barcodeReader/barcodeReaderV1Document.ts b/src/v1/product/barcodeReader/barcodeReaderV1Document.ts index 1191903c3..4e7acde43 100644 --- a/src/v1/product/barcodeReader/barcodeReaderV1Document.ts +++ b/src/v1/product/barcodeReader/barcodeReaderV1Document.ts @@ -9,9 +9,13 @@ import { StringField } from "@/v1/parsing/standard/index.js"; * Barcode Reader API version 1.0 document data. */ export class BarcodeReaderV1Document implements Prediction { - /** List of decoded 1D barcodes. */ + /** + * List of decoded 1D barcodes. + */ codes1D: StringField[] = []; - /** List of decoded 2D barcodes. */ + /** + * List of decoded 2D barcodes. + */ codes2D: StringField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/cropper/cropperV1.ts b/src/v1/product/cropper/cropperV1.ts index 2383a6cea..32ce7a032 100644 --- a/src/v1/product/cropper/cropperV1.ts +++ b/src/v1/product/cropper/cropperV1.ts @@ -6,13 +6,21 @@ import { CropperV1Page } from "./cropperV1Page.js"; * Cropper API version 1 inference prediction. */ export class CropperV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "cropper"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: CropperV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/cropper/cropperV1Page.ts b/src/v1/product/cropper/cropperV1Page.ts index 39b43e6e5..a44174f0d 100644 --- a/src/v1/product/cropper/cropperV1Page.ts +++ b/src/v1/product/cropper/cropperV1Page.ts @@ -7,7 +7,9 @@ import { CropperV1Document } from "./cropperV1Document.js"; * Cropper API version 1.1 page data. */ export class CropperV1Page extends CropperV1Document { - /** List of documents found in the image. */ + /** + * List of documents found in the image. + */ cropping: PositionField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/driverLicense/driverLicenseV1.ts b/src/v1/product/driverLicense/driverLicenseV1.ts index e1c5d52eb..7794e4513 100644 --- a/src/v1/product/driverLicense/driverLicenseV1.ts +++ b/src/v1/product/driverLicense/driverLicenseV1.ts @@ -5,13 +5,21 @@ import { DriverLicenseV1Document } from "./driverLicenseV1Document.js"; * Driver License API version 1 inference prediction. */ export class DriverLicenseV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "driver_license"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: DriverLicenseV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/driverLicense/driverLicenseV1Document.ts b/src/v1/product/driverLicense/driverLicenseV1Document.ts index 8a75b4f37..131c9abe8 100644 --- a/src/v1/product/driverLicense/driverLicenseV1Document.ts +++ b/src/v1/product/driverLicense/driverLicenseV1Document.ts @@ -9,31 +9,57 @@ import { DateField, StringField } from "@/v1/parsing/standard/index.js"; * Driver License API version 1.0 document data. */ export class DriverLicenseV1Document implements Prediction { - /** The category or class of the driver license. */ + /** + * The category or class of the driver license. + */ category: StringField; - /** The alpha-3 ISO 3166 code of the country where the driver license was issued. */ + /** + * The alpha-3 ISO 3166 code of the country where the driver license was issued. + */ countryCode: StringField; - /** The date of birth of the driver license holder. */ + /** + * The date of birth of the driver license holder. + */ dateOfBirth: DateField; - /** The DD number of the driver license. */ + /** + * The DD number of the driver license. + */ ddNumber: StringField; - /** The expiry date of the driver license. */ + /** + * The expiry date of the driver license. + */ expiryDate: DateField; - /** The first name of the driver license holder. */ + /** + * The first name of the driver license holder. + */ firstName: StringField; - /** The unique identifier of the driver license. */ + /** + * The unique identifier of the driver license. + */ id: StringField; - /** The date when the driver license was issued. */ + /** + * The date when the driver license was issued. + */ issuedDate: DateField; - /** The authority that issued the driver license. */ + /** + * The authority that issued the driver license. + */ issuingAuthority: StringField; - /** The last name of the driver license holder. */ + /** + * The last name of the driver license holder. + */ lastName: StringField; - /** The Machine Readable Zone (MRZ) of the driver license. */ + /** + * The Machine Readable Zone (MRZ) of the driver license. + */ mrz: StringField; - /** The place of birth of the driver license holder. */ + /** + * The place of birth of the driver license holder. + */ placeOfBirth: StringField; - /** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */ + /** + * Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. + */ state: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/financialDocument/financialDocumentV1.ts b/src/v1/product/financialDocument/financialDocumentV1.ts index b8216510a..601129c08 100644 --- a/src/v1/product/financialDocument/financialDocumentV1.ts +++ b/src/v1/product/financialDocument/financialDocumentV1.ts @@ -5,13 +5,21 @@ import { FinancialDocumentV1Document } from "./financialDocumentV1Document.js"; * Financial Document API version 1 inference prediction. */ export class FinancialDocumentV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "financial_document"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: FinancialDocumentV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/financialDocument/financialDocumentV1Document.ts b/src/v1/product/financialDocument/financialDocumentV1Document.ts index 396c8f7da..c840ddd3d 100644 --- a/src/v1/product/financialDocument/financialDocumentV1Document.ts +++ b/src/v1/product/financialDocument/financialDocumentV1Document.ts @@ -20,74 +20,138 @@ import { * Financial Document API version 1.14 document data. */ export class FinancialDocumentV1Document implements Prediction { - /** The customer's address used for billing. */ + /** + * The customer's address used for billing. + */ billingAddress: AddressField; - /** The purchase category. */ + /** + * The purchase category. + */ category: ClassificationField; - /** The address of the customer. */ + /** + * The address of the customer. + */ customerAddress: AddressField; - /** List of company registration numbers associated to the customer. */ + /** + * List of company registration numbers associated to the customer. + */ customerCompanyRegistrations: CompanyRegistrationField[] = []; - /** The customer account number or identifier from the supplier. */ + /** + * The customer account number or identifier from the supplier. + */ customerId: StringField; - /** The name of the customer. */ + /** + * The name of the customer. + */ customerName: StringField; - /** The date the purchase was made. */ + /** + * The date the purchase was made. + */ date: DateField; - /** The document number or identifier (invoice number or receipt number). */ + /** + * The document number or identifier (invoice number or receipt number). + */ documentNumber: StringField; /** * The type of the document: INVOICE or CREDIT NOTE if it is an invoice, CREDIT CARD RECEIPT or EXPENSE RECEIPT if it * is a receipt. */ documentType: ClassificationField; - /** Document type extended. */ + /** + * Document type extended. + */ documentTypeExtended: ClassificationField; - /** The date on which the payment is due. */ + /** + * The date on which the payment is due. + */ dueDate: DateField; - /** The invoice number or identifier only if document is an invoice. */ + /** + * The invoice number or identifier only if document is an invoice. + */ invoiceNumber: StringField; - /** List of line item present on the document. */ + /** + * List of line item present on the document. + */ lineItems: FinancialDocumentV1LineItem[] = []; - /** The locale of the document. */ + /** + * The locale of the document. + */ locale: LocaleField; - /** The date on which the payment is due / fullfilled. */ + /** + * The date on which the payment is due / fullfilled. + */ paymentDate: DateField; - /** The purchase order number, only if the document is an invoice. */ + /** + * The purchase order number, only if the document is an invoice. + */ poNumber: StringField; - /** The receipt number or identifier only if document is a receipt. */ + /** + * The receipt number or identifier only if document is a receipt. + */ receiptNumber: StringField; - /** List of Reference numbers, including PO number, only if the document is an invoice. */ + /** + * List of Reference numbers, including PO number, only if the document is an invoice. + */ referenceNumbers: StringField[] = []; - /** The customer's address used for shipping. */ + /** + * The customer's address used for shipping. + */ shippingAddress: AddressField; - /** The purchase subcategory for transport, food and shooping. */ + /** + * The purchase subcategory for transport, food and shooping. + */ subcategory: ClassificationField; - /** The address of the supplier or merchant. */ + /** + * The address of the supplier or merchant. + */ supplierAddress: AddressField; - /** List of company registration numbers associated to the supplier. */ + /** + * List of company registration numbers associated to the supplier. + */ supplierCompanyRegistrations: CompanyRegistrationField[] = []; - /** The email of the supplier or merchant. */ + /** + * The email of the supplier or merchant. + */ supplierEmail: StringField; - /** The name of the supplier or merchant. */ + /** + * The name of the supplier or merchant. + */ supplierName: StringField; - /** List of payment details associated to the supplier (only for invoices). */ + /** + * List of payment details associated to the supplier (only for invoices). + */ supplierPaymentDetails: PaymentDetailsField[] = []; - /** The phone number of the supplier or merchant. */ + /** + * The phone number of the supplier or merchant. + */ supplierPhoneNumber: StringField; - /** The website URL of the supplier or merchant. */ + /** + * The website URL of the supplier or merchant. + */ supplierWebsite: StringField; - /** List of all taxes on the document. */ + /** + * List of all taxes on the document. + */ taxes: Taxes; - /** The time the purchase was made (only for receipts). */ + /** + * The time the purchase was made (only for receipts). + */ time: StringField; - /** The total amount of tip and gratuity */ + /** + * The total amount of tip and gratuity + */ tip: AmountField; - /** The total amount paid: includes taxes, tips, fees, and other charges. */ + /** + * The total amount paid: includes taxes, tips, fees, and other charges. + */ totalAmount: AmountField; - /** The net amount paid: does not include taxes, fees, and discounts. */ + /** + * The net amount paid: does not include taxes, fees, and discounts. + */ totalNet: AmountField; - /** The sum of all taxes present on the document. */ + /** + * The sum of all taxes present on the document. + */ totalTax: AmountField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/financialDocument/financialDocumentV1LineItem.ts b/src/v1/product/financialDocument/financialDocumentV1LineItem.ts index 9daec38d4..399f3bd12 100644 --- a/src/v1/product/financialDocument/financialDocumentV1LineItem.ts +++ b/src/v1/product/financialDocument/financialDocumentV1LineItem.ts @@ -6,25 +6,45 @@ import { Polygon } from "@/geometry/index.js"; * List of line item present on the document. */ export class FinancialDocumentV1LineItem { - /** The item description. */ + /** + * The item description. + */ description: string | null; - /** The product code referring to the item. */ + /** + * The product code referring to the item. + */ productCode: string | null; - /** The item quantity */ + /** + * The item quantity + */ quantity: number | null; - /** The item tax amount. */ + /** + * The item tax amount. + */ taxAmount: number | null; - /** The item tax rate in percentage. */ + /** + * The item tax rate in percentage. + */ taxRate: number | null; - /** The item total amount. */ + /** + * The item total amount. + */ totalAmount: number | null; - /** The item unit of measure. */ + /** + * The item unit of measure. + */ unitMeasure: string | null; - /** The item unit price. */ + /** + * The item unit price. + */ unitPrice: number | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts index d38530b96..aa61fc227 100644 --- a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.ts @@ -5,13 +5,21 @@ import { BankAccountDetailsV1Document } from "./bankAccountDetailsV1Document.js" * Bank Account Details API version 1 inference prediction. */ export class BankAccountDetailsV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "bank_account_details"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: BankAccountDetailsV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts index 310af901f..8672fb93f 100644 --- a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.ts @@ -9,11 +9,17 @@ import { StringField } from "@/v1/parsing/standard/index.js"; * Bank Account Details API version 1.0 document data. */ export class BankAccountDetailsV1Document implements Prediction { - /** The name of the account holder as seen on the document. */ + /** + * The name of the account holder as seen on the document. + */ accountHolderName: StringField; - /** The International Bank Account Number (IBAN). */ + /** + * The International Bank Account Number (IBAN). + */ iban: StringField; - /** The bank's SWIFT Business Identifier Code (BIC). */ + /** + * The bank's SWIFT Business Identifier Code (BIC). + */ swift: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts index 2eb6a721e..81ed5b7a4 100644 --- a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.ts @@ -5,13 +5,21 @@ import { BankAccountDetailsV2Document } from "./bankAccountDetailsV2Document.js" * Bank Account Details API version 2 inference prediction. */ export class BankAccountDetailsV2 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "bank_account_details"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "2"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: BankAccountDetailsV2Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts index a2096a174..9a4400c33 100644 --- a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.ts @@ -5,17 +5,29 @@ import { Polygon } from "@/geometry/index.js"; * Full extraction of BBAN, including: branch code, bank code, account and key. */ export class BankAccountDetailsV2Bban { - /** The BBAN bank code outputted as a string. */ + /** + * The BBAN bank code outputted as a string. + */ bbanBankCode: string | null; - /** The BBAN branch code outputted as a string. */ + /** + * The BBAN branch code outputted as a string. + */ bbanBranchCode: string | null; - /** The BBAN key outputted as a string. */ + /** + * The BBAN key outputted as a string. + */ bbanKey: string | null; - /** The BBAN Account number outputted as a string. */ + /** + * The BBAN Account number outputted as a string. + */ bbanNumber: string | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts index c96053be2..8f1dbc0d8 100644 --- a/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts +++ b/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.ts @@ -10,13 +10,21 @@ import { StringField } from "@/v1/parsing/standard/index.js"; * Bank Account Details API version 2.0 document data. */ export class BankAccountDetailsV2Document implements Prediction { - /** Full extraction of the account holders names. */ + /** + * Full extraction of the account holders names. + */ accountHoldersNames: StringField; - /** Full extraction of BBAN, including: branch code, bank code, account and key. */ + /** + * Full extraction of BBAN, including: branch code, bank code, account and key. + */ bban: BankAccountDetailsV2Bban; - /** Full extraction of the IBAN number. */ + /** + * Full extraction of the IBAN number. + */ iban: StringField; - /** Full extraction of the SWIFT code. */ + /** + * Full extraction of the SWIFT code. + */ swiftCode: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/fr/carteGrise/carteGriseV1.ts b/src/v1/product/fr/carteGrise/carteGriseV1.ts index b3b240519..c6a2cd6f4 100644 --- a/src/v1/product/fr/carteGrise/carteGriseV1.ts +++ b/src/v1/product/fr/carteGrise/carteGriseV1.ts @@ -5,13 +5,21 @@ import { CarteGriseV1Document } from "./carteGriseV1Document.js"; * Carte Grise API version 1 inference prediction. */ export class CarteGriseV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "carte_grise"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: CarteGriseV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/fr/carteGrise/carteGriseV1Document.ts b/src/v1/product/fr/carteGrise/carteGriseV1Document.ts index 421079ff8..88d132420 100644 --- a/src/v1/product/fr/carteGrise/carteGriseV1Document.ts +++ b/src/v1/product/fr/carteGrise/carteGriseV1Document.ts @@ -9,87 +9,169 @@ import { DateField, StringField } from "@/v1/parsing/standard/index.js"; * Carte Grise API version 1.1 document data. */ export class CarteGriseV1Document implements Prediction { - /** The vehicle's license plate number. */ + /** + * The vehicle's license plate number. + */ a: StringField; - /** The vehicle's first release date. */ + /** + * The vehicle's first release date. + */ b: DateField; - /** The vehicle owner's full name including maiden name. */ + /** + * The vehicle owner's full name including maiden name. + */ c1: StringField; - /** The vehicle owner's address. */ + /** + * The vehicle owner's address. + */ c3: StringField; - /** Number of owners of the license certificate. */ + /** + * Number of owners of the license certificate. + */ c41: StringField; - /** Mentions about the ownership of the vehicle. */ + /** + * Mentions about the ownership of the vehicle. + */ c4A: StringField; - /** The vehicle's brand. */ + /** + * The vehicle's brand. + */ d1: StringField; - /** The vehicle's commercial name. */ + /** + * The vehicle's commercial name. + */ d3: StringField; - /** The Vehicle Identification Number (VIN). */ + /** + * The Vehicle Identification Number (VIN). + */ e: StringField; - /** The vehicle's maximum admissible weight. */ + /** + * The vehicle's maximum admissible weight. + */ f1: StringField; - /** The vehicle's maximum admissible weight within the license's state. */ + /** + * The vehicle's maximum admissible weight within the license's state. + */ f2: StringField; - /** The vehicle's maximum authorized weight with coupling. */ + /** + * The vehicle's maximum authorized weight with coupling. + */ f3: StringField; - /** The document's formula number. */ + /** + * The document's formula number. + */ formulaNumber: StringField; - /** The vehicle's weight with coupling if tractor different than category M1. */ + /** + * The vehicle's weight with coupling if tractor different than category M1. + */ g: StringField; - /** The vehicle's national empty weight. */ + /** + * The vehicle's national empty weight. + */ g1: StringField; - /** The car registration date of the given certificate. */ + /** + * The car registration date of the given certificate. + */ i: DateField; - /** The vehicle's category. */ + /** + * The vehicle's category. + */ j: StringField; - /** The vehicle's national type. */ + /** + * The vehicle's national type. + */ j1: StringField; - /** The vehicle's body type (CE). */ + /** + * The vehicle's body type (CE). + */ j2: StringField; - /** The vehicle's body type (National designation). */ + /** + * The vehicle's body type (National designation). + */ j3: StringField; - /** Machine Readable Zone, first line. */ + /** + * Machine Readable Zone, first line. + */ mrz1: StringField; - /** Machine Readable Zone, second line. */ + /** + * Machine Readable Zone, second line. + */ mrz2: StringField; - /** The vehicle's owner first name. */ + /** + * The vehicle's owner first name. + */ ownerFirstName: StringField; - /** The vehicle's owner surname. */ + /** + * The vehicle's owner surname. + */ ownerSurname: StringField; - /** The vehicle engine's displacement (cm3). */ + /** + * The vehicle engine's displacement (cm3). + */ p1: StringField; - /** The vehicle's maximum net power (kW). */ + /** + * The vehicle's maximum net power (kW). + */ p2: StringField; - /** The vehicle's fuel type or energy source. */ + /** + * The vehicle's fuel type or energy source. + */ p3: StringField; - /** The vehicle's administrative power (fiscal horsepower). */ + /** + * The vehicle's administrative power (fiscal horsepower). + */ p6: StringField; - /** The vehicle's power to weight ratio. */ + /** + * The vehicle's power to weight ratio. + */ q: StringField; - /** The vehicle's number of seats. */ + /** + * The vehicle's number of seats. + */ s1: StringField; - /** The vehicle's number of standing rooms (person). */ + /** + * The vehicle's number of standing rooms (person). + */ s2: StringField; - /** The vehicle's sound level (dB). */ + /** + * The vehicle's sound level (dB). + */ u1: StringField; - /** The vehicle engine's rotation speed (RPM). */ + /** + * The vehicle engine's rotation speed (RPM). + */ u2: StringField; - /** The vehicle's CO2 emission (g/km). */ + /** + * The vehicle's CO2 emission (g/km). + */ v7: StringField; - /** Next technical control date. */ + /** + * Next technical control date. + */ x1: StringField; - /** Amount of the regional proportional tax of the registration (in euros). */ + /** + * Amount of the regional proportional tax of the registration (in euros). + */ y1: StringField; - /** Amount of the additional parafiscal tax of the registration (in euros). */ + /** + * Amount of the additional parafiscal tax of the registration (in euros). + */ y2: StringField; - /** Amount of the additional CO2 tax of the registration (in euros). */ + /** + * Amount of the additional CO2 tax of the registration (in euros). + */ y3: StringField; - /** Amount of the fee for managing the registration (in euros). */ + /** + * Amount of the fee for managing the registration (in euros). + */ y4: StringField; - /** Amount of the fee for delivery of the registration certificate in euros. */ + /** + * Amount of the fee for delivery of the registration certificate in euros. + */ y5: StringField; - /** Total amount of registration fee to be paid in euros. */ + /** + * Total amount of registration fee to be paid in euros. + */ y6: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/fr/idCard/idCardV2.ts b/src/v1/product/fr/idCard/idCardV2.ts index 3ebfdfe88..c31e6ba7e 100644 --- a/src/v1/product/fr/idCard/idCardV2.ts +++ b/src/v1/product/fr/idCard/idCardV2.ts @@ -6,13 +6,21 @@ import { IdCardV2Page } from "./idCardV2Page.js"; * Carte Nationale d'Identité API version 2 inference prediction. */ export class IdCardV2 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "idcard_fr"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "2"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: IdCardV2Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/fr/idCard/idCardV2Document.ts b/src/v1/product/fr/idCard/idCardV2Document.ts index 932322af7..5cc62a499 100644 --- a/src/v1/product/fr/idCard/idCardV2Document.ts +++ b/src/v1/product/fr/idCard/idCardV2Document.ts @@ -9,35 +9,65 @@ import { DateField, StringField } from "@/v1/parsing/standard/index.js"; * Carte Nationale d'Identité API version 2.0 document data. */ export class IdCardV2Document implements Prediction { - /** The alternate name of the card holder. */ + /** + * The alternate name of the card holder. + */ alternateName: StringField; - /** The name of the issuing authority. */ + /** + * The name of the issuing authority. + */ authority: StringField; - /** The date of birth of the card holder. */ + /** + * The date of birth of the card holder. + */ birthDate: DateField; - /** The place of birth of the card holder. */ + /** + * The place of birth of the card holder. + */ birthPlace: StringField; - /** The card access number (CAN). */ + /** + * The card access number (CAN). + */ cardAccessNumber: StringField; - /** The document number. */ + /** + * The document number. + */ documentNumber: StringField; - /** The expiry date of the identification card. */ + /** + * The expiry date of the identification card. + */ expiryDate: DateField; - /** The gender of the card holder. */ + /** + * The gender of the card holder. + */ gender: StringField; - /** The given name(s) of the card holder. */ + /** + * The given name(s) of the card holder. + */ givenNames: StringField[] = []; - /** The date of issue of the identification card. */ + /** + * The date of issue of the identification card. + */ issueDate: DateField; - /** The Machine Readable Zone, first line. */ + /** + * The Machine Readable Zone, first line. + */ mrz1: StringField; - /** The Machine Readable Zone, second line. */ + /** + * The Machine Readable Zone, second line. + */ mrz2: StringField; - /** The Machine Readable Zone, third line. */ + /** + * The Machine Readable Zone, third line. + */ mrz3: StringField; - /** The nationality of the card holder. */ + /** + * The nationality of the card holder. + */ nationality: StringField; - /** The surname of the card holder. */ + /** + * The surname of the card holder. + */ surname: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/fr/idCard/idCardV2Page.ts b/src/v1/product/fr/idCard/idCardV2Page.ts index 5ad0bcb5a..d569d0c18 100644 --- a/src/v1/product/fr/idCard/idCardV2Page.ts +++ b/src/v1/product/fr/idCard/idCardV2Page.ts @@ -6,9 +6,13 @@ import { IdCardV2Document } from "./idCardV2Document.js"; * Carte Nationale d'Identité API version 2.0 page data. */ export class IdCardV2Page extends IdCardV2Document { - /** The sides of the document which are visible. */ + /** + * The sides of the document which are visible. + */ documentSide: ClassificationField; - /** The document type or format. */ + /** + * The document type or format. + */ documentType: ClassificationField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/generated/generatedV1.ts b/src/v1/product/generated/generatedV1.ts index 4e3cb5220..ce5138e83 100644 --- a/src/v1/product/generated/generatedV1.ts +++ b/src/v1/product/generated/generatedV1.ts @@ -6,13 +6,21 @@ import { GeneratedV1Page } from "./generatedV1Page.js"; * Generated API V1 inference results. */ export class GeneratedV1 extends Inference { - /** The endpoint's name. Note: placeholder for custom APIs. */ + /** + * The endpoint's name. Note: placeholder for custom APIs. + */ endpointName = "custom"; - /** The endpoint's version. Note: placeholder for custom APIs. */ + /** + * The endpoint's version. Note: placeholder for custom APIs. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: GeneratedV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/generated/generatedV1Prediction.ts b/src/v1/product/generated/generatedV1Prediction.ts index e1dc9228d..29ad02330 100644 --- a/src/v1/product/generated/generatedV1Prediction.ts +++ b/src/v1/product/generated/generatedV1Prediction.ts @@ -3,9 +3,13 @@ import { GeneratedListField, GeneratedObjectField } from "@/v1/parsing/generated import { StringField } from "@/v1/parsing/standard/index.js"; -/** Dynamic prediction container for generated v1 products. */ +/** + * Dynamic prediction container for generated v1 products. + */ export class GeneratedV1Prediction implements Prediction { - /** Map of all fields in the document. */ + /** + * Map of all fields in the document. + */ fields: Map; constructor() { diff --git a/src/v1/product/internationalId/internationalIdV2.ts b/src/v1/product/internationalId/internationalIdV2.ts index 05dc15124..fcf5937ba 100644 --- a/src/v1/product/internationalId/internationalIdV2.ts +++ b/src/v1/product/internationalId/internationalIdV2.ts @@ -5,13 +5,21 @@ import { InternationalIdV2Document } from "./internationalIdV2Document.js"; * International ID API version 2 inference prediction. */ export class InternationalIdV2 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "international_id"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "2"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: InternationalIdV2Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/internationalId/internationalIdV2Document.ts b/src/v1/product/internationalId/internationalIdV2Document.ts index fec62b3b4..5ef9c9a74 100644 --- a/src/v1/product/internationalId/internationalIdV2Document.ts +++ b/src/v1/product/internationalId/internationalIdV2Document.ts @@ -13,39 +13,73 @@ import { * International ID API version 2.2 document data. */ export class InternationalIdV2Document implements Prediction { - /** The physical address of the document holder. */ + /** + * The physical address of the document holder. + */ address: StringField; - /** The date of birth of the document holder. */ + /** + * The date of birth of the document holder. + */ birthDate: DateField; - /** The place of birth of the document holder. */ + /** + * The place of birth of the document holder. + */ birthPlace: StringField; - /** The country where the document was issued. */ + /** + * The country where the document was issued. + */ countryOfIssue: StringField; - /** The unique identifier assigned to the document. */ + /** + * The unique identifier assigned to the document. + */ documentNumber: StringField; - /** The type of personal identification document. */ + /** + * The type of personal identification document. + */ documentType: ClassificationField; - /** The date when the document becomes invalid. */ + /** + * The date when the document becomes invalid. + */ expiryDate: DateField; - /** The list of the document holder's given names. */ + /** + * The list of the document holder's given names. + */ givenNames: StringField[] = []; - /** The date when the document was issued. */ + /** + * The date when the document was issued. + */ issueDate: DateField; - /** The Machine Readable Zone, first line. */ + /** + * The Machine Readable Zone, first line. + */ mrzLine1: StringField; - /** The Machine Readable Zone, second line. */ + /** + * The Machine Readable Zone, second line. + */ mrzLine2: StringField; - /** The Machine Readable Zone, third line. */ + /** + * The Machine Readable Zone, third line. + */ mrzLine3: StringField; - /** The country of citizenship of the document holder. */ + /** + * The country of citizenship of the document holder. + */ nationality: StringField; - /** The unique identifier assigned to the document holder. */ + /** + * The unique identifier assigned to the document holder. + */ personalNumber: StringField; - /** The biological sex of the document holder. */ + /** + * The biological sex of the document holder. + */ sex: StringField; - /** The state or territory where the document was issued. */ + /** + * The state or territory where the document was issued. + */ stateOfIssue: StringField; - /** The list of the document holder's family names. */ + /** + * The list of the document holder's family names. + */ surnames: StringField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/invoice/invoiceV4.ts b/src/v1/product/invoice/invoiceV4.ts index 2d3cb4df5..05290be52 100644 --- a/src/v1/product/invoice/invoiceV4.ts +++ b/src/v1/product/invoice/invoiceV4.ts @@ -5,13 +5,21 @@ import { InvoiceV4Document } from "./invoiceV4Document.js"; * Invoice API version 4 inference prediction. */ export class InvoiceV4 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "invoices"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "4"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: InvoiceV4Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/invoice/invoiceV4Document.ts b/src/v1/product/invoice/invoiceV4Document.ts index eb5bc45c0..bedd1f83a 100644 --- a/src/v1/product/invoice/invoiceV4Document.ts +++ b/src/v1/product/invoice/invoiceV4Document.ts @@ -20,63 +20,121 @@ import { * Invoice API version 4.11 document data. */ export class InvoiceV4Document implements Prediction { - /** The customer billing address. */ + /** + * The customer billing address. + */ billingAddress: AddressField; - /** The purchase category. */ + /** + * The purchase category. + */ category: ClassificationField; - /** The address of the customer. */ + /** + * The address of the customer. + */ customerAddress: AddressField; - /** List of company registration numbers associated to the customer. */ + /** + * List of company registration numbers associated to the customer. + */ customerCompanyRegistrations: CompanyRegistrationField[] = []; - /** The customer account number or identifier from the supplier. */ + /** + * The customer account number or identifier from the supplier. + */ customerId: StringField; - /** The name of the customer or client. */ + /** + * The name of the customer or client. + */ customerName: StringField; - /** The date the purchase was made. */ + /** + * The date the purchase was made. + */ date: DateField; - /** Document type: INVOICE or CREDIT NOTE. */ + /** + * Document type: INVOICE or CREDIT NOTE. + */ documentType: ClassificationField; - /** Document type extended. */ + /** + * Document type extended. + */ documentTypeExtended: ClassificationField; - /** The date on which the payment is due. */ + /** + * The date on which the payment is due. + */ dueDate: DateField; - /** The invoice number or identifier. */ + /** + * The invoice number or identifier. + */ invoiceNumber: StringField; - /** List of all the line items present on the invoice. */ + /** + * List of all the line items present on the invoice. + */ lineItems: InvoiceV4LineItem[] = []; - /** The locale of the document. */ + /** + * The locale of the document. + */ locale: LocaleField; - /** The date on which the payment is due / was full-filled. */ + /** + * The date on which the payment is due / was full-filled. + */ paymentDate: DateField; - /** The purchase order number. */ + /** + * The purchase order number. + */ poNumber: StringField; - /** List of all reference numbers on the invoice, including the purchase order number. */ + /** + * List of all reference numbers on the invoice, including the purchase order number. + */ referenceNumbers: StringField[] = []; - /** Customer's delivery address. */ + /** + * Customer's delivery address. + */ shippingAddress: AddressField; - /** The purchase subcategory for transport, food and shopping. */ + /** + * The purchase subcategory for transport, food and shopping. + */ subcategory: ClassificationField; - /** The address of the supplier or merchant. */ + /** + * The address of the supplier or merchant. + */ supplierAddress: AddressField; - /** List of company registration numbers associated to the supplier. */ + /** + * List of company registration numbers associated to the supplier. + */ supplierCompanyRegistrations: CompanyRegistrationField[] = []; - /** The email address of the supplier or merchant. */ + /** + * The email address of the supplier or merchant. + */ supplierEmail: StringField; - /** The name of the supplier or merchant. */ + /** + * The name of the supplier or merchant. + */ supplierName: StringField; - /** List of payment details associated to the supplier of the invoice. */ + /** + * List of payment details associated to the supplier of the invoice. + */ supplierPaymentDetails: PaymentDetailsField[] = []; - /** The phone number of the supplier or merchant. */ + /** + * The phone number of the supplier or merchant. + */ supplierPhoneNumber: StringField; - /** The website URL of the supplier or merchant. */ + /** + * The website URL of the supplier or merchant. + */ supplierWebsite: StringField; - /** List of taxes. Each item contains the detail of the tax. */ + /** + * List of taxes. Each item contains the detail of the tax. + */ taxes: Taxes; - /** The total amount of the invoice: includes taxes, tips, fees, and other charges. */ + /** + * The total amount of the invoice: includes taxes, tips, fees, and other charges. + */ totalAmount: AmountField; - /** The net amount of the invoice: does not include taxes, fees, and discounts. */ + /** + * The net amount of the invoice: does not include taxes, fees, and discounts. + */ totalNet: AmountField; - /** The total tax: the sum of all the taxes for this invoice. */ + /** + * The total tax: the sum of all the taxes for this invoice. + */ totalTax: AmountField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/invoice/invoiceV4LineItem.ts b/src/v1/product/invoice/invoiceV4LineItem.ts index b9b95fea2..39ff3b1ec 100644 --- a/src/v1/product/invoice/invoiceV4LineItem.ts +++ b/src/v1/product/invoice/invoiceV4LineItem.ts @@ -6,25 +6,45 @@ import { Polygon } from "@/geometry/index.js"; * List of all the line items present on the invoice. */ export class InvoiceV4LineItem { - /** The item description. */ + /** + * The item description. + */ description: string | null; - /** The product code of the item. */ + /** + * The product code of the item. + */ productCode: string | null; - /** The item quantity */ + /** + * The item quantity + */ quantity: number | null; - /** The item tax amount. */ + /** + * The item tax amount. + */ taxAmount: number | null; - /** The item tax rate in percentage. */ + /** + * The item tax rate in percentage. + */ taxRate: number | null; - /** The item total amount. */ + /** + * The item total amount. + */ totalAmount: number | null; - /** The item unit of measure. */ + /** + * The item unit of measure. + */ unitMeasure: string | null; - /** The item unit price. */ + /** + * The item unit price. + */ unitPrice: number | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/invoiceSplitter/invoiceSplitterV1.ts b/src/v1/product/invoiceSplitter/invoiceSplitterV1.ts index 97080e19a..5c5ec748f 100644 --- a/src/v1/product/invoiceSplitter/invoiceSplitterV1.ts +++ b/src/v1/product/invoiceSplitter/invoiceSplitterV1.ts @@ -5,13 +5,21 @@ import { InvoiceSplitterV1Document } from "./invoiceSplitterV1Document.js"; * Invoice Splitter API version 1 inference prediction. */ export class InvoiceSplitterV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "invoice_splitter"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: InvoiceSplitterV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts b/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts index a27164cf2..3f9eb1f2f 100644 --- a/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts +++ b/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.ts @@ -10,7 +10,9 @@ import { InvoiceSplitterV1InvoicePageGroup } from "./invoiceSplitterV1InvoicePag * Invoice Splitter API version 1.4 document data. */ export class InvoiceSplitterV1Document implements Prediction { - /** List of page groups. Each group represents a single invoice within a multi-invoice document. */ + /** + * List of page groups. Each group represents a single invoice within a multi-invoice document. + */ invoicePageGroups: InvoiceSplitterV1InvoicePageGroup[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts b/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts index d3f725524..16c81ec4c 100644 --- a/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts +++ b/src/v1/product/invoiceSplitter/invoiceSplitterV1InvoicePageGroup.ts @@ -5,11 +5,17 @@ import { Polygon } from "@/geometry/index.js"; * List of page groups. Each group represents a single invoice within a multi-invoice document. */ export class InvoiceSplitterV1InvoicePageGroup { - /** List of page indexes that belong to the same invoice (group). */ + /** + * List of page indexes that belong to the same invoice (group). + */ pageIndexes: Array | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts index 0433d9a0c..59c39a791 100644 --- a/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts +++ b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.ts @@ -5,13 +5,21 @@ import { MultiReceiptsDetectorV1Document } from "./multiReceiptsDetectorV1Docume * Multi Receipts Detector API version 1 inference prediction. */ export class MultiReceiptsDetectorV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "multi_receipts_detector"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: MultiReceiptsDetectorV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts index 90cfefe37..efeaf69b6 100644 --- a/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts +++ b/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.ts @@ -9,7 +9,9 @@ import { PositionField } from "@/v1/parsing/standard/index.js"; * Multi Receipts Detector API version 1.1 document data. */ export class MultiReceiptsDetectorV1Document implements Prediction { - /** Positions of the receipts on the document. */ + /** + * Positions of the receipts on the document. + */ receipts: PositionField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/passport/passportV1.ts b/src/v1/product/passport/passportV1.ts index f3c916474..2c946a94b 100644 --- a/src/v1/product/passport/passportV1.ts +++ b/src/v1/product/passport/passportV1.ts @@ -5,13 +5,21 @@ import { PassportV1Document } from "./passportV1Document.js"; * Passport API version 1 inference prediction. */ export class PassportV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "passport"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: PassportV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/passport/passportV1Document.ts b/src/v1/product/passport/passportV1Document.ts index 81518c487..a7bf64581 100644 --- a/src/v1/product/passport/passportV1Document.ts +++ b/src/v1/product/passport/passportV1Document.ts @@ -9,27 +9,49 @@ import { DateField, StringField } from "@/v1/parsing/standard/index.js"; * Passport API version 1.1 document data. */ export class PassportV1Document implements Prediction { - /** The date of birth of the passport holder. */ + /** + * The date of birth of the passport holder. + */ birthDate: DateField; - /** The place of birth of the passport holder. */ + /** + * The place of birth of the passport holder. + */ birthPlace: StringField; - /** The country's 3 letter code (ISO 3166-1 alpha-3). */ + /** + * The country's 3 letter code (ISO 3166-1 alpha-3). + */ country: StringField; - /** The expiry date of the passport. */ + /** + * The expiry date of the passport. + */ expiryDate: DateField; - /** The gender of the passport holder. */ + /** + * The gender of the passport holder. + */ gender: StringField; - /** The given name(s) of the passport holder. */ + /** + * The given name(s) of the passport holder. + */ givenNames: StringField[] = []; - /** The passport's identification number. */ + /** + * The passport's identification number. + */ idNumber: StringField; - /** The date the passport was issued. */ + /** + * The date the passport was issued. + */ issuanceDate: DateField; - /** Machine Readable Zone, first line */ + /** + * Machine Readable Zone, first line + */ mrz1: StringField; - /** Machine Readable Zone, second line */ + /** + * Machine Readable Zone, second line + */ mrz2: StringField; - /** The surname of the passport holder. */ + /** + * The surname of the passport holder. + */ surname: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/receipt/receiptV5.ts b/src/v1/product/receipt/receiptV5.ts index 292ac397d..0335465a5 100644 --- a/src/v1/product/receipt/receiptV5.ts +++ b/src/v1/product/receipt/receiptV5.ts @@ -5,13 +5,21 @@ import { ReceiptV5Document } from "./receiptV5Document.js"; * Receipt API version 5 inference prediction. */ export class ReceiptV5 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "expense_receipts"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "5"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: ReceiptV5Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/receipt/receiptV5Document.ts b/src/v1/product/receipt/receiptV5Document.ts index cf25b2ba2..a1ab8077b 100644 --- a/src/v1/product/receipt/receiptV5Document.ts +++ b/src/v1/product/receipt/receiptV5Document.ts @@ -18,39 +18,73 @@ import { * Receipt API version 5.4 document data. */ export class ReceiptV5Document implements Prediction { - /** The purchase category of the receipt. */ + /** + * The purchase category of the receipt. + */ category: ClassificationField; - /** The date the purchase was made. */ + /** + * The date the purchase was made. + */ date: DateField; - /** The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT. */ + /** + * The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT. + */ documentType: ClassificationField; - /** List of all line items on the receipt. */ + /** + * List of all line items on the receipt. + */ lineItems: ReceiptV5LineItem[] = []; - /** The locale of the document. */ + /** + * The locale of the document. + */ locale: LocaleField; - /** The receipt number or identifier. */ + /** + * The receipt number or identifier. + */ receiptNumber: StringField; - /** The purchase subcategory of the receipt for transport and food. */ + /** + * The purchase subcategory of the receipt for transport and food. + */ subcategory: ClassificationField; - /** The address of the supplier or merchant. */ + /** + * The address of the supplier or merchant. + */ supplierAddress: StringField; - /** List of company registration numbers associated to the supplier. */ + /** + * List of company registration numbers associated to the supplier. + */ supplierCompanyRegistrations: CompanyRegistrationField[] = []; - /** The name of the supplier or merchant. */ + /** + * The name of the supplier or merchant. + */ supplierName: StringField; - /** The phone number of the supplier or merchant. */ + /** + * The phone number of the supplier or merchant. + */ supplierPhoneNumber: StringField; - /** The list of taxes present on the receipt. */ + /** + * The list of taxes present on the receipt. + */ taxes: Taxes; - /** The time the purchase was made. */ + /** + * The time the purchase was made. + */ time: StringField; - /** The total amount of tip and gratuity. */ + /** + * The total amount of tip and gratuity. + */ tip: AmountField; - /** The total amount paid: includes taxes, discounts, fees, tips, and gratuity. */ + /** + * The total amount paid: includes taxes, discounts, fees, tips, and gratuity. + */ totalAmount: AmountField; - /** The net amount paid: does not include taxes, fees, and discounts. */ + /** + * The net amount paid: does not include taxes, fees, and discounts. + */ totalNet: AmountField; - /** The sum of all taxes. */ + /** + * The sum of all taxes. + */ totalTax: AmountField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/receipt/receiptV5LineItem.ts b/src/v1/product/receipt/receiptV5LineItem.ts index 7cf094d57..826d99d87 100644 --- a/src/v1/product/receipt/receiptV5LineItem.ts +++ b/src/v1/product/receipt/receiptV5LineItem.ts @@ -6,17 +6,29 @@ import { Polygon } from "@/geometry/index.js"; * List of all line items on the receipt. */ export class ReceiptV5LineItem { - /** The item description. */ + /** + * The item description. + */ description: string | null; - /** The item quantity. */ + /** + * The item quantity. + */ quantity: number | null; - /** The item total amount. */ + /** + * The item total amount. + */ totalAmount: number | null; - /** The item unit price. */ + /** + * The item unit price. + */ unitPrice: number | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/resume/resumeV1.ts b/src/v1/product/resume/resumeV1.ts index 231b3de1a..4b41ee9d5 100644 --- a/src/v1/product/resume/resumeV1.ts +++ b/src/v1/product/resume/resumeV1.ts @@ -5,13 +5,21 @@ import { ResumeV1Document } from "./resumeV1Document.js"; * Resume API version 1 inference prediction. */ export class ResumeV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "resume"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: ResumeV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/resume/resumeV1Certificate.ts b/src/v1/product/resume/resumeV1Certificate.ts index 52ff5cb98..4bb349887 100644 --- a/src/v1/product/resume/resumeV1Certificate.ts +++ b/src/v1/product/resume/resumeV1Certificate.ts @@ -6,17 +6,29 @@ import { Polygon } from "@/geometry/index.js"; * The list of certificates obtained by the candidate. */ export class ResumeV1Certificate { - /** The grade obtained for the certificate. */ + /** + * The grade obtained for the certificate. + */ grade: string | null; - /** The name of certification. */ + /** + * The name of certification. + */ name: string | null; - /** The organization or institution that issued the certificate. */ + /** + * The organization or institution that issued the certificate. + */ provider: string | null; - /** The year when a certificate was issued or received. */ + /** + * The year when a certificate was issued or received. + */ year: string | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/resume/resumeV1Document.ts b/src/v1/product/resume/resumeV1Document.ts index 5d87befa1..11ccb42f8 100644 --- a/src/v1/product/resume/resumeV1Document.ts +++ b/src/v1/product/resume/resumeV1Document.ts @@ -14,39 +14,73 @@ import { ClassificationField, StringField } from "@/v1/parsing/standard/index.js * Resume API version 1.2 document data. */ export class ResumeV1Document implements Prediction { - /** The location information of the candidate, including city, state, and country. */ + /** + * The location information of the candidate, including city, state, and country. + */ address: StringField; - /** The list of certificates obtained by the candidate. */ + /** + * The list of certificates obtained by the candidate. + */ certificates: ResumeV1Certificate[] = []; - /** The ISO 639 code of the language in which the document is written. */ + /** + * The ISO 639 code of the language in which the document is written. + */ documentLanguage: StringField; - /** The type of the document sent. */ + /** + * The type of the document sent. + */ documentType: ClassificationField; - /** The list of the candidate's educational background. */ + /** + * The list of the candidate's educational background. + */ education: ResumeV1Education[] = []; - /** The email address of the candidate. */ + /** + * The email address of the candidate. + */ emailAddress: StringField; - /** The candidate's first or given names. */ + /** + * The candidate's first or given names. + */ givenNames: StringField[] = []; - /** The list of the candidate's technical abilities and knowledge. */ + /** + * The list of the candidate's technical abilities and knowledge. + */ hardSkills: StringField[] = []; - /** The position that the candidate is applying for. */ + /** + * The position that the candidate is applying for. + */ jobApplied: StringField; - /** The list of languages that the candidate is proficient in. */ + /** + * The list of languages that the candidate is proficient in. + */ languages: ResumeV1Language[] = []; - /** The ISO 3166 code for the country of citizenship of the candidate. */ + /** + * The ISO 3166 code for the country of citizenship of the candidate. + */ nationality: StringField; - /** The phone number of the candidate. */ + /** + * The phone number of the candidate. + */ phoneNumber: StringField; - /** The candidate's current profession. */ + /** + * The candidate's current profession. + */ profession: StringField; - /** The list of the candidate's professional experiences. */ + /** + * The list of the candidate's professional experiences. + */ professionalExperiences: ResumeV1ProfessionalExperience[] = []; - /** The list of social network profiles of the candidate. */ + /** + * The list of social network profiles of the candidate. + */ socialNetworksUrls: ResumeV1SocialNetworksUrl[] = []; - /** The list of the candidate's interpersonal and communication abilities. */ + /** + * The list of the candidate's interpersonal and communication abilities. + */ softSkills: StringField[] = []; - /** The candidate's last names. */ + /** + * The candidate's last names. + */ surnames: StringField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/resume/resumeV1Education.ts b/src/v1/product/resume/resumeV1Education.ts index 4c3b9aed6..32b4fd427 100644 --- a/src/v1/product/resume/resumeV1Education.ts +++ b/src/v1/product/resume/resumeV1Education.ts @@ -7,23 +7,41 @@ import { Polygon } from "@/geometry/index.js"; * The list of the candidate's educational background. */ export class ResumeV1Education { - /** The area of study or specialization. */ + /** + * The area of study or specialization. + */ degreeDomain: string | null; - /** The type of degree obtained, such as Bachelor's, Master's, or Doctorate. */ + /** + * The type of degree obtained, such as Bachelor's, Master's, or Doctorate. + */ degreeType: string | null; - /** The month when the education program or course was completed. */ + /** + * The month when the education program or course was completed. + */ endMonth: string | null; - /** The year when the education program or course was completed. */ + /** + * The year when the education program or course was completed. + */ endYear: string | null; - /** The name of the school. */ + /** + * The name of the school. + */ school: string | null; - /** The month when the education program or course began. */ + /** + * The month when the education program or course began. + */ startMonth: string | null; - /** The year when the education program or course began. */ + /** + * The year when the education program or course began. + */ startYear: string | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/resume/resumeV1Language.ts b/src/v1/product/resume/resumeV1Language.ts index 70389077b..fe8c3bba0 100644 --- a/src/v1/product/resume/resumeV1Language.ts +++ b/src/v1/product/resume/resumeV1Language.ts @@ -7,13 +7,21 @@ import { Polygon } from "@/geometry/index.js"; * The list of languages that the candidate is proficient in. */ export class ResumeV1Language { - /** The language's ISO 639 code. */ + /** + * The language's ISO 639 code. + */ language: string | null; - /** The candidate's level for the language. */ + /** + * The candidate's level for the language. + */ level: string | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/resume/resumeV1ProfessionalExperience.ts b/src/v1/product/resume/resumeV1ProfessionalExperience.ts index 847f99d84..c7ace17c5 100644 --- a/src/v1/product/resume/resumeV1ProfessionalExperience.ts +++ b/src/v1/product/resume/resumeV1ProfessionalExperience.ts @@ -7,27 +7,49 @@ import { Polygon } from "@/geometry/index.js"; * The list of the candidate's professional experiences. */ export class ResumeV1ProfessionalExperience { - /** The type of contract for the professional experience. */ + /** + * The type of contract for the professional experience. + */ contractType: string | null; - /** The specific department or division within the company. */ + /** + * The specific department or division within the company. + */ department: string | null; - /** The description of the professional experience as written in the document. */ + /** + * The description of the professional experience as written in the document. + */ description: string | null; - /** The name of the company or organization. */ + /** + * The name of the company or organization. + */ employer: string | null; - /** The month when the professional experience ended. */ + /** + * The month when the professional experience ended. + */ endMonth: string | null; - /** The year when the professional experience ended. */ + /** + * The year when the professional experience ended. + */ endYear: string | null; - /** The position or job title held by the candidate. */ + /** + * The position or job title held by the candidate. + */ role: string | null; - /** The month when the professional experience began. */ + /** + * The month when the professional experience began. + */ startMonth: string | null; - /** The year when the professional experience began. */ + /** + * The year when the professional experience began. + */ startYear: string | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/resume/resumeV1SocialNetworksUrl.ts b/src/v1/product/resume/resumeV1SocialNetworksUrl.ts index 9887634fa..b6c071bac 100644 --- a/src/v1/product/resume/resumeV1SocialNetworksUrl.ts +++ b/src/v1/product/resume/resumeV1SocialNetworksUrl.ts @@ -7,13 +7,21 @@ import { Polygon } from "@/geometry/index.js"; * The list of social network profiles of the candidate. */ export class ResumeV1SocialNetworksUrl { - /** The name of the social network. */ + /** + * The name of the social network. + */ name: string | null; - /** The URL of the social network. */ + /** + * The URL of the social network. + */ url: string | null; - /** Confidence score */ + /** + * Confidence score + */ confidence: number = 0.0; - /** The document page on which the information was found. */ + /** + * The document page on which the information was found. + */ pageId: number; /** * Contains the relative vertices coordinates (points) of a polygon containing diff --git a/src/v1/product/us/bankCheck/bankCheckV1.ts b/src/v1/product/us/bankCheck/bankCheckV1.ts index 4d8b2c9d8..4e26babef 100644 --- a/src/v1/product/us/bankCheck/bankCheckV1.ts +++ b/src/v1/product/us/bankCheck/bankCheckV1.ts @@ -6,13 +6,21 @@ import { BankCheckV1Page } from "./bankCheckV1Page.js"; * Bank Check API version 1 inference prediction. */ export class BankCheckV1 extends Inference { - /** The endpoint's name. */ + /** + * The endpoint's name. + */ endpointName = "bank_check"; - /** The endpoint's version. */ + /** + * The endpoint's version. + */ endpointVersion = "1"; - /** The document-level prediction. */ + /** + * The document-level prediction. + */ prediction: BankCheckV1Document; - /** The document's pages. */ + /** + * The document's pages. + */ pages: Page[] = []; constructor(rawPrediction: StringDict) { diff --git a/src/v1/product/us/bankCheck/bankCheckV1Document.ts b/src/v1/product/us/bankCheck/bankCheckV1Document.ts index 07176bc85..e35665412 100644 --- a/src/v1/product/us/bankCheck/bankCheckV1Document.ts +++ b/src/v1/product/us/bankCheck/bankCheckV1Document.ts @@ -13,17 +13,29 @@ import { * Bank Check API version 1.1 document data. */ export class BankCheckV1Document implements Prediction { - /** The check payer's account number. */ + /** + * The check payer's account number. + */ accountNumber: StringField; - /** The amount of the check. */ + /** + * The amount of the check. + */ amount: AmountField; - /** The issuer's check number. */ + /** + * The issuer's check number. + */ checkNumber: StringField; - /** The date the check was issued. */ + /** + * The date the check was issued. + */ date: DateField; - /** List of the check's payees (recipients). */ + /** + * List of the check's payees (recipients). + */ payees: StringField[] = []; - /** The check issuer's routing number. */ + /** + * The check issuer's routing number. + */ routingNumber: StringField; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v1/product/us/bankCheck/bankCheckV1Page.ts b/src/v1/product/us/bankCheck/bankCheckV1Page.ts index 52ef31ef7..359d7e2ab 100644 --- a/src/v1/product/us/bankCheck/bankCheckV1Page.ts +++ b/src/v1/product/us/bankCheck/bankCheckV1Page.ts @@ -6,9 +6,13 @@ import { BankCheckV1Document } from "./bankCheckV1Document.js"; * Bank Check API version 1.1 page data. */ export class BankCheckV1Page extends BankCheckV1Document { - /** The position of the check on the document. */ + /** + * The position of the check on the document. + */ checkPosition: PositionField; - /** List of signature positions */ + /** + * List of signature positions + */ signaturesPositions: PositionField[] = []; constructor(rawPrediction: StringDict, pageId?: number) { diff --git a/src/v2/client.ts b/src/v2/client.ts index 97a7486a4..6db22e610 100644 --- a/src/v2/client.ts +++ b/src/v2/client.ts @@ -25,11 +25,17 @@ import { LocalInputSource } from "@/input/index.js"; * }); */ export interface ClientOptions { - /** Your API key for all endpoints. */ + /** + * Your API key for all endpoints. + */ apiKey?: string; - /** Log debug messages. */ + /** + * Log debug messages. + */ debug?: boolean; - /** Custom Dispatcher instance for the HTTP requests. */ + /** + * Custom Dispatcher instance for the HTTP requests. + */ dispatcher?: Dispatcher; } diff --git a/src/v2/clientOptions/pollingOptions.ts b/src/v2/clientOptions/pollingOptions.ts index c374dcafe..b7ce157c7 100644 --- a/src/v2/clientOptions/pollingOptions.ts +++ b/src/v2/clientOptions/pollingOptions.ts @@ -1,11 +1,17 @@ import { MindeeConfigurationError } from "@/errors/index.js"; import { logger } from "@/logger.js"; -/** Optional timer settings used by polling delays. */ +/** + * Optional timer settings used by polling delays. + */ export interface TimerOptions { - /** Whether the timer should keep the event loop active. */ + /** + * Whether the timer should keep the event loop active. + */ ref?: boolean, - /** Optional signal used to abort timer waits. */ + /** + * Optional signal used to abort timer waits. + */ signal?: AbortSignal } @@ -52,15 +58,25 @@ const minRetries = 2; * ``` */ export class PollingOptions { - /** Number of seconds to wait *before the first poll*. */ + /** + * Number of seconds to wait *before the first poll*. + */ initialDelaySec: number; - /** Interval in seconds between two consecutive polls. */ + /** + * Interval in seconds between two consecutive polls. + */ delaySec: number; - /** Maximum number of polling attempts (including the first one). */ + /** + * Maximum number of polling attempts (including the first one). + */ maxRetries: number; - /** Options passed to the initial `setTimeout()`. */ + /** + * Options passed to the initial `setTimeout()`. + */ initialTimerOptions?: TimerOptions; - /** Options passed to every recurring `setTimeout()`. */ + /** + * Options passed to every recurring `setTimeout()`. + */ recurringTimerOptions?: TimerOptions; constructor(params?: PollingOptionsConstructor) { @@ -92,7 +108,9 @@ export class PollingOptions { logger.debug(`Polling options initialized: ${this.toString()}`); } - /** Validates polling options against minimum accepted values. */ + /** + * Validates polling options against minimum accepted values. + */ validateSettings() { if (this.delaySec < minDelaySec) { throw new MindeeConfigurationError( @@ -111,7 +129,9 @@ export class PollingOptions { } } - /** Returns a compact string representation of the polling options. */ + /** + * Returns a compact string representation of the polling options. + */ toString(): string { return `{ initialDelaySec: ${this.initialDelaySec}, delaySec: ${this.delaySec}, maxRetries: ${this.maxRetries} }`; } diff --git a/src/v2/parsing/error/errorDetails.ts b/src/v2/parsing/error/errorDetails.ts index 55e04aeef..b9f994cfd 100644 --- a/src/v2/parsing/error/errorDetails.ts +++ b/src/v2/parsing/error/errorDetails.ts @@ -1,6 +1,8 @@ import { ErrorItem } from "./errorItem.js"; -/** Structured error payload returned by v2 APIs. */ +/** + * Structured error payload returned by v2 APIs. + */ export interface ErrorDetails { /** * The HTTP status code returned by the server. diff --git a/src/v2/parsing/inference/baseInference.ts b/src/v2/parsing/inference/baseInference.ts index 8be4c6f56..276bbd57d 100644 --- a/src/v2/parsing/inference/baseInference.ts +++ b/src/v2/parsing/inference/baseInference.ts @@ -3,7 +3,9 @@ import { InferenceModel } from "./inferenceModel.js"; import { InferenceFile } from "./inferenceFile.js"; import { InferenceJob } from "./inferenceJob.js"; -/** Shared metadata container for v2 inference payloads. */ +/** + * Shared metadata container for v2 inference payloads. + */ export abstract class BaseInference { /** * Model info for the inference. @@ -29,7 +31,9 @@ export abstract class BaseInference { this.file = new InferenceFile(serverResponse["file"]); } - /** Returns a printable representation of inference metadata. */ + /** + * Returns a printable representation of inference metadata. + */ toString(): string { return ( "Inference\n" + diff --git a/src/v2/parsing/inference/field/baseField.ts b/src/v2/parsing/inference/field/baseField.ts index 09814931e..4254d63ec 100644 --- a/src/v2/parsing/inference/field/baseField.ts +++ b/src/v2/parsing/inference/field/baseField.ts @@ -3,11 +3,17 @@ import { StringDict } from "@/parsing/stringDict.js"; import { FieldLocation } from "./fieldLocation.js"; export abstract class BaseField { - /** Indentation level used when rendering field text output. */ + /** + * Indentation level used when rendering field text output. + */ protected _indentLevel: number; - /** Confidence level associated with this field. */ + /** + * Confidence level associated with this field. + */ public confidence: FieldConfidence | undefined; - /** Optional list of source locations for this field. */ + /** + * Optional list of source locations for this field. + */ public locations: Array | undefined; protected constructor(rawResponse: StringDict, indentLevel = 0) { diff --git a/src/v2/parsing/inference/field/fieldConfidence.ts b/src/v2/parsing/inference/field/fieldConfidence.ts index 4b92105e0..904869775 100644 --- a/src/v2/parsing/inference/field/fieldConfidence.ts +++ b/src/v2/parsing/inference/field/fieldConfidence.ts @@ -4,13 +4,21 @@ * Confidence level of a field as returned by the V2 API. */ export enum FieldConfidence { - /** Maximum confidence level. */ + /** + * Maximum confidence level. + */ Certain = "Certain", - /** High confidence level. */ + /** + * High confidence level. + */ High = "High", - /** Medium confidence level. */ + /** + * Medium confidence level. + */ Medium = "Medium", - /** Low confidence level. */ + /** + * Low confidence level. + */ Low = "Low", } diff --git a/src/v2/parsing/inference/field/fieldLocation.ts b/src/v2/parsing/inference/field/fieldLocation.ts index 2346ae234..1640a34e6 100644 --- a/src/v2/parsing/inference/field/fieldLocation.ts +++ b/src/v2/parsing/inference/field/fieldLocation.ts @@ -5,9 +5,13 @@ import { StringDict } from "@/parsing/stringDict.js"; * A field's location on the document. */ export class FieldLocation { - /** Position information as a list of points in clockwise order. */ + /** + * Position information as a list of points in clockwise order. + */ readonly polygon: Polygon; - /** 0-based page index of where the polygon is located. */ + /** + * 0-based page index of where the polygon is located. + */ readonly page; constructor(serverResponse: StringDict) { @@ -15,7 +19,9 @@ export class FieldLocation { this.page = serverResponse["page"]; } - /** Returns a readable location string. */ + /** + * Returns a readable location string. + */ toString(): string { return `${this.polygon} on page ${this.page}`; } diff --git a/src/v2/parsing/inference/field/inferenceFields.ts b/src/v2/parsing/inference/field/inferenceFields.ts index 8013e7af7..3a186d383 100644 --- a/src/v2/parsing/inference/field/inferenceFields.ts +++ b/src/v2/parsing/inference/field/inferenceFields.ts @@ -5,9 +5,13 @@ import type { SimpleField } from "./simpleField.js"; import { createField } from "./fieldFactory.js"; -/** Typed map of extraction fields returned by the API. */ +/** + * Typed map of extraction fields returned by the API. + */ export class InferenceFields extends Map { - /** Indentation level used when rendering text output. */ + /** + * Indentation level used when rendering text output. + */ protected _indentLevel: number; constructor(serverResponse: StringDict, indentLevel = 0) { diff --git a/src/v2/parsing/inference/field/listField.ts b/src/v2/parsing/inference/field/listField.ts index 800a6d816..036eed8a2 100644 --- a/src/v2/parsing/inference/field/listField.ts +++ b/src/v2/parsing/inference/field/listField.ts @@ -5,7 +5,9 @@ import { ObjectField } from "./objectField.js"; import { SimpleField } from "./simpleField.js"; import { createField } from "./fieldFactory.js"; -/** List-valued inference field. */ +/** + * List-valued inference field. + */ export class ListField extends BaseField { /** * Items contained in the list. @@ -61,7 +63,9 @@ export class ListField extends BaseField { return result; } - /** Returns a readable representation of list items. */ + /** + * Returns a readable representation of list items. + */ toString(): string { if (!this.items || this.items.length === 0) { return "\n"; diff --git a/src/v2/parsing/inference/field/objectField.ts b/src/v2/parsing/inference/field/objectField.ts index 04cc954ba..2cb60e6ec 100644 --- a/src/v2/parsing/inference/field/objectField.ts +++ b/src/v2/parsing/inference/field/objectField.ts @@ -4,9 +4,13 @@ import { BaseField } from "./baseField.js"; import type { SimpleField } from "./simpleField.js"; import type { ListField } from "./listField.js"; -/** Object-valued inference field. */ +/** + * Object-valued inference field. + */ export class ObjectField extends BaseField { - /** Nested fields carried by this object. */ + /** + * Nested fields carried by this object. + */ readonly fields: InferenceFields; constructor(serverResponse: StringDict, indentLevel = 0) { diff --git a/src/v2/parsing/inference/field/ragMetadata.ts b/src/v2/parsing/inference/field/ragMetadata.ts index 0940476ed..650304d4d 100644 --- a/src/v2/parsing/inference/field/ragMetadata.ts +++ b/src/v2/parsing/inference/field/ragMetadata.ts @@ -1,6 +1,8 @@ import { StringDict } from "@/parsing/stringDict.js"; -/** Metadata about the RAG operation. */ +/** + * Metadata about the RAG operation. + */ export class RagMetadata { /** * The UUID of the matched document used during the RAG operation. diff --git a/src/v2/parsing/inference/field/rawText.ts b/src/v2/parsing/inference/field/rawText.ts index c17b84e79..c38b14730 100644 --- a/src/v2/parsing/inference/field/rawText.ts +++ b/src/v2/parsing/inference/field/rawText.ts @@ -1,7 +1,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { RawTextPage } from "./rawTextPage.js"; -/** Full raw OCR text grouped by page. */ +/** + * Full raw OCR text grouped by page. + */ export class RawText { /** * List of pages with their extracted text content. @@ -14,7 +16,9 @@ export class RawText { ) : []; } - /** Returns concatenated raw text for all pages. */ + /** + * Returns concatenated raw text for all pages. + */ toString(): string { return this.pages.map(page => page.toString()).join("\n\n"); } diff --git a/src/v2/parsing/inference/field/simpleField.ts b/src/v2/parsing/inference/field/simpleField.ts index 38ec2e8bb..6c8db9d11 100644 --- a/src/v2/parsing/inference/field/simpleField.ts +++ b/src/v2/parsing/inference/field/simpleField.ts @@ -51,7 +51,9 @@ export class SimpleField extends BaseField { return this.value as boolean; } - /** Returns a readable scalar representation. */ + /** + * Returns a readable scalar representation. + */ toString(): string { if (this.value === null) { return ""; diff --git a/src/v2/parsing/inference/inferenceFile.ts b/src/v2/parsing/inference/inferenceFile.ts index 6efbee89e..0fe1b6dc8 100644 --- a/src/v2/parsing/inference/inferenceFile.ts +++ b/src/v2/parsing/inference/inferenceFile.ts @@ -1,6 +1,8 @@ import { StringDict } from "@/parsing/stringDict.js"; -/** File metadata attached to a v2 inference. */ +/** + * File metadata attached to a v2 inference. + */ export class InferenceFile { /** * Name of the file. @@ -26,7 +28,9 @@ export class InferenceFile { this.mimeType = serverResponse["mime_type"]; } - /** Returns a printable representation of file metadata. */ + /** + * Returns a printable representation of file metadata. + */ toString () { return( "File\n" + diff --git a/src/v2/parsing/inference/inferenceModel.ts b/src/v2/parsing/inference/inferenceModel.ts index 0725b9ee1..b61d3fabe 100644 --- a/src/v2/parsing/inference/inferenceModel.ts +++ b/src/v2/parsing/inference/inferenceModel.ts @@ -1,6 +1,8 @@ import { StringDict } from "@/parsing/stringDict.js"; -/** Model metadata attached to a v2 inference. */ +/** + * Model metadata attached to a v2 inference. + */ export class InferenceModel { /** * ID of the model. @@ -11,7 +13,9 @@ export class InferenceModel { this.id = serverResponse["id"]; } - /** Returns a printable representation of model metadata. */ + /** + * Returns a printable representation of model metadata. + */ toString(): string { return "Model\n" + "=====\n" + diff --git a/src/v2/product/classification/classification.ts b/src/v2/product/classification/classification.ts index a957d1dcf..36e356688 100644 --- a/src/v2/product/classification/classification.ts +++ b/src/v2/product/classification/classification.ts @@ -6,17 +6,23 @@ import { BaseProduct } from "@/v2/product/baseProduct.js"; * Automatically sort any image or scanned document into categories. */ export class Classification extends BaseProduct { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return ClassificationParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return ClassificationResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "classification"; } diff --git a/src/v2/product/classification/classificationClassifier.ts b/src/v2/product/classification/classificationClassifier.ts index 7c5bf2d1b..b93ab80c0 100644 --- a/src/v2/product/classification/classificationClassifier.ts +++ b/src/v2/product/classification/classificationClassifier.ts @@ -4,7 +4,9 @@ import { ExtractionResponse } from "@/v2/product/index.js"; /** * Document level classification. */ -/** Classifier output for document-level classification. */ +/** + * Classifier output for document-level classification. + */ export class ClassificationClassifier { /** * The document type, as identified on given classification values. @@ -22,7 +24,9 @@ export class ClassificationClassifier { : undefined; } - /** Returns a readable classifier summary. */ + /** + * Returns a readable classifier summary. + */ toString(): string { return `Document Type: ${this.documentType}`; } diff --git a/src/v2/product/classification/classificationInference.ts b/src/v2/product/classification/classificationInference.ts index f42fc4891..529addcd9 100644 --- a/src/v2/product/classification/classificationInference.ts +++ b/src/v2/product/classification/classificationInference.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/index.js"; import { BaseInference } from "@/v2/parsing/inference/baseInference.js"; import { ClassificationResult } from "./classificationResult.js"; -/** Inference payload for classification responses. */ +/** + * Inference payload for classification responses. + */ export class ClassificationInference extends BaseInference { /** * Result of a classification inference. @@ -14,7 +16,9 @@ export class ClassificationInference extends BaseInference { this.result = new ClassificationResult(serverResponse["result"]); } - /** Returns a readable representation of the inference. */ + /** + * Returns a readable representation of the inference. + */ toString(): string { return ( super.toString() + diff --git a/src/v2/product/classification/classificationResponse.ts b/src/v2/product/classification/classificationResponse.ts index 1c41b550f..ca8ec485c 100644 --- a/src/v2/product/classification/classificationResponse.ts +++ b/src/v2/product/classification/classificationResponse.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { ClassificationInference } from "./classificationInference.js"; import { BaseResponse } from "@/v2/parsing/index.js"; -/** Response wrapper for classification product calls. */ +/** + * Response wrapper for classification product calls. + */ export class ClassificationResponse extends BaseResponse { /** * The inference result for a classification utility request. diff --git a/src/v2/product/classification/classificationResult.ts b/src/v2/product/classification/classificationResult.ts index 26678a1ed..8bb810c53 100644 --- a/src/v2/product/classification/classificationResult.ts +++ b/src/v2/product/classification/classificationResult.ts @@ -1,7 +1,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { ClassificationClassifier } from "./classificationClassifier.js"; -/** Classification section of a classification inference result. */ +/** + * Classification section of a classification inference result. + */ export class ClassificationResult { /** * Fields contained in the inference. @@ -12,7 +14,9 @@ export class ClassificationResult { this.classification = new ClassificationClassifier(serverResponse["classification"]); } - /** Returns a readable classification summary. */ + /** + * Returns a readable classification summary. + */ toString(): string { return `Classification\n==============\n${this.classification}`; } diff --git a/src/v2/product/crop/crop.ts b/src/v2/product/crop/crop.ts index 12681b133..b3145269b 100644 --- a/src/v2/product/crop/crop.ts +++ b/src/v2/product/crop/crop.ts @@ -6,17 +6,23 @@ import { BaseProduct } from "@/v2/product/baseProduct.js"; * Identify the borders of documents on each page, matching each one to a category. */ export class Crop extends BaseProduct { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return CropParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return CropResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "crop"; } diff --git a/src/v2/product/crop/cropInference.ts b/src/v2/product/crop/cropInference.ts index d243f0bc5..de2552464 100644 --- a/src/v2/product/crop/cropInference.ts +++ b/src/v2/product/crop/cropInference.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/index.js"; import { BaseInference } from "@/v2/parsing/inference/baseInference.js"; import { CropResult } from "@/v2/product/crop/cropResult.js"; -/** Inference payload for crop responses. */ +/** + * Inference payload for crop responses. + */ export class CropInference extends BaseInference { /** * Result of a crop utility inference. @@ -14,7 +16,9 @@ export class CropInference extends BaseInference { this.result = new CropResult(serverResponse["result"]); } - /** Returns a readable representation of the inference. */ + /** + * Returns a readable representation of the inference. + */ toString(): string { return ( super.toString() + diff --git a/src/v2/product/crop/cropItem.ts b/src/v2/product/crop/cropItem.ts index cac8b98cd..14b4472c9 100644 --- a/src/v2/product/crop/cropItem.ts +++ b/src/v2/product/crop/cropItem.ts @@ -5,7 +5,9 @@ import { extractSingleCrop } from "@/v2/fileOperations/crop.js"; import { ExtractedImage } from "@/image/index.js"; import { ExtractionResponse } from "@/v2/product/index.js"; -/** Single crop detection returned by the crop product. */ +/** + * Single crop detection returned by the crop product. + */ export class CropItem { /** * Type or classification of the detected object. @@ -28,7 +30,9 @@ export class CropItem { : undefined; } - /** Returns a readable crop item summary. */ + /** + * Returns a readable crop item summary. + */ toString(): string { return `* :Location: ${this.location}\n :Object Type: ${this.objectType}`; } diff --git a/src/v2/product/crop/cropResponse.ts b/src/v2/product/crop/cropResponse.ts index 0e17dba15..5466c4aa9 100644 --- a/src/v2/product/crop/cropResponse.ts +++ b/src/v2/product/crop/cropResponse.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { BaseResponse } from "@/v2/parsing/index.js"; import { CropInference } from "./cropInference.js"; -/** Response wrapper for crop product calls. */ +/** + * Response wrapper for crop product calls. + */ export class CropResponse extends BaseResponse { /** * Response for a crop utility inference. diff --git a/src/v2/product/crop/cropResult.ts b/src/v2/product/crop/cropResult.ts index f8a539814..6bedf3605 100644 --- a/src/v2/product/crop/cropResult.ts +++ b/src/v2/product/crop/cropResult.ts @@ -4,7 +4,9 @@ import { LocalInputSource } from "@/input/index.js"; import { extractMultipleCrops } from "@/v2/fileOperations/crop.js"; import { ExtractedImages } from "@/image/extractedImages.js"; -/** Crop section of a crop inference result. */ +/** + * Crop section of a crop inference result. + */ export class CropResult { /** * Fields contained in the inference. @@ -15,7 +17,9 @@ export class CropResult { this.crops = serverResponse["crops"].map((cropItem: StringDict) => new CropItem(cropItem)); } - /** Returns a readable list of detected crops. */ + /** + * Returns a readable list of detected crops. + */ toString(): string { const crops = this.crops.map(item => item.toString()).join("\n"); return `Crops\n=====\n${crops}`; diff --git a/src/v2/product/extraction/dataSchemaActiveOption.ts b/src/v2/product/extraction/dataSchemaActiveOption.ts index 30e68c56f..94a931e7c 100644 --- a/src/v2/product/extraction/dataSchemaActiveOption.ts +++ b/src/v2/product/extraction/dataSchemaActiveOption.ts @@ -13,7 +13,9 @@ export class DataSchemaActiveOption { this.replace = serverResponse["replace"]; } - /** Returns a readable representation of active data schema options. */ + /** + * Returns a readable representation of active data schema options. + */ toString() { return `Data Schema\n-----------\n:Replace: ${this.replace? "True" : "False"}`; } diff --git a/src/v2/product/extraction/extraction.ts b/src/v2/product/extraction/extraction.ts index 1dcf02812..1911c735e 100644 --- a/src/v2/product/extraction/extraction.ts +++ b/src/v2/product/extraction/extraction.ts @@ -10,32 +10,44 @@ import { RagDocumentAnnotationParameters, RagDocumentUploadParameters } from "./ * Automatically extract structured data from any image or scanned document. */ export class Extraction extends BaseProduct { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "extraction"; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return ExtractionParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return ExtractionResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get annotationResponseClass() { return ExtractionRagAnnotationResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get annotationParametersClass() { return RagDocumentAnnotationParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get ragDocumentUploadClass() { return RagDocumentUploadParameters; } diff --git a/src/v2/product/extraction/extractionActiveOptions.ts b/src/v2/product/extraction/extractionActiveOptions.ts index fb076a715..c68725306 100644 --- a/src/v2/product/extraction/extractionActiveOptions.ts +++ b/src/v2/product/extraction/extractionActiveOptions.ts @@ -1,7 +1,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { DataSchemaActiveOption } from "./dataSchemaActiveOption.js"; -/** Active extraction options echoed by the API. */ +/** + * Active extraction options echoed by the API. + */ export class ExtractionActiveOptions { /** * Whether the RAG feature was activated. @@ -39,7 +41,9 @@ export class ExtractionActiveOptions { this.dataSchema = new DataSchemaActiveOption(serverResponse["data_schema"]); } - /** Returns a readable representation of active options. */ + /** + * Returns a readable representation of active options. + */ toString(): string { return "Active Options\n" + "==============\n" + diff --git a/src/v2/product/extraction/extractionInference.ts b/src/v2/product/extraction/extractionInference.ts index 018ad0525..3cf8af7c4 100644 --- a/src/v2/product/extraction/extractionInference.ts +++ b/src/v2/product/extraction/extractionInference.ts @@ -3,7 +3,9 @@ import { ExtractionResult } from "./extractionResult.js"; import { ExtractionActiveOptions } from "./extractionActiveOptions.js"; import { BaseInference } from "@/v2/parsing/inference/baseInference.js"; -/** Inference payload for extraction responses. */ +/** + * Inference payload for extraction responses. + */ export class ExtractionInference extends BaseInference { /** * Result of the inference. @@ -20,7 +22,9 @@ export class ExtractionInference extends BaseInference { this.activeOptions = new ExtractionActiveOptions(serverResponse["active_options"]); } - /** Returns a readable representation of the inference. */ + /** + * Returns a readable representation of the inference. + */ toString(): string { return ( super.toString() + diff --git a/src/v2/product/extraction/extractionResponse.ts b/src/v2/product/extraction/extractionResponse.ts index d67e8c53c..7aa5288c3 100644 --- a/src/v2/product/extraction/extractionResponse.ts +++ b/src/v2/product/extraction/extractionResponse.ts @@ -2,7 +2,9 @@ import { ExtractionInference } from "./extractionInference.js"; import { StringDict } from "@/parsing/stringDict.js"; import { BaseResponse } from "@/v2/parsing/index.js"; -/** Response wrapper for extraction product calls. */ +/** + * Response wrapper for extraction product calls. + */ export class ExtractionResponse extends BaseResponse { /** * The inference result for an extraction request. diff --git a/src/v2/product/extraction/extractionResult.ts b/src/v2/product/extraction/extractionResult.ts index 8f4dea36d..1eefe1a2a 100644 --- a/src/v2/product/extraction/extractionResult.ts +++ b/src/v2/product/extraction/extractionResult.ts @@ -3,7 +3,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { RawText } from "@/v2/parsing/inference/field/rawText.js"; import { RagMetadata } from "@/v2/parsing/inference/field/ragMetadata.js"; -/** Extraction result payload containing fields and optional extras. */ +/** + * Extraction result payload containing fields and optional extras. + */ export class ExtractionResult { /** * Fields contained in the inference. @@ -30,7 +32,9 @@ export class ExtractionResult { } } - /** Returns a readable representation of extracted fields. */ + /** + * Returns a readable representation of extracted fields. + */ toString(): string { return `Fields\n======\n${this.fields}`; } diff --git a/src/v2/product/extraction/params/dataSchema.ts b/src/v2/product/extraction/params/dataSchema.ts index 88f9f49e1..4fb1bb2d9 100644 --- a/src/v2/product/extraction/params/dataSchema.ts +++ b/src/v2/product/extraction/params/dataSchema.ts @@ -1,9 +1,13 @@ import { StringDict } from "@/parsing/stringDict.js"; import { DataSchemaReplace, DataSchemaReplaceJson } from "./dataSchemaReplace.js"; -/** JSON payload for top-level data schema options. */ +/** + * JSON payload for top-level data schema options. + */ export interface DataSchemaJson { - /** Optional full replacement schema. */ + /** + * Optional full replacement schema. + */ replace?: DataSchemaReplaceJson; } @@ -26,11 +30,15 @@ export class DataSchema { } } - /** Serializes the data schema parameters to API format. */ + /** + * Serializes the data schema parameters to API format. + */ toJSON(): DataSchemaJson { return { replace: this.replace?.toJSON() }; } - /** Returns a JSON string representation of the data schema parameters. */ + /** + * Returns a JSON string representation of the data schema parameters. + */ toString() { return JSON.stringify(this.toJSON()); } diff --git a/src/v2/product/extraction/params/dataSchemaField.ts b/src/v2/product/extraction/params/dataSchemaField.ts index 922f56058..cf6e12435 100644 --- a/src/v2/product/extraction/params/dataSchemaField.ts +++ b/src/v2/product/extraction/params/dataSchemaField.ts @@ -1,32 +1,54 @@ import { StringDict } from "@/parsing/index.js"; -/** JSON payload for a single data schema field definition. */ +/** + * JSON payload for a single data schema field definition. + */ export interface DataSchemaFieldJson { - /** Field key used in results. */ + /** + * Field key used in results. + */ name: string; - /** Human-readable field title. */ + /** + * Human-readable field title. + */ title: string; - /** Whether the field accepts multiple values. */ + /** + * Whether the field accepts multiple values. + */ // eslint-disable-next-line @typescript-eslint/naming-convention is_array: boolean; - /** Field type name. */ + /** + * Field type name. + */ type: string; - /** Optional allowed classes for classification fields. */ + /** + * Optional allowed classes for classification fields. + */ // eslint-disable-next-line @typescript-eslint/naming-convention classification_values?: Array; - /** Optional deduplication behavior for array fields. */ + /** + * Optional deduplication behavior for array fields. + */ // eslint-disable-next-line @typescript-eslint/naming-convention unique_values?: boolean; - /** Optional field description. */ + /** + * Optional field description. + */ description?: string; - /** Optional extraction guidelines. */ + /** + * Optional extraction guidelines. + */ guidelines?: string; - /** Optional nested schema for object fields. */ + /** + * Optional nested schema for object fields. + */ // eslint-disable-next-line @typescript-eslint/naming-convention nested_fields?: StringDict; } -/** Data schema field definition used by extraction parameters. */ +/** + * Data schema field definition used by extraction parameters. + */ export class DataSchemaField { /** * Display name for the field, also impacts inference results. @@ -78,7 +100,9 @@ export class DataSchemaField { this.nestedFields = fields["nested_fields"]; } - /** Serializes the field definition to API format. */ + /** + * Serializes the field definition to API format. + */ toJSON(): DataSchemaFieldJson { const out: DataSchemaFieldJson = { name: this.name, @@ -100,7 +124,9 @@ export class DataSchemaField { return out; } - /** Returns a JSON string representation of the field definition. */ + /** + * Returns a JSON string representation of the field definition. + */ toString() { return JSON.stringify(this.toJSON()); } diff --git a/src/v2/product/extraction/params/dataSchemaReplace.ts b/src/v2/product/extraction/params/dataSchemaReplace.ts index 836ef5be5..08675ec44 100644 --- a/src/v2/product/extraction/params/dataSchemaReplace.ts +++ b/src/v2/product/extraction/params/dataSchemaReplace.ts @@ -2,9 +2,13 @@ import { StringDict } from "@/parsing/index.js"; import { DataSchemaField, DataSchemaFieldJson } from "./dataSchemaField.js"; import { MindeeError } from "@/errors/index.js"; -/** JSON payload for replacement data schema options. */ +/** + * JSON payload for replacement data schema options. + */ export interface DataSchemaReplaceJson { - /** Field definitions replacing the current schema. */ + /** + * Field definitions replacing the current schema. + */ fields: Array; } @@ -27,12 +31,16 @@ export class DataSchemaReplace { this.fields = dataSchemaReplace["fields"].map((field: StringDict) => (new DataSchemaField(field))); } - /** Serializes the replacement schema to API format. */ + /** + * Serializes the replacement schema to API format. + */ toJSON(): DataSchemaReplaceJson { return { fields: this.fields.map(e => e.toJSON()) }; } - /** Returns a JSON string representation of the replacement schema. */ + /** + * Returns a JSON string representation of the replacement schema. + */ toString() { return JSON.stringify(this.toJSON()); } diff --git a/src/v2/product/extraction/ragDocuments/annotatedListField.ts b/src/v2/product/extraction/ragDocuments/annotatedListField.ts index 7d8fade51..2501c284d 100644 --- a/src/v2/product/extraction/ragDocuments/annotatedListField.ts +++ b/src/v2/product/extraction/ragDocuments/annotatedListField.ts @@ -63,7 +63,9 @@ export class AnnotatedListField extends AnnotatedBaseField { return result; } - /** Returns a readable representation of list items. */ + /** + * Returns a readable representation of list items. + */ toString(): string { if (!this.items || this.items.length === 0) { return "\n"; diff --git a/src/v2/product/ocr/ocr.ts b/src/v2/product/ocr/ocr.ts index cf2afab8b..6ce43e57c 100644 --- a/src/v2/product/ocr/ocr.ts +++ b/src/v2/product/ocr/ocr.ts @@ -6,17 +6,23 @@ import { BaseProduct } from "@/v2/product/baseProduct.js"; * Extract raw text (OCR) from any image or scanned document. */ export class Ocr extends BaseProduct { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return OcrParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return OcrResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "ocr"; } diff --git a/src/v2/product/ocr/ocrInference.ts b/src/v2/product/ocr/ocrInference.ts index 31097754a..b81ca668d 100644 --- a/src/v2/product/ocr/ocrInference.ts +++ b/src/v2/product/ocr/ocrInference.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/index.js"; import { BaseInference } from "@/v2/parsing/inference/baseInference.js"; import { OcrResult } from "@/v2/product/ocr/ocrResult.js"; -/** Inference payload for OCR responses. */ +/** + * Inference payload for OCR responses. + */ export class OcrInference extends BaseInference { /** * Result of an OCR inference. @@ -14,7 +16,9 @@ export class OcrInference extends BaseInference { this.result = new OcrResult(serverResponse["result"]); } - /** Returns a readable representation of OCR inference output. */ + /** + * Returns a readable representation of OCR inference output. + */ toString(): string { return ( "Inference\n" + diff --git a/src/v2/product/ocr/ocrPage.ts b/src/v2/product/ocr/ocrPage.ts index 91f2808e0..4a225e015 100644 --- a/src/v2/product/ocr/ocrPage.ts +++ b/src/v2/product/ocr/ocrPage.ts @@ -1,7 +1,9 @@ import { OcrWord } from "./ocrWord.js"; import { StringDict } from "@/parsing/index.js"; -/** OCR payload for a single page. */ +/** + * OCR payload for a single page. + */ export class OcrPage { /** * List of words extracted from the document page. @@ -18,7 +20,9 @@ export class OcrPage { this.content = serverResponse["content"] as string; } - /** Returns a readable representation of page OCR content. */ + /** + * Returns a readable representation of page OCR content. + */ toString(): string { let ocrWords = "\n"; if (this.words.length > 0) { diff --git a/src/v2/product/ocr/ocrResponse.ts b/src/v2/product/ocr/ocrResponse.ts index af64dd4ad..127865b62 100644 --- a/src/v2/product/ocr/ocrResponse.ts +++ b/src/v2/product/ocr/ocrResponse.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { OcrInference } from "./ocrInference.js"; import { BaseResponse } from "@/v2/parsing/index.js"; -/** Response wrapper for OCR product calls. */ +/** + * Response wrapper for OCR product calls. + */ export class OcrResponse extends BaseResponse { /** * Response for an OCR utility inference. diff --git a/src/v2/product/ocr/ocrResult.ts b/src/v2/product/ocr/ocrResult.ts index 21a441ea2..cee62ea8b 100644 --- a/src/v2/product/ocr/ocrResult.ts +++ b/src/v2/product/ocr/ocrResult.ts @@ -14,7 +14,9 @@ export class OcrResult { this.pages = serverResponse.pages.map((ocr: any) => new OcrPage(ocr)); } - /** Returns a readable OCR summary for all pages. */ + /** + * Returns a readable OCR summary for all pages. + */ toString(): string { let pages = "\n"; if (this.pages.length > 0) { diff --git a/src/v2/product/ocr/ocrWord.ts b/src/v2/product/ocr/ocrWord.ts index f7c079d6f..90d4c62b1 100644 --- a/src/v2/product/ocr/ocrWord.ts +++ b/src/v2/product/ocr/ocrWord.ts @@ -1,7 +1,9 @@ import { Polygon } from "@/geometry/index.js"; import { StringDict } from "@/parsing/index.js"; -/** OCR word token with geometry. */ +/** + * OCR word token with geometry. + */ export class OcrWord { /** * Text content of the word. @@ -18,7 +20,9 @@ export class OcrWord { this.polygon = new Polygon(...serverResponse["polygon"]); } - /** Returns the OCR token text. */ + /** + * Returns the OCR token text. + */ toString(): string { return this.content; } diff --git a/src/v2/product/split/split.ts b/src/v2/product/split/split.ts index 296cf81ea..532e64662 100644 --- a/src/v2/product/split/split.ts +++ b/src/v2/product/split/split.ts @@ -6,17 +6,23 @@ import { BaseProduct } from "@/v2/product/baseProduct.js"; * Break a multipage source file into separate documents, associating a class for each one. */ export class Split extends BaseProduct { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return SplitParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return SplitResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "split"; } diff --git a/src/v2/product/split/splitInference.ts b/src/v2/product/split/splitInference.ts index ccb1bc89d..9a2a15b4d 100644 --- a/src/v2/product/split/splitInference.ts +++ b/src/v2/product/split/splitInference.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/index.js"; import { BaseInference } from "@/v2/parsing/inference/baseInference.js"; import { SplitResult } from "./splitResult.js"; -/** Inference payload for split responses. */ +/** + * Inference payload for split responses. + */ export class SplitInference extends BaseInference { /** * Result of a split inference. @@ -14,7 +16,9 @@ export class SplitInference extends BaseInference { this.result = new SplitResult(serverResponse["result"]); } - /** Returns a readable representation of the split inference. */ + /** + * Returns a readable representation of the split inference. + */ toString(): string { return ( super.toString() + diff --git a/src/v2/product/split/splitRange.ts b/src/v2/product/split/splitRange.ts index cca9e8ded..d61356139 100644 --- a/src/v2/product/split/splitRange.ts +++ b/src/v2/product/split/splitRange.ts @@ -30,7 +30,9 @@ export class SplitRange { : undefined; } - /** Returns a readable summary of the split range. */ + /** + * Returns a readable summary of the split range. + */ toString(): string { const pageRange = this.pageRange.join(","); return `* :Page Range: ${pageRange}\n :Document Type: ${this.documentType}`; diff --git a/src/v2/product/split/splitResponse.ts b/src/v2/product/split/splitResponse.ts index 3999c05bc..8d5c23dc1 100644 --- a/src/v2/product/split/splitResponse.ts +++ b/src/v2/product/split/splitResponse.ts @@ -2,7 +2,9 @@ import { StringDict } from "@/parsing/stringDict.js"; import { SplitInference } from "./splitInference.js"; import { BaseResponse } from "@/v2/parsing/index.js"; -/** Response wrapper for split product calls. */ +/** + * Response wrapper for split product calls. + */ export class SplitResponse extends BaseResponse { /** * Response for an OCR utility inference. diff --git a/src/v2/product/split/splitResult.ts b/src/v2/product/split/splitResult.ts index ac1aa3f72..d78631eb9 100644 --- a/src/v2/product/split/splitResult.ts +++ b/src/v2/product/split/splitResult.ts @@ -29,7 +29,9 @@ export class SplitResult { return await extractMultipleSplits(inputSource, splits); } - /** Returns a readable list of split ranges. */ + /** + * Returns a readable list of split ranges. + */ toString(): string { let splits = "\n"; if (this.splits.length > 0) { diff --git a/src/v2/search/baseSearch.ts b/src/v2/search/baseSearch.ts index 9b076d81c..908927359 100644 --- a/src/v2/search/baseSearch.ts +++ b/src/v2/search/baseSearch.ts @@ -7,17 +7,23 @@ import { BaseSearchParameters } from "@/v2/clientOptions/index.js"; * Child classes are passed to the Client when making requests. */ export abstract class BaseSearch { - /** Parameter class used for the search query. */ + /** + * Parameter class used for the search query. + */ static get parametersClass(): new (...args: any[]) => BaseSearchParameters { throw new Error("Must define static parametersClass property"); } - /** Response class returned by the search. */ + /** + * Response class returned by the search. + */ static get responseClass(): ResponseConstructor { throw new Error("Must define static response property"); } - /** API slug for the search. */ + /** + * API slug for the search. + */ static get slug(): string { throw new Error("Must define static slug property"); } diff --git a/src/v2/search/models/modelSearch.ts b/src/v2/search/models/modelSearch.ts index 7991de37f..991e2d391 100644 --- a/src/v2/search/models/modelSearch.ts +++ b/src/v2/search/models/modelSearch.ts @@ -11,17 +11,23 @@ import { ModelSearchResponse } from "@/v2/search/models/modelSearchResponse.js"; * Results are paginated. */ export class ModelSearch extends BaseSearch { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return ModelSearchParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return ModelSearchResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "models"; } diff --git a/src/v2/search/models/modelSearchParameters.ts b/src/v2/search/models/modelSearchParameters.ts index 78c78fc47..84d4406b9 100644 --- a/src/v2/search/models/modelSearchParameters.ts +++ b/src/v2/search/models/modelSearchParameters.ts @@ -28,7 +28,9 @@ export class ModelSearchParameters extends BaseSearchParameters { this.modelType = params.modelType; } - /** @inheritdoc */ + /** + * @inheritdoc + */ getRequestParameters(): Record { const parameters = super.getRequestParameters(); if (this.name) { diff --git a/src/v2/search/ragDocuments/ragDocumentSearch.ts b/src/v2/search/ragDocuments/ragDocumentSearch.ts index 5ca7c3f7e..9c6b52ae7 100644 --- a/src/v2/search/ragDocuments/ragDocumentSearch.ts +++ b/src/v2/search/ragDocuments/ragDocumentSearch.ts @@ -6,17 +6,23 @@ import { RagDocumentSearchResponse } from "@/v2/search/ragDocuments/ragDocumentS * Search for RAG Documents. */ export class RagDocumentSearch extends BaseSearch { - /** @inheritDoc */ + /** + * @inheritDoc + */ static get parametersClass() { return RagDocumentSearchParameters; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get responseClass() { return RagDocumentSearchResponse; } - /** @inheritDoc */ + /** + * @inheritDoc + */ static get slug() { return "rag-documents"; } diff --git a/src/v2/search/ragDocuments/ragDocumentSearchParameters.ts b/src/v2/search/ragDocuments/ragDocumentSearchParameters.ts index 3cc35ca38..b9d7f45fc 100644 --- a/src/v2/search/ragDocuments/ragDocumentSearchParameters.ts +++ b/src/v2/search/ragDocuments/ragDocumentSearchParameters.ts @@ -32,7 +32,9 @@ export class RagDocumentSearchParameters extends BaseSearchParameters { this.filename = params.filename; } - /** @inheritdoc */ + /** + * @inheritdoc + */ getRequestParameters(): Record { const parameters = super.getRequestParameters(); From e41f59fc30f2565fcc406457ada16f1afe535ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Fri, 18 Sep 2026 18:38:15 +0200 Subject: [PATCH 2/4] Fix typo in alias documentation comment Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/v1/parsing/common/executionFile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1/parsing/common/executionFile.ts b/src/v1/parsing/common/executionFile.ts index a0ca415b5..3adbc4f1d 100644 --- a/src/v1/parsing/common/executionFile.ts +++ b/src/v1/parsing/common/executionFile.ts @@ -12,7 +12,7 @@ export class ExecutionFile { name: string|null; /** - * Optional alias for the fil. + * Optional alias for the file. */ alias: string|null; From f35ef40e4f112f3cc99379fcefb1ee1fe758cdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Fri, 18 Sep 2026 18:38:30 +0200 Subject: [PATCH 3/4] Fix typo in paymentDate documentation Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/v1/product/financialDocument/financialDocumentV1Document.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1/product/financialDocument/financialDocumentV1Document.ts b/src/v1/product/financialDocument/financialDocumentV1Document.ts index c840ddd3d..263cb9851 100644 --- a/src/v1/product/financialDocument/financialDocumentV1Document.ts +++ b/src/v1/product/financialDocument/financialDocumentV1Document.ts @@ -78,7 +78,7 @@ export class FinancialDocumentV1Document implements Prediction { */ locale: LocaleField; /** - * The date on which the payment is due / fullfilled. + * The date on which the payment is due / fulfilled. */ paymentDate: DateField; /** From d8a29f4ba7872345af5e261da9a645f67544d141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ianar=C3=A9?= <97107275+ianardee@users.noreply.github.com> Date: Fri, 18 Sep 2026 18:38:40 +0200 Subject: [PATCH 4/4] Fix typo in paymentDate documentation Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/v1/product/invoice/invoiceV4Document.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1/product/invoice/invoiceV4Document.ts b/src/v1/product/invoice/invoiceV4Document.ts index bedd1f83a..1b28cfc9c 100644 --- a/src/v1/product/invoice/invoiceV4Document.ts +++ b/src/v1/product/invoice/invoiceV4Document.ts @@ -73,7 +73,7 @@ export class InvoiceV4Document implements Prediction { */ locale: LocaleField; /** - * The date on which the payment is due / was full-filled. + * The date on which the payment is due / was fulfilled. */ paymentDate: DateField; /**