@@ -21,10 +21,11 @@ import { LOG_LEVELS, logger } from "./logger";
2121import { InferenceFactory } from "./parsing/common/inference" ;
2222import { CustomV1 } from "./product" ;
2323
24+ /**
25+ * Options relating to predictions.
26+ */
2427export interface PredictOptions {
25- endpointName ?: string ;
26- accountName ?: string ;
27- endpointVersion ?: string ;
28+ /** A custom endpoint. */
2829 endpoint ?: Endpoint ;
2930 /**
3031 * Whether to include the full text for each page.
@@ -38,19 +39,11 @@ export interface PredictOptions {
3839 * This performs a cropping operation on the server and will increase response time.
3940 */
4041 cropper ?: boolean ;
41- pageOptions ?: PageOptions ;
42- }
43-
44- export interface CustomConfigParams {
45- /** Your organization's username on the API Builder. */
46- accountName : string ;
47- /** The "API name" field in the "Settings" page of the API Builder. */
48- endpointName : string ;
49- /**
50- * If set, locks the version of the model to use.
51- * If not set, use the latest version of the model.
42+ /**
43+ * If set, remove pages from the document as specified.
44+ * This is done before sending the file to the server and is useful to avoid page limitations.
5245 */
53- version ?: string ;
46+ pageOptions ?: PageOptions ;
5447}
5548
5649export interface ClientOptions {
@@ -63,13 +56,16 @@ export interface ClientOptions {
6356}
6457
6558/**
66- * Mindee Client
59+ * Mindee Client class that centralizes most basic operations.
60+ *
61+ * @category Client
6762 */
6863export class Client {
64+ /** Key of the API. */
6965 protected apiKey : string ;
7066
7167 /**
72- * @param options
68+ * @param options options for the initialization of a client.
7369 */
7470 constructor (
7571 { apiKey, throwOnError, debug } : ClientOptions = {
@@ -89,8 +85,14 @@ export class Client {
8985
9086 /**
9187 * Send a document to a synchronous endpoint and parse the predictions.
92- * @param productClass
93- * @param params
88+ *
89+ * @param productClass product class to use for calling the API and parsing the response.
90+ * @param inputSource document to parse.
91+ * @param params parameters relating to prediction options.
92+ *
93+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
94+ * @category Synchronous
95+ * @returns a `Promise` containing parsing results.
9496 */
9597 async parse < T extends Inference > (
9698 productClass : new ( httpResponse : StringDict ) => T ,
@@ -118,8 +120,11 @@ export class Client {
118120
119121 /**
120122 * Send the document to an asynchronous endpoint and return its ID in the queue.
121- * @param productClass
122- * @param params
123+ * @param productClass product class to use for calling the API and parsing the response.
124+ * @param params parameters relating to prediction options.
125+ * @category Asynchronous
126+ *
127+ * @returns a `Promise` containing the job (queue) corresponding to a document.
123128 */
124129 async enqueue < T extends Inference > (
125130 productClass : new ( httpResponse : StringDict ) => T ,
@@ -141,6 +146,18 @@ export class Client {
141146 return new AsyncPredictResponse < T > ( productClass , rawResponse . data ) ;
142147 }
143148
149+ /**
150+ * Polls a queue and returns its status as well as the prediction results if the parsing is done.
151+ *
152+ * @param productClass product class to use for calling the API and parsing the response.
153+ * @param queueId id of the queue to poll.
154+ * @param params parameters relating to prediction options.
155+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
156+ * @category Asynchronous
157+ *
158+ * @returns a `Promise` containing a `Job`, which also contains a `Document` if the
159+ * parsing is complete.
160+ */
144161 async parseQueued < T extends Inference > (
145162 productClass : new ( httpResponse : StringDict ) => T ,
146163 queueId : string ,
@@ -152,10 +169,22 @@ export class Client {
152169 return new AsyncPredictResponse < T > ( productClass , docResponse . data ) ;
153170 }
154171
172+ /**
173+ * Forces boolean coercion on truthy/falsy parameters.
174+ * @param param input parameter to check.
175+ * @returns a strict boolean value.
176+ */
155177 protected getBooleanParam ( param ?: boolean ) : boolean {
156178 return param !== undefined ? param : false ;
157179 }
158180
181+ /**
182+ * Builds a custom endpoint.
183+ * @param endpointName name of the endpoint.
184+ * @param accountName name of the endpoint's owner.
185+ * @param endpointVersion version of the endpoint.
186+ * @returns a custom `Endpoint` object.
187+ */
159188 #buildEndpoint(
160189 endpointName : string ,
161190 accountName : string ,
@@ -177,10 +206,13 @@ export class Client {
177206
178207 /**
179208 * Creates a custom endpoint with the given values. Raises an error if the endpoint is invalid.
180- * @param productClass Class of the product
181- * @param endpointName Name of a custom Endpoint
182- * @param accountName Name of the account tied to the active Endpoint
183- * @param version Version of a custom Endpoint
209+ * @param productClass product class to use for calling the API and parsing the response.
210+ * @param endpointName Name of the custom Endpoint.
211+ * @param accountName Name of the account tied to the Endpoint.
212+ * @param version Version of the custom Endpoint.
213+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
214+ *
215+ * @returns a new endpoint
184216 */
185217 createEndpoint (
186218 endpointName : string ,
@@ -229,9 +261,11 @@ export class Client {
229261
230262 /**
231263 * Checks that an account name is provided for custom builds, and sets the default one otherwise.
232- * @param productClass Type of product
233- * @param accountName Account name. Only required on custom builds.
234- * @returns {string } The name of the account. Sends an error if one isn't provided for a custom build.
264+ * @param productClass product class to use for calling the API and parsing the response.
265+ * @param accountName name of the account's holder. Only required on custom builds.
266+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
267+ *
268+ * @returns the name of the account. Sends an error if one isn't provided for a custom build.
235269 */
236270 #cleanAccountName< T extends Inference > (
237271 productClass : new ( httpResponse : StringDict ) => T ,
@@ -251,8 +285,10 @@ export class Client {
251285
252286 /**
253287 * Get the name and version of an OTS endpoint.
254- * @param productClass Type of product
255- * @returns {[string, string] } An endpoint's name and version
288+ * @param productClass product class to use for calling the API and parsing the response. Mandatory to retrieve default OTS endpoint data.
289+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
290+ *
291+ * @returns an endpoint's name and version.
256292 */
257293 #getEndpoint< T extends Inference > (
258294 productClass : new ( httpResponse : StringDict ) => T
@@ -274,8 +310,8 @@ export class Client {
274310
275311 /**
276312 * Load an input document from a base64 encoded string.
277- * @param inputString
278- * @param filename
313+ * @param inputString input content, as a string.
314+ * @param filename file name.
279315 */
280316 docFromBase64 ( inputString : string , filename : string ) : InputSource {
281317 return new Base64Input ( {
@@ -286,8 +322,8 @@ export class Client {
286322
287323 /**
288324 * Load an input document from a `stream.Readable` object.
289- * @param inputStream
290- * @param filename
325+ * @param inputStream input content, as a readable stream.
326+ * @param filename file name.
291327 */
292328 docFromStream ( inputStream : Readable , filename : string ) : InputSource {
293329 return new StreamInput ( {
@@ -298,8 +334,8 @@ export class Client {
298334
299335 /**
300336 * Load an input document from a bytes string.
301- * @param inputBytes
302- * @param filename
337+ * @param inputBytes input content, as readable bytes.
338+ * @param filename file name.
303339 */
304340 docFromBytes ( inputBytes : string , filename : string ) : InputSource {
305341 return new BytesInput ( {
@@ -310,7 +346,7 @@ export class Client {
310346
311347 /**
312348 * Load an input document from a URL.
313- * @param url
349+ * @param url input url. Must be HTTPS.
314350 */
315351 docFromUrl ( url : string ) : InputSource {
316352 return new UrlInput ( {
@@ -320,8 +356,8 @@ export class Client {
320356
321357 /**
322358 * Load an input document from a Buffer.
323- * @param buffer
324- * @param filename
359+ * @param buffer input content, as a buffer.
360+ * @param filename file name.
325361 */
326362 docFromBuffer ( buffer : Buffer , filename : string ) : InputSource {
327363 return new BufferInput ( {
0 commit comments