mindee 5.7.2 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/package.json +104 -95
- package/src/geometry/bbox.js +1 -1
- package/src/image/extractedImages.d.ts +1 -1
- package/src/image/imageExtractor.d.ts +1 -1
- package/src/image/imageExtractor.js +2 -2
- package/src/input/localInputSource.d.ts +1 -1
- package/src/parsing/baseLocalResponse.d.ts +1 -1
- package/src/pdf/extractedPdfs.d.ts +1 -1
- package/src/pdf/pdfExtractor.d.ts +1 -1
- package/src/pdf/pdfExtractor.js +2 -2
- package/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.d.ts +2 -2
- package/src/v1/extraction/invoiceSplitterExtractor/invoiceSplitterExtractor.js +2 -2
- package/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.d.ts +2 -2
- package/src/v1/extraction/multiReceiptsExtractor/multiReceiptsExtractor.js +1 -1
- package/src/v1/http/baseEndpoint.d.ts +1 -1
- package/src/v1/http/endpoint.d.ts +1 -1
- package/src/v1/http/endpoint.js +1 -1
- package/src/v1/http/httpParams.d.ts +1 -1
- package/src/v1/http/workflowEndpoint.d.ts +2 -2
- package/src/v1/http/workflowEndpoint.js +1 -1
- package/src/v1/parsing/common/execution.d.ts +1 -1
- package/src/v1/parsing/common/execution.js +1 -1
- package/src/v1/parsing/common/extras/cropperExtra.d.ts +1 -1
- package/src/v1/parsing/common/extras/cropperExtra.js +1 -1
- package/src/v1/parsing/common/ocrPage.d.ts +1 -1
- package/src/v1/parsing/common/ocrPage.js +1 -1
- package/src/v1/parsing/common/orientation.d.ts +1 -1
- package/src/v1/parsing/common/orientation.js +1 -1
- package/src/v1/parsing/generated/generatedList.d.ts +1 -1
- package/src/v1/parsing/generated/generatedList.js +1 -1
- package/src/v1/parsing/generated/generatedObject.d.ts +1 -1
- package/src/v1/parsing/generated/generatedObject.js +1 -1
- package/src/v1/parsing/localResponse.d.ts +1 -1
- package/src/v1/parsing/localResponse.js +1 -1
- package/src/v1/parsing/standard/amount.js +1 -1
- package/src/v1/parsing/standard/companyRegistration.js +1 -1
- package/src/v1/parsing/standard/tax.d.ts +1 -1
- package/src/v1/parsing/standard/tax.js +1 -1
- package/src/v1/product/barcodeReader/barcodeReaderV1.d.ts +1 -1
- package/src/v1/product/barcodeReader/barcodeReaderV1.js +1 -1
- package/src/v1/product/barcodeReader/barcodeReaderV1Document.d.ts +2 -2
- package/src/v1/product/barcodeReader/barcodeReaderV1Document.js +2 -2
- package/src/v1/product/cliProducts.d.ts +2 -2
- package/src/v1/product/cliProducts.js +1 -1
- package/src/v1/product/cropper/cropperV1.d.ts +1 -1
- package/src/v1/product/cropper/cropperV1.js +1 -1
- package/src/v1/product/cropper/cropperV1Document.d.ts +1 -1
- package/src/v1/product/cropper/cropperV1Page.d.ts +2 -2
- package/src/v1/product/cropper/cropperV1Page.js +2 -2
- package/src/v1/product/driverLicense/driverLicenseV1.d.ts +1 -1
- package/src/v1/product/driverLicense/driverLicenseV1.js +1 -1
- package/src/v1/product/driverLicense/driverLicenseV1Document.d.ts +2 -2
- package/src/v1/product/driverLicense/driverLicenseV1Document.js +2 -2
- package/src/v1/product/financialDocument/financialDocumentV1.d.ts +1 -1
- package/src/v1/product/financialDocument/financialDocumentV1.js +1 -1
- package/src/v1/product/financialDocument/financialDocumentV1Document.d.ts +2 -2
- package/src/v1/product/financialDocument/financialDocumentV1Document.js +2 -2
- package/src/v1/product/financialDocument/financialDocumentV1LineItem.js +1 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +1 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1.js +1 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +2 -2
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +2 -2
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +1 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2.js +1 -1
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts +2 -2
- package/src/v1/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +2 -2
- package/src/v1/product/fr/carteGrise/carteGriseV1.d.ts +1 -1
- package/src/v1/product/fr/carteGrise/carteGriseV1.js +1 -1
- package/src/v1/product/fr/carteGrise/carteGriseV1Document.d.ts +2 -2
- package/src/v1/product/fr/carteGrise/carteGriseV1Document.js +2 -2
- package/src/v1/product/fr/idCard/idCardV2.d.ts +1 -1
- package/src/v1/product/fr/idCard/idCardV2.js +1 -1
- package/src/v1/product/fr/idCard/idCardV2Document.d.ts +2 -2
- package/src/v1/product/fr/idCard/idCardV2Document.js +2 -2
- package/src/v1/product/fr/idCard/idCardV2Page.d.ts +2 -2
- package/src/v1/product/fr/idCard/idCardV2Page.js +2 -2
- package/src/v1/product/generated/generatedV1.d.ts +1 -1
- package/src/v1/product/generated/generatedV1.js +1 -1
- package/src/v1/product/generated/generatedV1Document.js +2 -2
- package/src/v1/product/generated/generatedV1Page.js +2 -2
- package/src/v1/product/generated/generatedV1Prediction.d.ts +3 -3
- package/src/v1/product/generated/generatedV1Prediction.js +3 -3
- package/src/v1/product/internationalId/internationalIdV2.d.ts +1 -1
- package/src/v1/product/internationalId/internationalIdV2.js +1 -1
- package/src/v1/product/internationalId/internationalIdV2Document.d.ts +2 -2
- package/src/v1/product/internationalId/internationalIdV2Document.js +2 -2
- package/src/v1/product/invoice/invoiceV4.d.ts +1 -1
- package/src/v1/product/invoice/invoiceV4.js +1 -1
- package/src/v1/product/invoice/invoiceV4Document.d.ts +2 -2
- package/src/v1/product/invoice/invoiceV4Document.js +2 -2
- package/src/v1/product/invoice/invoiceV4LineItem.js +1 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1.d.ts +1 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1.js +1 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +1 -1
- package/src/v1/product/invoiceSplitter/invoiceSplitterV1Document.js +1 -1
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.d.ts +1 -1
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1.js +1 -1
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.d.ts +2 -2
- package/src/v1/product/multiReceiptsDetector/multiReceiptsDetectorV1Document.js +2 -2
- package/src/v1/product/passport/passportV1.d.ts +1 -1
- package/src/v1/product/passport/passportV1.js +1 -1
- package/src/v1/product/passport/passportV1Document.d.ts +2 -2
- package/src/v1/product/passport/passportV1Document.js +2 -2
- package/src/v1/product/receipt/receiptV5.d.ts +1 -1
- package/src/v1/product/receipt/receiptV5.js +1 -1
- package/src/v1/product/receipt/receiptV5Document.d.ts +2 -2
- package/src/v1/product/receipt/receiptV5Document.js +2 -2
- package/src/v1/product/receipt/receiptV5LineItem.js +1 -1
- package/src/v1/product/resume/resumeV1.d.ts +1 -1
- package/src/v1/product/resume/resumeV1.js +1 -1
- package/src/v1/product/resume/resumeV1Certificate.js +1 -1
- package/src/v1/product/resume/resumeV1Document.d.ts +2 -2
- package/src/v1/product/resume/resumeV1Document.js +2 -2
- package/src/v1/product/resume/resumeV1Education.js +1 -1
- package/src/v1/product/resume/resumeV1Language.js +1 -1
- package/src/v1/product/resume/resumeV1ProfessionalExperience.js +1 -1
- package/src/v1/product/resume/resumeV1SocialNetworksUrl.js +1 -1
- package/src/v1/product/us/bankCheck/bankCheckV1.d.ts +1 -1
- package/src/v1/product/us/bankCheck/bankCheckV1.js +1 -1
- package/src/v1/product/us/bankCheck/bankCheckV1Document.d.ts +2 -2
- package/src/v1/product/us/bankCheck/bankCheckV1Document.js +2 -2
- package/src/v1/product/us/bankCheck/bankCheckV1Page.d.ts +2 -2
- package/src/v1/product/us/bankCheck/bankCheckV1Page.js +2 -2
- package/src/v2/cli.js +1 -1
- package/src/v2/client.d.ts +94 -18
- package/src/v2/client.js +171 -27
- package/src/v2/clientOptions/baseAnnotationParameters.d.ts +23 -0
- package/src/v2/clientOptions/baseAnnotationParameters.js +17 -0
- package/src/v2/clientOptions/baseProductParameters.js +3 -2
- package/src/v2/clientOptions/baseRagDocumentUploadParameters.d.ts +23 -0
- package/src/v2/clientOptions/baseRagDocumentUploadParameters.js +24 -0
- package/src/v2/clientOptions/index.d.ts +2 -0
- package/src/v2/clientOptions/index.js +2 -0
- package/src/v2/fileOperations/crop.d.ts +1 -1
- package/src/v2/http/errors.d.ts +1 -1
- package/src/v2/http/mindeeApiV2.d.ts +35 -6
- package/src/v2/http/mindeeApiV2.js +91 -10
- package/src/v2/index.d.ts +1 -1
- package/src/v2/index.js +1 -1
- package/src/v2/parsing/baseRagAnnotationResponse.d.ts +28 -0
- package/src/v2/parsing/baseRagAnnotationResponse.js +14 -0
- package/src/v2/parsing/baseResponse.d.ts +6 -2
- package/src/v2/parsing/baseResponse.js +3 -1
- package/src/v2/parsing/error/errorItem.d.ts +1 -1
- package/src/v2/parsing/error/errorItem.js +1 -3
- package/src/v2/parsing/error/errorResponse.d.ts +5 -1
- package/src/v2/parsing/error/errorResponse.js +27 -1
- package/src/v2/parsing/index.d.ts +3 -1
- package/src/v2/parsing/index.js +2 -1
- package/src/v2/parsing/inference/failedInferenceResponse.d.ts +2 -2
- package/src/v2/parsing/inference/failedInferenceResponse.js +2 -2
- package/src/v2/parsing/inference/field/inferenceFields.d.ts +9 -3
- package/src/v2/parsing/inference/field/inferenceFields.js +9 -3
- package/src/v2/parsing/inference/field/objectField.d.ts +13 -9
- package/src/v2/parsing/inference/field/objectField.js +19 -33
- package/src/v2/parsing/inference/index.d.ts +1 -0
- package/src/v2/parsing/inference/index.js +1 -0
- package/src/v2/parsing/job/job.d.ts +8 -8
- package/src/v2/parsing/job/job.js +1 -1
- package/src/v2/parsing/job/jobResponse.d.ts +1 -1
- package/src/v2/parsing/job/jobResponse.js +1 -1
- package/src/v2/parsing/job/jobWebhook.d.ts +1 -1
- package/src/v2/parsing/job/jobWebhook.js +1 -1
- package/src/v2/parsing/search/baseSearchResponse.d.ts +1 -1
- package/src/v2/parsing/search/baseSearchResponse.js +1 -1
- package/src/v2/parsing/search/searchModels.d.ts +1 -1
- package/src/v2/parsing/search/searchModels.js +1 -1
- package/src/v2/parsing/search/searchRagDocuments.d.ts +1 -1
- package/src/v2/parsing/search/searchRagDocuments.js +1 -1
- package/src/v2/parsing/search/searchResponse.d.ts +1 -1
- package/src/v2/parsing/search/searchResponse.js +1 -1
- package/src/v2/product/baseProduct.d.ts +26 -6
- package/src/v2/product/baseProduct.js +31 -7
- package/src/v2/product/classification/classification.d.ts +1 -1
- package/src/v2/product/classification/classification.js +1 -1
- package/src/v2/product/classification/classificationClassifier.d.ts +1 -1
- package/src/v2/product/classification/classificationClassifier.js +1 -1
- package/src/v2/product/classification/classificationInference.d.ts +1 -1
- package/src/v2/product/classification/classificationInference.js +1 -1
- package/src/v2/product/classification/classificationResponse.d.ts +1 -1
- package/src/v2/product/classification/classificationResponse.js +1 -1
- package/src/v2/product/classification/params/classificationParameters.d.ts +1 -1
- package/src/v2/product/classification/params/classificationParameters.js +1 -1
- package/src/v2/product/crop/crop.d.ts +1 -1
- package/src/v2/product/crop/crop.js +1 -1
- package/src/v2/product/crop/cropInference.d.ts +2 -2
- package/src/v2/product/crop/cropInference.js +2 -2
- package/src/v2/product/crop/cropItem.d.ts +2 -2
- package/src/v2/product/crop/cropItem.js +3 -3
- package/src/v2/product/crop/cropResponse.d.ts +1 -1
- package/src/v2/product/crop/cropResponse.js +1 -1
- package/src/v2/product/crop/cropResult.d.ts +1 -1
- package/src/v2/product/crop/cropResult.js +2 -2
- package/src/v2/product/crop/params/cropParameters.d.ts +1 -1
- package/src/v2/product/crop/params/cropParameters.js +1 -1
- package/src/v2/product/extraction/extraction.d.ts +10 -2
- package/src/v2/product/extraction/extraction.js +17 -3
- package/src/v2/product/extraction/extractionInference.d.ts +1 -1
- package/src/v2/product/extraction/extractionInference.js +1 -1
- package/src/v2/product/extraction/extractionResponse.d.ts +1 -1
- package/src/v2/product/extraction/extractionResponse.js +1 -1
- package/src/v2/product/extraction/extractionResult.d.ts +3 -3
- package/src/v2/product/extraction/extractionResult.js +3 -3
- package/src/v2/product/extraction/index.d.ts +1 -0
- package/src/v2/product/extraction/index.js +1 -0
- package/src/v2/product/extraction/params/extractionParameters.d.ts +1 -1
- package/src/v2/product/extraction/params/extractionParameters.js +1 -1
- package/src/v2/product/extraction/ragDocuments/annotatedBaseField.d.ts +20 -0
- package/src/v2/product/extraction/ragDocuments/annotatedBaseField.js +15 -0
- package/src/v2/product/extraction/ragDocuments/annotatedFields.d.ts +27 -0
- package/src/v2/product/extraction/ragDocuments/annotatedFields.js +57 -0
- package/src/v2/product/extraction/ragDocuments/annotatedListField.d.ts +24 -0
- package/src/v2/product/extraction/ragDocuments/annotatedListField.js +67 -0
- package/src/v2/product/extraction/ragDocuments/annotatedObjectField.d.ts +43 -0
- package/src/v2/product/extraction/ragDocuments/annotatedObjectField.js +47 -0
- package/src/v2/product/extraction/ragDocuments/annotatedSimpleField.d.ts +15 -0
- package/src/v2/product/extraction/ragDocuments/annotatedSimpleField.js +13 -0
- package/src/v2/product/extraction/ragDocuments/extractionRagAnnotationResponse.d.ts +25 -0
- package/src/v2/product/extraction/ragDocuments/extractionRagAnnotationResponse.js +17 -0
- package/src/v2/product/extraction/ragDocuments/fieldFactory.d.ts +12 -0
- package/src/v2/product/extraction/ragDocuments/fieldFactory.js +23 -0
- package/src/v2/product/extraction/ragDocuments/index.d.ts +7 -0
- package/src/v2/product/extraction/ragDocuments/index.js +7 -0
- package/src/v2/product/extraction/ragDocuments/params/index.d.ts +2 -0
- package/src/v2/product/extraction/ragDocuments/params/index.js +2 -0
- package/src/v2/product/extraction/ragDocuments/params/ragDocumentAnnotationParameters.d.ts +27 -0
- package/src/v2/product/extraction/ragDocuments/params/ragDocumentAnnotationParameters.js +43 -0
- package/src/v2/product/extraction/ragDocuments/params/ragDocumentUploadParameters.d.ts +7 -0
- package/src/v2/product/extraction/ragDocuments/params/ragDocumentUploadParameters.js +9 -0
- package/src/v2/product/extraction/ragDocuments/ragAnnotation.d.ts +12 -0
- package/src/v2/product/extraction/ragDocuments/ragAnnotation.js +9 -0
- package/src/v2/product/ocr/ocr.d.ts +1 -1
- package/src/v2/product/ocr/ocr.js +1 -1
- package/src/v2/product/ocr/ocrInference.d.ts +2 -2
- package/src/v2/product/ocr/ocrInference.js +2 -2
- package/src/v2/product/ocr/ocrResponse.d.ts +1 -1
- package/src/v2/product/ocr/ocrResponse.js +1 -1
- package/src/v2/product/ocr/params/ocrParameters.d.ts +1 -1
- package/src/v2/product/ocr/params/ocrParameters.js +1 -1
- package/src/v2/product/split/params/splitParameters.d.ts +1 -1
- package/src/v2/product/split/params/splitParameters.js +1 -1
- package/src/v2/product/split/split.d.ts +1 -1
- package/src/v2/product/split/split.js +1 -1
- package/src/v2/product/split/splitInference.d.ts +1 -1
- package/src/v2/product/split/splitInference.js +1 -1
- package/src/v2/product/split/splitRange.d.ts +1 -1
- package/src/v2/product/split/splitRange.js +2 -2
- package/src/v2/product/split/splitResponse.d.ts +1 -1
- package/src/v2/product/split/splitResponse.js +1 -1
- package/src/v2/product/split/splitResult.js +1 -1
- package/src/v2/search/baseSearch.d.ts +2 -2
- package/src/v2/search/models/modelSearch.d.ts +3 -3
- package/src/v2/search/models/modelSearch.js +3 -3
- package/src/v2/search/models/modelSearchParameters.d.ts +1 -1
- package/src/v2/search/models/modelSearchParameters.js +1 -1
- package/src/v2/search/models/modelSearchResponse.d.ts +2 -2
- package/src/v2/search/models/modelSearchResponse.js +2 -2
- package/src/v2/search/ragDocuments/ragDocumentSearch.d.ts +3 -3
- package/src/v2/search/ragDocuments/ragDocumentSearch.js +3 -3
- package/src/v2/search/ragDocuments/ragDocumentSearchParameters.d.ts +1 -1
- package/src/v2/search/ragDocuments/ragDocumentSearchParameters.js +1 -1
- package/src/v2/search/ragDocuments/ragDocumentSearchResponse.d.ts +2 -2
- package/src/v2/search/ragDocuments/ragDocumentSearchResponse.js +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ApiSettings } from "./apiSettings.js";
|
|
2
2
|
import { Dispatcher } from "undici";
|
|
3
|
-
import { BaseProductParameters } from "
|
|
4
|
-
import { BaseSearchParameters } from "
|
|
5
|
-
import { JobResponse } from "
|
|
6
|
-
import { InputSource } from "../../input/index.js";
|
|
7
|
-
import { BaseProduct } from "
|
|
8
|
-
import { BaseSearch } from "
|
|
3
|
+
import { BaseProductParameters } from "../index.js";
|
|
4
|
+
import { BaseSearchParameters, BaseAnnotationParameters, BaseRagDocumentUploadParameters } from "../clientOptions/index.js";
|
|
5
|
+
import { JobResponse } from "../parsing/index.js";
|
|
6
|
+
import { InputSource, LocalInputSource } from "../../input/index.js";
|
|
7
|
+
import { BaseProduct } from "../product/baseProduct.js";
|
|
8
|
+
import { BaseSearch } from "../search/baseSearch.js";
|
|
9
9
|
/**
|
|
10
10
|
* Mindee V2 API handler.
|
|
11
11
|
*/
|
|
@@ -57,4 +57,33 @@ export declare class MindeeApiV2 {
|
|
|
57
57
|
* @returns a `Promise` containing the search response.
|
|
58
58
|
*/
|
|
59
59
|
reqGetSearch<S extends typeof BaseSearch>(search: S, parameters: BaseSearchParameters): Promise<InstanceType<S["responseClass"]>>;
|
|
60
|
+
/**
|
|
61
|
+
* Get a document's info and annotations from the RAG database.
|
|
62
|
+
* @param product the product definition to use.
|
|
63
|
+
* @param documentId the document id to get.
|
|
64
|
+
* @returns a `Promise` containing an annotation response.
|
|
65
|
+
*/
|
|
66
|
+
reqGetRagAnnotation<P extends typeof BaseProduct>(product: P, documentId: string): Promise<InstanceType<P["annotationResponseClass"]>>;
|
|
67
|
+
/**
|
|
68
|
+
* Add a document to the RAG database.
|
|
69
|
+
* @param product the product definition to use.
|
|
70
|
+
* @param parameters the parameters to use.
|
|
71
|
+
* @param inputSource the file to upload.
|
|
72
|
+
* @returns a `Promise` containing an annotation response.
|
|
73
|
+
*/
|
|
74
|
+
reqPostRagDocument<P extends typeof BaseProduct>(product: P, parameters: BaseRagDocumentUploadParameters, inputSource: LocalInputSource): Promise<InstanceType<P["annotationResponseClass"]>>;
|
|
75
|
+
/**
|
|
76
|
+
* Update a document's annotations in the RAG database.
|
|
77
|
+
* @param product the product definition to use.
|
|
78
|
+
* @param parameters the parameters to use.
|
|
79
|
+
* @returns a `Promise` containing an annotation response.
|
|
80
|
+
*/
|
|
81
|
+
reqPatchRagAnnotation<P extends typeof BaseProduct>(product: P, parameters: BaseAnnotationParameters): Promise<InstanceType<P["annotationResponseClass"]>>;
|
|
82
|
+
/**
|
|
83
|
+
* Deletes a document from the RAG database.
|
|
84
|
+
* @param product the product definition to use.
|
|
85
|
+
* @param documentId the document's ID.
|
|
86
|
+
* @returns true if the document was deleted successfully, false otherwise.
|
|
87
|
+
*/
|
|
88
|
+
reqDeleteRagDocument<P extends typeof BaseProduct>(product: P, documentId: string): Promise<boolean>;
|
|
60
89
|
}
|
|
@@ -6,7 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
6
6
|
var _MindeeApiV2_instances, _MindeeApiV2_paramsToFormData, _MindeeApiV2_processResponse;
|
|
7
7
|
import { ApiSettings } from "./apiSettings.js";
|
|
8
8
|
import { FormData } from "undici";
|
|
9
|
-
import { ErrorResponse, JobResponse, } from "
|
|
9
|
+
import { ErrorResponse, JobResponse, } from "../parsing/index.js";
|
|
10
10
|
import { sendRequestAndReadResponse } from "../../http/apiCore.js";
|
|
11
11
|
import { LocalInputSource } from "../../input/index.js";
|
|
12
12
|
import { MindeeDeserializationError, MindeeError } from "../../errors/index.js";
|
|
@@ -34,12 +34,11 @@ export class MindeeApiV2 {
|
|
|
34
34
|
else {
|
|
35
35
|
form.set("url", inputSource.url);
|
|
36
36
|
}
|
|
37
|
-
const path = `/v2/products/${product.slug}/enqueue`;
|
|
38
37
|
const options = {
|
|
39
38
|
method: "POST",
|
|
40
39
|
headers: this.settings.baseHeaders,
|
|
41
40
|
hostname: this.settings.hostname,
|
|
42
|
-
path:
|
|
41
|
+
path: `/v2/products/${product.slug}/enqueue`,
|
|
43
42
|
body: form,
|
|
44
43
|
timeoutSecs: this.settings.timeoutSecs,
|
|
45
44
|
};
|
|
@@ -123,6 +122,83 @@ export class MindeeApiV2 {
|
|
|
123
122
|
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
124
123
|
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, search.responseClass);
|
|
125
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Get a document's info and annotations from the RAG database.
|
|
127
|
+
* @param product the product definition to use.
|
|
128
|
+
* @param documentId the document id to get.
|
|
129
|
+
* @returns a `Promise` containing an annotation response.
|
|
130
|
+
*/
|
|
131
|
+
async reqGetRagAnnotation(product, documentId) {
|
|
132
|
+
const options = {
|
|
133
|
+
method: "GET",
|
|
134
|
+
headers: this.settings.baseHeaders,
|
|
135
|
+
hostname: this.settings.hostname,
|
|
136
|
+
path: `/v2/products/${product.slug}/rag-documents/${documentId}`,
|
|
137
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
138
|
+
};
|
|
139
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
140
|
+
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, product.annotationResponseClass);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Add a document to the RAG database.
|
|
144
|
+
* @param product the product definition to use.
|
|
145
|
+
* @param parameters the parameters to use.
|
|
146
|
+
* @param inputSource the file to upload.
|
|
147
|
+
* @returns a `Promise` containing an annotation response.
|
|
148
|
+
*/
|
|
149
|
+
async reqPostRagDocument(product, parameters, inputSource) {
|
|
150
|
+
const form = __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_paramsToFormData).call(this, parameters.getRequestParameters());
|
|
151
|
+
form.set("file", new Blob([inputSource.fileObject]), inputSource.filename);
|
|
152
|
+
const options = {
|
|
153
|
+
method: "POST",
|
|
154
|
+
headers: this.settings.baseHeaders,
|
|
155
|
+
hostname: this.settings.hostname,
|
|
156
|
+
path: `/v2/products/${product.slug}/rag-documents`,
|
|
157
|
+
body: form,
|
|
158
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
159
|
+
};
|
|
160
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
161
|
+
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, product.annotationResponseClass);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Update a document's annotations in the RAG database.
|
|
165
|
+
* @param product the product definition to use.
|
|
166
|
+
* @param parameters the parameters to use.
|
|
167
|
+
* @returns a `Promise` containing an annotation response.
|
|
168
|
+
*/
|
|
169
|
+
async reqPatchRagAnnotation(product, parameters) {
|
|
170
|
+
const options = {
|
|
171
|
+
method: "PATCH",
|
|
172
|
+
headers: {
|
|
173
|
+
...this.settings.baseHeaders,
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
175
|
+
"Content-Type": "application/json",
|
|
176
|
+
},
|
|
177
|
+
hostname: this.settings.hostname,
|
|
178
|
+
path: `/v2/products/${product.slug}/rag-documents/${parameters.documentId}`,
|
|
179
|
+
body: JSON.stringify(parameters.getRequestParameters()),
|
|
180
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
181
|
+
};
|
|
182
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
183
|
+
return __classPrivateFieldGet(this, _MindeeApiV2_instances, "m", _MindeeApiV2_processResponse).call(this, response, product.annotationResponseClass);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Deletes a document from the RAG database.
|
|
187
|
+
* @param product the product definition to use.
|
|
188
|
+
* @param documentId the document's ID.
|
|
189
|
+
* @returns true if the document was deleted successfully, false otherwise.
|
|
190
|
+
*/
|
|
191
|
+
async reqDeleteRagDocument(product, documentId) {
|
|
192
|
+
const options = {
|
|
193
|
+
method: "DELETE",
|
|
194
|
+
headers: this.settings.baseHeaders,
|
|
195
|
+
hostname: this.settings.hostname,
|
|
196
|
+
path: `/v2/products/${product.slug}/rag-documents/${documentId}`,
|
|
197
|
+
timeoutSecs: this.settings.timeoutSecs,
|
|
198
|
+
};
|
|
199
|
+
const response = await sendRequestAndReadResponse(this.settings.dispatcher, options);
|
|
200
|
+
return response.messageObj?.statusCode >= 200 && response.messageObj?.statusCode < 400;
|
|
201
|
+
}
|
|
126
202
|
}
|
|
127
203
|
_MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_paramsToFormData = function _MindeeApiV2_paramsToFormData(params) {
|
|
128
204
|
const form = new FormData();
|
|
@@ -133,15 +209,20 @@ _MindeeApiV2_instances = new WeakSet(), _MindeeApiV2_paramsToFormData = function
|
|
|
133
209
|
}, _MindeeApiV2_processResponse = function _MindeeApiV2_processResponse(result, responseClass) {
|
|
134
210
|
if (result.messageObj?.statusCode
|
|
135
211
|
&& (result.messageObj?.statusCode > 399 || result.messageObj?.statusCode < 200)) {
|
|
212
|
+
let errorResponse;
|
|
136
213
|
if (result.data?.status !== null) {
|
|
137
|
-
|
|
214
|
+
errorResponse = new ErrorResponse(result.data);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
errorResponse = new ErrorResponse({
|
|
218
|
+
status: result.messageObj?.statusCode ?? -1,
|
|
219
|
+
title: "Unknown Error",
|
|
220
|
+
detail: result.data?.detail ?? "The server returned an Unknown error.",
|
|
221
|
+
code: `${result.messageObj?.statusCode ?? -1}-000`,
|
|
222
|
+
});
|
|
138
223
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
title: "Unknown Error",
|
|
142
|
-
detail: result.data?.detail ?? "The server returned an Unknown error.",
|
|
143
|
-
code: `${result.messageObj?.statusCode ?? -1}-000`,
|
|
144
|
-
}));
|
|
224
|
+
logger.error(errorResponse.toString());
|
|
225
|
+
throw new MindeeHttpErrorV2(errorResponse);
|
|
145
226
|
}
|
|
146
227
|
try {
|
|
147
228
|
return new responseClass(result.data);
|
package/src/v2/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export * as parsing from "./parsing/index.js";
|
|
|
3
3
|
export * as product from "./product/index.js";
|
|
4
4
|
export * as search from "./search/index.js";
|
|
5
5
|
export { Client } from "./client.js";
|
|
6
|
-
export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
|
|
6
|
+
export { JobResponse, ErrorResponse, LocalResponse, FailedInferenceResponse, } from "./parsing/index.js";
|
|
7
7
|
export type { BaseProductParameters, TimerOptions } from "./clientOptions/index.js";
|
|
8
8
|
export { PollingOptions } from "./clientOptions/index.js";
|
package/src/v2/index.js
CHANGED
|
@@ -3,5 +3,5 @@ export * as parsing from "./parsing/index.js";
|
|
|
3
3
|
export * as product from "./product/index.js";
|
|
4
4
|
export * as search from "./search/index.js";
|
|
5
5
|
export { Client } from "./client.js";
|
|
6
|
-
export { JobResponse, ErrorResponse, LocalResponse, } from "./parsing/index.js";
|
|
6
|
+
export { JobResponse, ErrorResponse, LocalResponse, FailedInferenceResponse, } from "./parsing/index.js";
|
|
7
7
|
export { PollingOptions } from "./clientOptions/index.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseResponse } from "./baseResponse.js";
|
|
2
|
+
import { StringDict } from "../../parsing/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all RAG document responses from the V2 API.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BaseRagAnnotationResponse extends BaseResponse {
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier of the RAG document.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Original filename of the uploaded document.
|
|
13
|
+
*/
|
|
14
|
+
filename: string;
|
|
15
|
+
/**
|
|
16
|
+
* Date and time of the document creation.
|
|
17
|
+
*/
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
/**
|
|
20
|
+
* Current status of the RAG document.
|
|
21
|
+
*/
|
|
22
|
+
status: string;
|
|
23
|
+
constructor(serverResponse: StringDict);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Constructor signature for typed v2 response classes.
|
|
27
|
+
*/
|
|
28
|
+
export type AnnotationResponseConstructor<T extends BaseRagAnnotationResponse> = new (serverResponse: StringDict) => T;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseResponse } from "./baseResponse.js";
|
|
2
|
+
import { parseDate } from "../../parsing/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all RAG document responses from the V2 API.
|
|
5
|
+
*/
|
|
6
|
+
export class BaseRagAnnotationResponse extends BaseResponse {
|
|
7
|
+
constructor(serverResponse) {
|
|
8
|
+
super(serverResponse);
|
|
9
|
+
this.id = serverResponse["id"];
|
|
10
|
+
this.filename = serverResponse["filename"];
|
|
11
|
+
this.createdAt = parseDate(serverResponse["created_at"]);
|
|
12
|
+
this.status = serverResponse["status"];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { StringDict } from "../../parsing/stringDict.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Base response contract for v2 product responses.
|
|
4
|
+
*/
|
|
3
5
|
export declare abstract class BaseResponse {
|
|
4
6
|
/**
|
|
5
7
|
* Raw text representation of the API's response.
|
|
@@ -15,5 +17,7 @@ export declare abstract class BaseResponse {
|
|
|
15
17
|
*/
|
|
16
18
|
getRawHttp(): StringDict;
|
|
17
19
|
}
|
|
18
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Constructor signature for typed v2 response classes.
|
|
22
|
+
*/
|
|
19
23
|
export type ResponseConstructor<T extends BaseResponse> = new (serverResponse: StringDict) => T;
|
|
@@ -6,9 +6,7 @@ export class ErrorItem {
|
|
|
6
6
|
* @param serverResponse JSON response from the server.
|
|
7
7
|
*/
|
|
8
8
|
constructor(serverResponse) {
|
|
9
|
-
|
|
10
|
-
this.pointer = serverResponse["pointer"];
|
|
11
|
-
}
|
|
9
|
+
this.pointer = serverResponse["pointer"];
|
|
12
10
|
this.detail = serverResponse["detail"];
|
|
13
11
|
}
|
|
14
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/stringDict.js";
|
|
2
2
|
import { ErrorItem } from "./errorItem.js";
|
|
3
3
|
import { ErrorDetails } from "./errorDetails.js";
|
|
4
|
-
import { BaseResponse } from "
|
|
4
|
+
import { BaseResponse } from "../baseResponse.js";
|
|
5
5
|
/**
|
|
6
6
|
* Error response detailing a problem. The format adheres to RFC 9457.
|
|
7
7
|
*/
|
|
@@ -15,4 +15,8 @@ export declare class ErrorResponse extends BaseResponse implements ErrorDetails
|
|
|
15
15
|
* @param serverResponse JSON response from the server.
|
|
16
16
|
*/
|
|
17
17
|
constructor(serverResponse: StringDict);
|
|
18
|
+
/**
|
|
19
|
+
* To make the error prettier to display.
|
|
20
|
+
*/
|
|
21
|
+
toString(): string;
|
|
18
22
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorItem } from "./errorItem.js";
|
|
2
|
-
import { BaseResponse } from "
|
|
2
|
+
import { BaseResponse } from "../baseResponse.js";
|
|
3
3
|
/**
|
|
4
4
|
* Error response detailing a problem. The format adheres to RFC 9457.
|
|
5
5
|
*/
|
|
@@ -20,4 +20,30 @@ export class ErrorResponse extends BaseResponse {
|
|
|
20
20
|
this.errors = [];
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* To make the error prettier to display.
|
|
25
|
+
*/
|
|
26
|
+
toString() {
|
|
27
|
+
const result = [];
|
|
28
|
+
result.push("Error Details");
|
|
29
|
+
result.push("=============");
|
|
30
|
+
result.push(`:HTTP Status: ${this.status}`);
|
|
31
|
+
result.push(`:Title: ${this.title}`);
|
|
32
|
+
result.push(`:Code: ${this.code}`);
|
|
33
|
+
result.push(`:Detail: ${this.detail}`);
|
|
34
|
+
if (this.errors && this.errors.length > 0) {
|
|
35
|
+
result.push("");
|
|
36
|
+
result.push("Error Items");
|
|
37
|
+
result.push("-----------");
|
|
38
|
+
this.errors.forEach((error, i) => {
|
|
39
|
+
result.push(`**Error ${i + 1}:**`);
|
|
40
|
+
result.push(` :Pointer: ${error.pointer}`);
|
|
41
|
+
result.push(` :Detail: ${error.detail}`);
|
|
42
|
+
if (i < this.errors.length - 1) {
|
|
43
|
+
result.push("");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return result.join("\n") + "\n";
|
|
48
|
+
}
|
|
23
49
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { ErrorResponse, ErrorItem, } from "./error/index.js";
|
|
2
2
|
export type { ErrorDetails } from "./error/index.js";
|
|
3
3
|
export { Job, JobResponse, JobWebhook, } from "./job/index.js";
|
|
4
|
-
export { BaseInference, InferenceFile, InferenceModel, } from "./inference/index.js";
|
|
4
|
+
export { BaseInference, InferenceFile, InferenceModel, FailedInferenceResponse, } from "./inference/index.js";
|
|
5
5
|
export { LocalResponse } from "./localResponse.js";
|
|
6
6
|
export { BaseResponse } from "./baseResponse.js";
|
|
7
7
|
export type { ResponseConstructor } from "./baseResponse.js";
|
|
8
|
+
export { BaseRagAnnotationResponse } from "./baseRagAnnotationResponse.js";
|
|
9
|
+
export type { AnnotationResponseConstructor } from "./baseRagAnnotationResponse.js";
|
|
8
10
|
export * as field from "./inference/field/index.js";
|
package/src/v2/parsing/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { ErrorResponse, ErrorItem, } from "./error/index.js";
|
|
2
2
|
export { Job, JobResponse, JobWebhook, } from "./job/index.js";
|
|
3
|
-
export { BaseInference, InferenceFile, InferenceModel, } from "./inference/index.js";
|
|
3
|
+
export { BaseInference, InferenceFile, InferenceModel, FailedInferenceResponse, } from "./inference/index.js";
|
|
4
4
|
export { LocalResponse } from "./localResponse.js";
|
|
5
5
|
export { BaseResponse } from "./baseResponse.js";
|
|
6
|
+
export { BaseRagAnnotationResponse } from "./baseRagAnnotationResponse.js";
|
|
6
7
|
export * as field from "./inference/field/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StringDict } from "../../../parsing/index.js";
|
|
2
|
-
import { ErrorResponse } from "
|
|
3
|
-
import { BaseResponse } from "
|
|
2
|
+
import { ErrorResponse } from "../../index.js";
|
|
3
|
+
import { BaseResponse } from "../baseResponse.js";
|
|
4
4
|
/**
|
|
5
5
|
* Webhook payload returned when an inference fails before producing a result.
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseDate } from "../../../parsing/index.js";
|
|
2
|
-
import { ErrorResponse } from "
|
|
3
|
-
import { BaseResponse } from "
|
|
2
|
+
import { ErrorResponse } from "../../index.js";
|
|
3
|
+
import { BaseResponse } from "../baseResponse.js";
|
|
4
4
|
/**
|
|
5
5
|
* Webhook payload returned when an inference fails before producing a result.
|
|
6
6
|
*/
|
|
@@ -7,11 +7,17 @@ export declare class InferenceFields extends Map<string, SimpleField | ObjectFie
|
|
|
7
7
|
/** Indentation level used when rendering text output. */
|
|
8
8
|
protected _indentLevel: number;
|
|
9
9
|
constructor(serverResponse: StringDict, indentLevel?: number);
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Returns a field as a `SimpleField`, or throws if the type mismatches.
|
|
12
|
+
*/
|
|
11
13
|
getSimpleField(fieldName: string): SimpleField;
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Returns a field as an `ObjectField`, or throws if the type mismatches.
|
|
16
|
+
*/
|
|
13
17
|
getObjectField(fieldName: string): ObjectField;
|
|
14
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Returns a field as a `ListField`, or throws if the type mismatches.
|
|
20
|
+
*/
|
|
15
21
|
getListField(fieldName: string): ListField;
|
|
16
22
|
toString(indent?: number): string;
|
|
17
23
|
}
|
|
@@ -7,7 +7,9 @@ export class InferenceFields extends Map {
|
|
|
7
7
|
}));
|
|
8
8
|
this._indentLevel = indentLevel;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Returns a field as a `SimpleField`, or throws if the type mismatches.
|
|
12
|
+
*/
|
|
11
13
|
getSimpleField(fieldName) {
|
|
12
14
|
const field = this.get(fieldName);
|
|
13
15
|
if (field === undefined) {
|
|
@@ -18,7 +20,9 @@ export class InferenceFields extends Map {
|
|
|
18
20
|
}
|
|
19
21
|
return field;
|
|
20
22
|
}
|
|
21
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Returns a field as an `ObjectField`, or throws if the type mismatches.
|
|
25
|
+
*/
|
|
22
26
|
getObjectField(fieldName) {
|
|
23
27
|
const field = this.get(fieldName);
|
|
24
28
|
if (field === undefined) {
|
|
@@ -29,7 +33,9 @@ export class InferenceFields extends Map {
|
|
|
29
33
|
}
|
|
30
34
|
return field;
|
|
31
35
|
}
|
|
32
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Returns a field as a `ListField`, or throws if the type mismatches.
|
|
38
|
+
*/
|
|
33
39
|
getListField(fieldName) {
|
|
34
40
|
const field = this.get(fieldName);
|
|
35
41
|
if (field === undefined) {
|
|
@@ -7,6 +7,7 @@ import type { ListField } from "./listField.js";
|
|
|
7
7
|
export declare class ObjectField extends BaseField {
|
|
8
8
|
/** Nested fields carried by this object. */
|
|
9
9
|
readonly fields: InferenceFields;
|
|
10
|
+
constructor(serverResponse: StringDict, indentLevel?: number);
|
|
10
11
|
/**
|
|
11
12
|
* Retrieves the simple sub-fields in the object.
|
|
12
13
|
*
|
|
@@ -29,29 +30,32 @@ export declare class ObjectField extends BaseField {
|
|
|
29
30
|
* Retrieves a SimpleField by its name if it exists and is of the correct type.
|
|
30
31
|
*
|
|
31
32
|
* @param {string} fieldName - The name of the field to retrieve.
|
|
32
|
-
* @return {SimpleField} The
|
|
33
|
-
* @throws {Error} If the field does not exist or is
|
|
33
|
+
* @return {SimpleField} The field instance if it exists and is valid, or undefined if not.
|
|
34
|
+
* @throws {Error} If the field does not exist or is of wrong type.
|
|
34
35
|
*/
|
|
35
36
|
getSimpleField(fieldName: string): SimpleField;
|
|
36
37
|
/**
|
|
37
38
|
* Retrieves a ListField by its name if it exists and is of the correct type.
|
|
38
39
|
*
|
|
39
40
|
* @param {string} fieldName - The name of the field to retrieve.
|
|
40
|
-
* @return {ListField} The
|
|
41
|
-
* @throws {Error} If the field does not exist or is
|
|
41
|
+
* @return {ListField} The field instance if it exists and is valid, or undefined if not.
|
|
42
|
+
* @throws {Error} If the field does not exist or is of wrong type.
|
|
42
43
|
*/
|
|
43
44
|
getListField(fieldName: string): ListField;
|
|
44
45
|
/**
|
|
45
46
|
* Retrieves an ObjectField by its name if it exists and is of the correct type.
|
|
46
47
|
*
|
|
47
48
|
* @param {string} fieldName - The name of the field to retrieve.
|
|
48
|
-
* @return {ObjectField} The
|
|
49
|
-
* @throws {Error} If the field does not exist or is
|
|
49
|
+
* @return {ObjectField} The field instance if it exists and is valid, or undefined if not.
|
|
50
|
+
* @throws {Error} If the field does not exist or is of wrong type.
|
|
50
51
|
*/
|
|
51
52
|
getObjectField(fieldName: string): ObjectField;
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Returns a readable representation of nested fields.
|
|
55
|
+
*/
|
|
54
56
|
toString(): string;
|
|
55
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Returns a compact representation suitable for list items.
|
|
59
|
+
*/
|
|
56
60
|
toStringFromList(): string;
|
|
57
61
|
}
|
|
@@ -2,6 +2,10 @@ import { InferenceFields } from "./inferenceFields.js";
|
|
|
2
2
|
import { BaseField } from "./baseField.js";
|
|
3
3
|
/** Object-valued inference field. */
|
|
4
4
|
export class ObjectField extends BaseField {
|
|
5
|
+
constructor(serverResponse, indentLevel = 0) {
|
|
6
|
+
super(serverResponse, indentLevel);
|
|
7
|
+
this.fields = new InferenceFields(serverResponse["fields"], this._indentLevel + 1);
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
10
|
* Retrieves the simple sub-fields in the object.
|
|
7
11
|
*
|
|
@@ -48,59 +52,41 @@ export class ObjectField extends BaseField {
|
|
|
48
52
|
* Retrieves a SimpleField by its name if it exists and is of the correct type.
|
|
49
53
|
*
|
|
50
54
|
* @param {string} fieldName - The name of the field to retrieve.
|
|
51
|
-
* @return {SimpleField} The
|
|
52
|
-
* @throws {Error} If the field does not exist or is
|
|
55
|
+
* @return {SimpleField} The field instance if it exists and is valid, or undefined if not.
|
|
56
|
+
* @throws {Error} If the field does not exist or is of wrong type.
|
|
53
57
|
*/
|
|
54
58
|
getSimpleField(fieldName) {
|
|
55
|
-
|
|
56
|
-
throw new Error(`The field '${fieldName}' was not found.`);
|
|
57
|
-
}
|
|
58
|
-
if (this.fields.get(fieldName)?.constructor.name !== "SimpleField") {
|
|
59
|
-
throw new Error(`The field '${fieldName}' is not a SimpleField.`);
|
|
60
|
-
}
|
|
61
|
-
return this.simpleFields.get(fieldName);
|
|
59
|
+
return this.fields.getSimpleField(fieldName);
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* Retrieves a ListField by its name if it exists and is of the correct type.
|
|
65
63
|
*
|
|
66
64
|
* @param {string} fieldName - The name of the field to retrieve.
|
|
67
|
-
* @return {ListField} The
|
|
68
|
-
* @throws {Error} If the field does not exist or is
|
|
65
|
+
* @return {ListField} The field instance if it exists and is valid, or undefined if not.
|
|
66
|
+
* @throws {Error} If the field does not exist or is of wrong type.
|
|
69
67
|
*/
|
|
70
68
|
getListField(fieldName) {
|
|
71
|
-
|
|
72
|
-
throw new Error(`The field '${fieldName}' was not found.`);
|
|
73
|
-
}
|
|
74
|
-
if (this.fields.get(fieldName)?.constructor.name !== "ListField") {
|
|
75
|
-
throw new Error(`The field '${fieldName}' is not a ListField.`);
|
|
76
|
-
}
|
|
77
|
-
return this.listFields.get(fieldName);
|
|
69
|
+
return this.fields.getListField(fieldName);
|
|
78
70
|
}
|
|
79
71
|
/**
|
|
80
72
|
* Retrieves an ObjectField by its name if it exists and is of the correct type.
|
|
81
73
|
*
|
|
82
74
|
* @param {string} fieldName - The name of the field to retrieve.
|
|
83
|
-
* @return {ObjectField} The
|
|
84
|
-
* @throws {Error} If the field does not exist or is
|
|
75
|
+
* @return {ObjectField} The field instance if it exists and is valid, or undefined if not.
|
|
76
|
+
* @throws {Error} If the field does not exist or is of wrong type.
|
|
85
77
|
*/
|
|
86
78
|
getObjectField(fieldName) {
|
|
87
|
-
|
|
88
|
-
throw new Error(`The field '${fieldName}' was not found.`);
|
|
89
|
-
}
|
|
90
|
-
if (this.fields.get(fieldName)?.constructor.name !== "ObjectField") {
|
|
91
|
-
throw new Error(`The field '${fieldName}' is not an ObjectField.`);
|
|
92
|
-
}
|
|
93
|
-
return this.objectFields.get(fieldName);
|
|
94
|
-
}
|
|
95
|
-
constructor(serverResponse, indentLevel = 0) {
|
|
96
|
-
super(serverResponse, indentLevel);
|
|
97
|
-
this.fields = new InferenceFields(serverResponse["fields"], this._indentLevel + 1);
|
|
79
|
+
return this.fields.getObjectField(fieldName);
|
|
98
80
|
}
|
|
99
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Returns a readable representation of nested fields.
|
|
83
|
+
*/
|
|
100
84
|
toString() {
|
|
101
85
|
return "\n" + (this.fields ? this.fields.toString(1) : "");
|
|
102
86
|
}
|
|
103
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Returns a compact representation suitable for list items.
|
|
89
|
+
*/
|
|
104
90
|
toStringFromList() {
|
|
105
91
|
return this.fields ? this.fields.toString(2).substring(4) : "";
|
|
106
92
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BaseInference } from "./baseInference.js";
|
|
2
2
|
export { InferenceFile } from "./inferenceFile.js";
|
|
3
3
|
export { InferenceModel } from "./inferenceModel.js";
|
|
4
|
+
export { FailedInferenceResponse } from "./failedInferenceResponse.js";
|
|
4
5
|
export * as field from "./field/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BaseInference } from "./baseInference.js";
|
|
2
2
|
export { InferenceFile } from "./inferenceFile.js";
|
|
3
3
|
export { InferenceModel } from "./inferenceModel.js";
|
|
4
|
+
export { FailedInferenceResponse } from "./failedInferenceResponse.js";
|
|
4
5
|
export * as field from "./field/index.js";
|