@@ -18,7 +18,9 @@ import { MindeeHttpErrorV2 } from "./errors.js";
1818import { logger } from "@/logger.js" ;
1919import { BaseProduct } from "@/v2/product/baseProduct.js" ;
2020
21-
21+ /**
22+ * Mindee V2 API handler.
23+ */
2224export class MindeeApiV2 {
2325 settings : ApiSettings ;
2426
@@ -27,11 +29,10 @@ export class MindeeApiV2 {
2729 }
2830
2931 /**
30- * Sends a file to the extraction inference queue.
32+ * Sends a file to the product inference queue.
3133 * @param product product to enqueue.
3234 * @param inputSource Local file loaded as an input.
3335 * @param params {ExtractionParameters} parameters relating to the enqueueing options.
34- * @category V2
3536 * @throws Error if the server's response contains an error.
3637 * @returns a `Promise` containing a job response.
3738 */
@@ -51,24 +52,22 @@ export class MindeeApiV2 {
5152 }
5253
5354 /**
54- * Requests the results of a queued document from the API .
55+ * Get the specified Job .
5556 * Throws an error if the server's response contains an error.
56- * @param jobId The document's ID in the queue.
57- * @category Asynchronous
58- * @returns a `Promise` containing information on the queue.
57+ * @param jobId The Job ID as returned by the enqueue request.
58+ * @returns a `Promise` containing the job response.
5959 */
6060 async getJob ( jobId : string ) : Promise < JobResponse > {
6161 const response = await this . #reqGetJob( jobId ) ;
6262 return this . #processResponse( response , JobResponse ) ;
6363 }
6464
6565 /**
66- * Requests the job of a queued document from the API.
66+ * Get the result of a queued document from the API.
6767 * Throws an error if the server's response contains an error.
6868 * @param product
69- * @param inferenceId The result's ID in the queue.
70- * @category Asynchronous
71- * @returns a `Promise` containing either the parsed result, or information on the queue.
69+ * @param inferenceId The inference ID for the result.
70+ * @returns a `Promise` containing the parsed result.
7271 */
7372 async getProductResultById < P extends typeof BaseProduct > (
7473 product : P ,
@@ -81,12 +80,11 @@ export class MindeeApiV2 {
8180 }
8281
8382 /**
84- * Requests the job of a queued document from the API.
83+ * Get the result of a queued document from the API.
8584 * Throws an error if the server's response contains an error.
8685 * @param product
87- * @param url The document's ID in the queue.
88- * @category Asynchronous
89- * @returns a `Promise` containing either the parsed result, or information on the queue.
86+ * @param url The URL as returned by a Job's resultUrl property.
87+ * @returns a `Promise` containing the parsed result.
9088 */
9189 async getProductResultByUrl < P extends typeof BaseProduct > (
9290 product : P ,
@@ -130,7 +128,6 @@ export class MindeeApiV2 {
130128
131129 /**
132130 * Sends a document to the inference queue.
133- *
134131 * @param product Product to enqueue.
135132 * @param inputSource Local or remote file as an input.
136133 * @param params {ExtractionParameters} parameters relating to the enqueueing options.
@@ -172,7 +169,6 @@ export class MindeeApiV2 {
172169 /**
173170 * Make a request to GET the status of a document in the queue.
174171 * @param url URL path to the result.
175- * @category Asynchronous
176172 * @returns a `Promise` containing the parsed result.
177173 */
178174 async #reqGetProductResult( url : string ) : Promise < BaseHttpResponse > {
@@ -182,7 +178,7 @@ export class MindeeApiV2 {
182178 timeoutSecs : this . settings . timeoutSecs ,
183179 } ;
184180 if ( ! url . startsWith ( "https://" ) ) {
185- throw new MindeeError ( "URL must start with https://" ) ;
181+ throw new MindeeError ( `Invalid URL: ${ url } ` ) ;
186182 }
187183 return await sendRequestAndReadResponse ( this . settings . dispatcher , options , url ) ;
188184 }
0 commit comments