import { Dispatcher } from "undici"; import { InputSource } from "../input/index.js"; import { JobResponse } from "./parsing/index.js"; import { SearchResponse } from "./parsing/search/index.js"; import { MindeeApiV2 } from "./http/mindeeApiV2.js"; import { PollingOptions, PollingOptionsConstructor } from "./clientOptions/index.js"; import { BaseProduct } from "./product/baseProduct.js"; import { BaseSearch } from "./search/baseSearch.js"; import { LocalInputSource } from "../input/index.js"; /** * Options for the V2 Mindee Client. * @example * const client = new MindeeClientV2({ * apiKey: "YOUR_API_KEY", * throwOnError: true, * debug: false * }); */ export interface ClientOptions { /** * Your API key for all endpoints. */ apiKey?: string; /** * Log debug messages. */ debug?: boolean; /** * Custom Dispatcher instance for the HTTP requests. */ dispatcher?: Dispatcher; } /** * Mindee Client V2 class that centralizes most basic operations. */ export declare class Client { /** * Mindee V2 API handler. */ protected mindeeApi: MindeeApiV2; /** * @param {ClientOptions} options options for the initialization of a client. */ constructor({ apiKey, debug, dispatcher }?: ClientOptions); /** * Send a file to the asynchronous processing queue for inference. */ enqueue

(product: P, inputSource: InputSource, params: InstanceType | ConstructorParameters[0]): Promise; /** * Get the status of an inference that was previously enqueued. * Can be used for polling. * * @param pollingUrl The URL to poll to retrieve the job. * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. * @returns a `Promise` containing a `Job`, which also contains a `Document` if the * parsing is complete. */ getJobByUrl(pollingUrl: string): Promise; /** * Get the result of an inference that was previously enqueued. * * @param product the product to retrieve. * @param url URL as given in the `getJob()` response. * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. * @returns a `Promise` containing the inference. */ getResultByUrl

(product: P, url: string): Promise>; /** * Get the result of an inference that was previously enqueued. * Prefer using `getResultByUrl` using the result URL returned in the Job instance. * * @param product the product to retrieve. * @param inferenceId id of the queue to poll. * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. * @returns a `Promise` containing the inference. */ getResult

(product: P, inferenceId: string): Promise>; /** * Get the status of an inference that was previously enqueued. * Prefer using `getJobByUrl` using the polling URL returned by the enqueue method. * * @param jobId id of the queue to poll. * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`. * @returns a `Promise` containing a `Job`, which also contains a `Document` if the * parsing is complete. */ getJob(jobId: string): Promise; /** * Send a file to the inference queue and return the results when complete. * * @param product the product to retrieve. * @param inputSource file or URL to parse. * @param params parameters relating to prediction options. * @param pollingOptions options for the polling loop, see {@link PollingOptions}. * @returns a `Promise` containing parsing results. */ enqueueAndGetResult

(product: P, inputSource: InputSource, params: InstanceType | ConstructorParameters[0], pollingOptions?: PollingOptions | PollingOptionsConstructor): Promise>; /** * Checks if all webhooks associated with a job have finished processing. */ private checkWebhooksDone; /** * Polls a job until it is processed or the maximum number of tries is reached. * @protected */ protected pollOnJob(initialResponse: JobResponse, pollingOptions: PollingOptions, waitForWebhooks?: boolean): Promise; /** * Poll until the inference is finished processing or the max number of attempts is reached. * @protected */ protected pollForProductResult

(product: P, pollingOptions: PollingOptions, initialResponse: JobResponse, waitForWebhooks?: boolean): Promise>; /** * Search for models available to the account. * @param name Optional name filter. * @param modelType Optional model type filter. * @returns a `Promise` containing the search response. * @deprecated Use `search(ModelSearch, {})` instead. */ searchModels(name?: string, modelType?: string): Promise; /** * Search for resources matching the given criteria. * @param search Search definition class to use. * @param searchParameters Search parameters. * @returns a `Promise` containing the search response with the matching resources. */ search(search: S, searchParameters: InstanceType | ConstructorParameters[0]): Promise>; /** * Not recommended for general use, prefer `getReadyRagDocumentPoll`. * You will need to poll until the document is ready for use. * Get a document's info and annotations from the RAG database. * * @param product the product the RAG database belongs to. * @param documentId the document's ID. */ getRagDocument

(product: P, documentId: string): Promise>; /** * Get a document's info and annotations from the RAG database. * * @param product the product the RAG database belongs to. * @param documentId the document's ID. * @param pollingOptions options for the polling loop, see {@link PollingOptions}. * @returns a `Promise` containing the RAG document annotation. */ getReadyRagDocumentPoll

(product: P, documentId: string, pollingOptions?: PollingOptions | PollingOptionsConstructor): Promise>; /** * Not recommended for general use, prefer `uploadAndGetRagDocumentPoll`. * You will need to poll until the document is ready for use. * Add a document to the RAG database. * * @param product The product the RAG database belongs to. * @param inputSource The file to upload. * @param parameters The parameters to use for the upload. */ uploadRagDocument

(product: P, inputSource: LocalInputSource, parameters: InstanceType | ConstructorParameters[0]): Promise>; /** * Add a document to the RAG database and return the initial annotation. * * @param product The product the RAG database belongs to. * @param inputSource The file to upload. * @param parameters The parameters to use for the upload. * @param pollingOptions options for the polling loop, see {@link PollingOptions}. */ uploadAndGetRagDocumentPoll

(product: P, inputSource: LocalInputSource, parameters: InstanceType | ConstructorParameters[0], pollingOptions?: PollingOptions | PollingOptionsConstructor): Promise>; /** * Not recommended for general use, prefer `updateAndGetRagAnnotationPoll`. * You will need to poll until the document is ready for use. * Update a document's annotations in the RAG database. * * @param product The product the RAG database belongs to. * @param parameters The parameters to use for the update. */ updateRagAnnotation

(product: P, parameters: InstanceType | ConstructorParameters[0]): Promise>; /** * Update a document's annotations in the RAG database and poll until ready. * * @param product The product the RAG database belongs to. * @param parameters The parameters to use for the update. * @param pollingOptions options for the polling loop, see {@link PollingOptions}. * @returns a `Promise` containing the RAG document annotation. */ updateAndGetRagAnnotationPoll

(product: P, parameters: InstanceType | ConstructorParameters[0], pollingOptions?: PollingOptions | PollingOptionsConstructor): Promise>; /** * Deletes a document from the RAG database. * @param product the product the RAG database belongs to. * @param documentId the document's ID. */ deleteRagDocument

(product: P, documentId: string): Promise; /** * Poll until the document is finished processing or the max number of attempts is reached. * * @param product The product the RAG database belongs to. * @param initialResponse The initial response containing the document's ID. * @param pollingOptions Options for the polling loop, see {@link PollingOptions}. * @returns A `Promise` containing the RAG document annotation. * @protected */ protected pollForRagDocument

(product: P, initialResponse: InstanceType, pollingOptions: PollingOptions): Promise>; }