mindee 5.3.1 → 5.5.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/src/http/apiCore.d.ts +1 -0
  4. package/src/http/apiCore.js +21 -3
  5. package/src/image/extractedImage.d.ts +5 -5
  6. package/src/image/extractedImage.js +2 -2
  7. package/src/image/extractedImages.d.ts +4 -0
  8. package/src/image/extractedImages.js +5 -0
  9. package/src/image/imageExtractor.d.ts +2 -2
  10. package/src/image/imageExtractor.js +4 -3
  11. package/src/image/index.d.ts +1 -0
  12. package/src/image/index.js +1 -0
  13. package/src/pdf/extractedPdf.d.ts +3 -2
  14. package/src/pdf/extractedPdf.js +4 -3
  15. package/src/pdf/extractedPdfs.d.ts +4 -0
  16. package/src/{v2/fileOperations/cropFiles.js → pdf/extractedPdfs.js} +1 -1
  17. package/src/pdf/index.d.ts +2 -0
  18. package/src/pdf/index.js +2 -0
  19. package/src/pdf/pdfExtractor.d.ts +2 -2
  20. package/src/pdf/pdfExtractor.js +1 -1
  21. package/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.d.ts +3 -3
  22. package/src/v1/extraction/invoiceSplitterExtractor/extractedInvoiceSplitterImage.js +4 -4
  23. package/src/v1/extraction/multiReceiptsExtractor/extractedMultiReceiptImage.js +1 -1
  24. package/src/v2/client.d.ts +9 -1
  25. package/src/v2/client.js +17 -8
  26. package/src/v2/clientOptions/baseParameters.d.ts +3 -2
  27. package/src/v2/clientOptions/pollingOptions.d.ts +1 -1
  28. package/src/v2/clientOptions/pollingOptions.js +2 -2
  29. package/src/v2/fileOperations/crop.d.ts +4 -4
  30. package/src/v2/fileOperations/crop.js +5 -6
  31. package/src/v2/fileOperations/split.d.ts +3 -3
  32. package/src/v2/fileOperations/split.js +6 -6
  33. package/src/v2/http/mindeeApiV2.d.ts +23 -10
  34. package/src/v2/http/mindeeApiV2.js +79 -68
  35. package/src/v2/parsing/search/index.d.ts +4 -0
  36. package/src/v2/parsing/search/index.js +4 -0
  37. package/src/v2/parsing/search/modelWebhook.d.ts +19 -0
  38. package/src/v2/parsing/search/modelWebhook.js +10 -0
  39. package/src/v2/parsing/search/paginationMetadata.d.ts +24 -0
  40. package/src/v2/parsing/search/paginationMetadata.js +19 -0
  41. package/src/v2/parsing/search/searchModel.d.ts +25 -0
  42. package/src/v2/parsing/search/searchModel.js +19 -0
  43. package/src/v2/parsing/search/searchResponse.d.ts +19 -0
  44. package/src/v2/parsing/search/searchResponse.js +24 -0
  45. package/src/v2/product/crop/cropItem.d.ts +1 -1
  46. package/src/v2/product/crop/cropItem.js +3 -3
  47. package/src/v2/product/crop/cropResponse.d.ts +0 -8
  48. package/src/v2/product/crop/cropResponse.js +0 -9
  49. package/src/v2/product/crop/cropResult.d.ts +8 -0
  50. package/src/v2/product/crop/cropResult.js +9 -0
  51. package/src/v2/product/split/splitRange.d.ts +2 -1
  52. package/src/v2/product/split/splitRange.js +2 -2
  53. package/src/v2/product/split/splitResponse.d.ts +0 -7
  54. package/src/v2/product/split/splitResponse.js +0 -12
  55. package/src/v2/product/split/splitResult.d.ts +7 -0
  56. package/src/v2/product/split/splitResult.js +12 -0
  57. package/src/v2/fileOperations/cropFiles.d.ts +0 -4
  58. package/src/v2/fileOperations/splitFiles.d.ts +0 -4
  59. package/src/v2/fileOperations/splitFiles.js +0 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Mindee Node.js API Library Changelog
2
2
 
3
+ ## v5.5.0 - 2026-07-01
4
+ ### Fixes
5
+ * :memo: minor tweak to SKILL file
6
+ * :bug: retry once on connection error
7
+ * :recycle: rework and fix extractors (:boom: some **undocumented** functions break)
8
+
9
+
10
+ ## v5.4.0 - 2026-06-22
11
+ ### Fixes
12
+ * :bug: :boom: harmonize Crop and Split extraction (now ready for public use)
13
+
14
+
3
15
  ## v5.3.1 - 2026-06-11
4
16
  ### Fixes
5
17
  * :arrow_up: bump 'tmp' and 'file-type'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.3.1",
3
+ "version": "5.5.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "author": {
6
6
  "name": "Mindee",
@@ -8,6 +8,7 @@ export interface RequestOptions {
8
8
  timeoutSecs: number;
9
9
  headers: any;
10
10
  body?: FormData | string;
11
+ queryParams?: Record<string, string>;
11
12
  }
12
13
  export interface BaseHttpResponse {
13
14
  messageObj: any;
@@ -20,14 +20,32 @@ export async function cutDocPages(inputDoc, pageOptions) {
20
20
  * @returns the processed request.
21
21
  */
22
22
  export async function sendRequestAndReadResponse(dispatcher, options, url) {
23
- url ?? (url = `https://${options.hostname}${options.path}`);
24
- const response = await request(url, {
23
+ const requestUrl = new URL(url ?? `https://${options.hostname}${options.path}`);
24
+ if (options.queryParams) {
25
+ for (const [key, value] of Object.entries(options.queryParams)) {
26
+ requestUrl.searchParams.set(key, value);
27
+ }
28
+ }
29
+ const requestParams = {
25
30
  method: options.method,
26
31
  headers: options.headers,
27
32
  headersTimeout: options.timeoutSecs * 1000,
28
33
  body: options.body,
29
34
  dispatcher: dispatcher,
30
- });
35
+ };
36
+ let response;
37
+ try {
38
+ response = await request(requestUrl, requestParams);
39
+ }
40
+ catch (err) {
41
+ // shenanigans in networking or freezing/thawing of the process in serverless environments
42
+ if (err.code === "UND_ERR_SOCKET" || err.code === "UND_ERR_CONNECT_TIMEOUT" || err.code === "ECONNRESET") {
43
+ logger.warn(`Socket error (${err.code}), retrying with a fresh connection...`);
44
+ response = await request(requestUrl, requestParams);
45
+ }
46
+ else
47
+ throw err;
48
+ }
31
49
  logger.debug("Parsing the response ...");
32
50
  let responseBody = await response.body.text();
33
51
  // handle empty responses from server, for example, in the case of redirects
@@ -1,14 +1,14 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import { BufferInput } from "../input/index.js";
3
3
  /**
4
- * Generic class for image extraction
4
+ * Generic class for image extraction.
5
5
  */
6
6
  export declare class ExtractedImage {
7
7
  buffer: Buffer;
8
8
  filename: string;
9
- pageId?: number;
10
- elementId?: number;
11
- constructor(buffer: Uint8Array, fileName: string, pageId?: number, elementId?: number);
9
+ readonly pageId: number;
10
+ readonly elementId: number;
11
+ constructor(buffer: Uint8Array, fileName: string, pageId: number, elementId: number);
12
12
  /**
13
13
  * Saves the document to a file.
14
14
  *
@@ -27,5 +27,5 @@ export declare class ExtractedImage {
27
27
  *
28
28
  * @returns A BufferInput source.
29
29
  */
30
- asSource(): BufferInput;
30
+ asInputSource(): BufferInput;
31
31
  }
@@ -7,7 +7,7 @@ import { BufferInput, MIMETYPES } from "../input/index.js";
7
7
  import { logger } from "../logger.js";
8
8
  import { loadOptionalDependency } from "../dependency/index.js";
9
9
  /**
10
- * Generic class for image extraction
10
+ * Generic class for image extraction.
11
11
  */
12
12
  export class ExtractedImage {
13
13
  constructor(buffer, fileName, pageId, elementId) {
@@ -92,7 +92,7 @@ export class ExtractedImage {
92
92
  *
93
93
  * @returns A BufferInput source.
94
94
  */
95
- asSource() {
95
+ asInputSource() {
96
96
  return new BufferInput({
97
97
  buffer: this.buffer,
98
98
  filename: this.filename,
@@ -0,0 +1,4 @@
1
+ import { ExtractedImage } from "../image/index.js";
2
+ export declare class ExtractedImages extends Array<ExtractedImage> {
3
+ constructor(...items: ExtractedImage[]);
4
+ }
@@ -0,0 +1,5 @@
1
+ export class ExtractedImages extends Array {
2
+ constructor(...items) {
3
+ super(...items);
4
+ }
5
+ }
@@ -1,5 +1,5 @@
1
1
  import { Polygon } from "../geometry/index.js";
2
- import { ExtractedImage } from "../image/extractedImage.js";
2
+ import { ExtractedImages } from "../image/extractedImages.js";
3
3
  import { LocalInputSource } from "../input/index.js";
4
4
  import type * as pdfLibTypes from "@cantoo/pdf-lib";
5
5
  /**
@@ -8,7 +8,7 @@ import type * as pdfLibTypes from "@cantoo/pdf-lib";
8
8
  * @param polygonsPerPage List of polygons to extract from per page.
9
9
  * @param quality JPEG quality of extracted images.
10
10
  */
11
- export declare function extractImagesFromPolygon(inputSource: LocalInputSource, polygonsPerPage: Map<number, Polygon[]>, quality?: number): Promise<ExtractedImage[]>;
11
+ export declare function extractImagesFromPolygon(inputSource: LocalInputSource, polygonsPerPage: Map<number, Polygon[]>, quality?: number): Promise<ExtractedImages>;
12
12
  /**
13
13
  * Extracts elements from a page based off of a list of bounding boxes.
14
14
  *
@@ -3,6 +3,7 @@ import { MindeeImageError } from "../errors/index.js";
3
3
  import { getMinMaxX, getMinMaxY } from "../geometry/index.js";
4
4
  import { adjustForRotation } from "../geometry/polygonUtils.js";
5
5
  import { ExtractedImage } from "../image/extractedImage.js";
6
+ import { ExtractedImages } from "../image/extractedImages.js";
6
7
  import { logger } from "../logger.js";
7
8
  import { createPdfFromInputSource } from "../pdf/pdfOperation.js";
8
9
  import { rasterizePage } from "../pdf/pdfUtils.js";
@@ -21,13 +22,13 @@ async function getPdfLib() {
21
22
  * @param quality JPEG quality of extracted images.
22
23
  */
23
24
  export async function extractImagesFromPolygon(inputSource, polygonsPerPage, quality) {
24
- const allExtractedImages = [];
25
+ const allExtractedImages = new ExtractedImages();
25
26
  const pdfDoc = await createPdfFromInputSource(inputSource);
26
27
  for (const [pageId, polygons] of polygonsPerPage) {
27
28
  logger.debug(`Extracting images from page ${pageId}`);
28
29
  const pdfPage = pdfDoc.getPage(pageId);
29
- const extractions = (await extractFromPage(pdfPage, polygons, true, quality));
30
- const extractedImages = extractions.map((v, i) => new ExtractedImage(v, inputSource.filename + `_page${pageId}-${i}.jpg`, pageId, i));
30
+ const extractions = await extractFromPage(pdfPage, polygons, true, quality);
31
+ const extractedImages = extractions.map((buffer, elementId) => new ExtractedImage(buffer, inputSource.filename + `_page-${pageId}-item-${elementId}.jpg`, pageId, elementId));
31
32
  allExtractedImages.push(...extractedImages);
32
33
  }
33
34
  return allExtractedImages;
@@ -1,3 +1,4 @@
1
1
  export { compressImage } from "./imageCompressor.js";
2
2
  export { ExtractedImage } from "./extractedImage.js";
3
+ export { ExtractedImages } from "./extractedImages.js";
3
4
  export { extractFromPage } from "./imageExtractor.js";
@@ -1,3 +1,4 @@
1
1
  export { compressImage } from "./imageCompressor.js";
2
2
  export { ExtractedImage } from "./extractedImage.js";
3
+ export { ExtractedImages } from "./extractedImages.js";
3
4
  export { extractFromPage } from "./imageExtractor.js";
@@ -4,7 +4,8 @@ export declare class ExtractedPdf {
4
4
  readonly buffer: Buffer;
5
5
  readonly filename: string;
6
6
  readonly pageCount: number;
7
- constructor(pdfData: Buffer<ArrayBufferLike>, filename: string, pageCount: number);
7
+ readonly pageIndexes: number[];
8
+ constructor(pdfData: Buffer<ArrayBufferLike>, filename: string, pageIndexes: number[]);
8
9
  /**
9
10
  * Saves the document to a file.
10
11
  *
@@ -21,5 +22,5 @@ export declare class ExtractedPdf {
21
22
  *
22
23
  * @returns A BufferInput source.
23
24
  */
24
- asSource(): BufferInput;
25
+ asInputSource(): BufferInput;
25
26
  }
@@ -5,10 +5,11 @@ import { writeFile } from "fs/promises";
5
5
  import { logger } from "../logger.js";
6
6
  import { writeFileSync } from "node:fs";
7
7
  export class ExtractedPdf {
8
- constructor(pdfData, filename, pageCount) {
8
+ constructor(pdfData, filename, pageIndexes) {
9
9
  this.buffer = pdfData;
10
10
  this.filename = filename;
11
- this.pageCount = pageCount;
11
+ this.pageCount = pageIndexes.length;
12
+ this.pageIndexes = pageIndexes;
12
13
  }
13
14
  /**
14
15
  * Saves the document to a file.
@@ -56,7 +57,7 @@ export class ExtractedPdf {
56
57
  *
57
58
  * @returns A BufferInput source.
58
59
  */
59
- asSource() {
60
+ asInputSource() {
60
61
  return new BufferInput({
61
62
  buffer: this.buffer,
62
63
  filename: this.filename,
@@ -0,0 +1,4 @@
1
+ import { ExtractedPdf } from "../pdf/extractedPdf.js";
2
+ export declare class ExtractedPdfs extends Array<ExtractedPdf> {
3
+ constructor(...items: ExtractedPdf[]);
4
+ }
@@ -1,4 +1,4 @@
1
- export class CropFiles extends Array {
1
+ export class ExtractedPdfs extends Array {
2
2
  constructor(...items) {
3
3
  super(...items);
4
4
  }
@@ -2,3 +2,5 @@ export { extractPages, countPages } from "./pdfOperation.js";
2
2
  export type { SplitPdf } from "./pdfOperation.js";
3
3
  export { compressPdf } from "./pdfCompressor.js";
4
4
  export { hasSourceText } from "./pdfUtils.js";
5
+ export { ExtractedPdf } from "./extractedPdf.js";
6
+ export { ExtractedPdfs } from "./extractedPdfs.js";
package/src/pdf/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export { extractPages, countPages } from "./pdfOperation.js";
2
2
  export { compressPdf } from "./pdfCompressor.js";
3
3
  export { hasSourceText } from "./pdfUtils.js";
4
+ export { ExtractedPdf } from "./extractedPdf.js";
5
+ export { ExtractedPdfs } from "./extractedPdfs.js";
@@ -1,5 +1,5 @@
1
1
  import { LocalInputSource } from "../input/index.js";
2
- import { ExtractedPdf } from "../pdf/extractedPdf.js";
2
+ import { ExtractedPdfs } from "../pdf/extractedPdfs.js";
3
3
  export declare class PdfExtractor {
4
4
  /**
5
5
  * Buffer containing the PDF data.
@@ -42,5 +42,5 @@ export declare class PdfExtractor {
42
42
  * Extracts pages from the PDF.
43
43
  * @param pageIndexes
44
44
  */
45
- extractSubDocuments(pageIndexes: number[][]): Promise<ExtractedPdf[]>;
45
+ extractSubDocuments(pageIndexes: number[][]): Promise<ExtractedPdfs>;
46
46
  }
@@ -121,7 +121,7 @@ export class PdfExtractor {
121
121
  const endPage = String(pageRange[pageRange.length - 1] + 1).padStart(3, "0");
122
122
  const fieldFilename = `${splitName}_page_${startPage}-${endPage}.pdf`;
123
123
  const page = await extractPages(this.sourcePdf, pageOptions);
124
- this.extractedPdfs.push(new ExtractedPdf(page.file, fieldFilename, pageRange.length));
124
+ this.extractedPdfs.push(new ExtractedPdf(page.file, fieldFilename, pageRange));
125
125
  }
126
126
  return this.extractedPdfs;
127
127
  }
@@ -1,9 +1,9 @@
1
- import { ExtractedImage } from "../../../image/extractedImage.js";
1
+ import { ExtractedPdf } from "../../../pdf/index.js";
2
2
  /**
3
3
  * Wrapper class for extracted invoice pages.
4
4
  */
5
- export declare class ExtractedInvoiceSplitterImage extends ExtractedImage {
5
+ export declare class ExtractedInvoiceSplitterImage extends ExtractedPdf {
6
6
  readonly pageIdMin: number;
7
7
  readonly pageIdMax: number;
8
- constructor(buffer: Uint8Array, pageIndices: [number, number]);
8
+ constructor(bytes: Uint8Array, pageIndices: [number, number]);
9
9
  }
@@ -1,10 +1,10 @@
1
- import { ExtractedImage } from "../../../image/extractedImage.js";
1
+ import { ExtractedPdf } from "../../../pdf/index.js";
2
2
  /**
3
3
  * Wrapper class for extracted invoice pages.
4
4
  */
5
- export class ExtractedInvoiceSplitterImage extends ExtractedImage {
6
- constructor(buffer, pageIndices) {
7
- super(buffer, `invoice_p_${pageIndices[0]}-${pageIndices[1]}.pdf`);
5
+ export class ExtractedInvoiceSplitterImage extends ExtractedPdf {
6
+ constructor(bytes, pageIndices) {
7
+ super(Buffer.from(bytes), `invoice_p_${pageIndices[0]}-${pageIndices[1]}.pdf`, pageIndices);
8
8
  this.pageIdMin = pageIndices[0];
9
9
  this.pageIdMax = pageIndices[1];
10
10
  }
@@ -4,7 +4,7 @@ import { ExtractedImage } from "../../../image/index.js";
4
4
  */
5
5
  export class ExtractedMultiReceiptImage extends ExtractedImage {
6
6
  constructor(buffer, pageId, receiptId) {
7
- super(buffer, `receipt_p${pageId}_${receiptId}.pdf`);
7
+ super(buffer, `receipt_p${pageId}_${receiptId}.pdf`, pageId, receiptId);
8
8
  this.pageId = pageId;
9
9
  this.receiptId = receiptId;
10
10
  }
@@ -1,6 +1,7 @@
1
1
  import { Dispatcher } from "undici";
2
2
  import { InputSource } from "../input/index.js";
3
3
  import { JobResponse } from "./parsing/index.js";
4
+ import { SearchResponse } from "./parsing/search/index.js";
4
5
  import { MindeeApiV2 } from "./http/mindeeApiV2.js";
5
6
  import { PollingOptions, PollingOptionsConstructor } from "./clientOptions/index.js";
6
7
  import { BaseProduct } from "../v2/product/baseProduct.js";
@@ -31,6 +32,13 @@ export declare class Client {
31
32
  * @param {ClientOptions} options options for the initialization of a client.
32
33
  */
33
34
  constructor({ apiKey, debug, dispatcher }?: ClientOptions);
35
+ /**
36
+ * Search for models available to the account.
37
+ * @param name Optional name filter.
38
+ * @param modelType Optional model type filter.
39
+ * @returns a `Promise` containing the search response.
40
+ */
41
+ searchModels(name?: string, modelType?: string): Promise<SearchResponse>;
34
42
  enqueue<P extends typeof BaseProduct>(product: P, inputSource: InputSource, params: InstanceType<P["parametersClass"]> | ConstructorParameters<P["parametersClass"]>[0]): Promise<JobResponse>;
35
43
  /**
36
44
  * Retrieves the result of a previously enqueued request.
@@ -79,5 +87,5 @@ export declare class Client {
79
87
  * until the maximum number of tries is reached.
80
88
  * @protected
81
89
  */
82
- protected pollForResult<P extends typeof BaseProduct>(product: typeof BaseProduct, pollingOptions: PollingOptions, jobId: string): Promise<InstanceType<P["responseClass"]>>;
90
+ protected pollForResult<P extends typeof BaseProduct>(product: typeof BaseProduct, pollingOptions: PollingOptions, jobResponse: JobResponse): Promise<InstanceType<P["responseClass"]>>;
83
91
  }
package/src/v2/client.js CHANGED
@@ -25,6 +25,15 @@ export class Client {
25
25
  : LOG_LEVELS["warn"];
26
26
  logger.debug("Client V2 Initialized");
27
27
  }
28
+ /**
29
+ * Search for models available to the account.
30
+ * @param name Optional name filter.
31
+ * @param modelType Optional model type filter.
32
+ * @returns a `Promise` containing the search response.
33
+ */
34
+ async searchModels(name, modelType) {
35
+ return await this.mindeeApi.reqGetSearchModel(name, modelType);
36
+ }
28
37
  async enqueue(product, inputSource, params) {
29
38
  if (inputSource === undefined) {
30
39
  throw new MindeeError("An input document is required.");
@@ -33,7 +42,7 @@ export class Client {
33
42
  ? params
34
43
  : new product.parametersClass(params);
35
44
  await inputSource.init();
36
- const jobResponse = await this.mindeeApi.enqueueProduct(product, inputSource, paramsInstance);
45
+ const jobResponse = await this.mindeeApi.reqPostProductEnqueue(product, inputSource, paramsInstance);
37
46
  if (jobResponse.job.id === undefined || jobResponse.job.id.length === 0) {
38
47
  logger.error(`Failed enqueueing:\n${jobResponse.getRawHttp()}`);
39
48
  throw new MindeeError("Enqueueing of the document failed.");
@@ -51,7 +60,7 @@ export class Client {
51
60
  */
52
61
  async getResult(product, inferenceId) {
53
62
  logger.debug(`Attempting to get inference with ID: ${inferenceId} using response type: ${product.name}`);
54
- return await this.mindeeApi.getProductResultById(product, inferenceId);
63
+ return await this.mindeeApi.reqGetProductResultById(product, inferenceId);
55
64
  }
56
65
  /**
57
66
  * Retrieves the result of a previously enqueued request.
@@ -64,7 +73,7 @@ export class Client {
64
73
  */
65
74
  async getResultByUrl(product, url) {
66
75
  logger.debug(`Attempting to get inference from: ${url} using response type: ${product.name}`);
67
- return await this.mindeeApi.getProductResultByUrl(product, url);
76
+ return await this.mindeeApi.reqGetProductResultByUrl(product, url);
68
77
  }
69
78
  /**
70
79
  * Get the processing status of a previously enqueued request.
@@ -76,7 +85,7 @@ export class Client {
76
85
  * parsing is complete.
77
86
  */
78
87
  async getJob(jobId) {
79
- return await this.mindeeApi.getJob(jobId);
88
+ return await this.mindeeApi.reqGetJobById(jobId);
80
89
  }
81
90
  /**
82
91
  * Enqueue a request and poll the server until the result is sent or
@@ -94,22 +103,22 @@ export class Client {
94
103
  const paramsInstance = new product.parametersClass(params);
95
104
  const pollingOptionsInstance = new PollingOptions(pollingOptions);
96
105
  const jobResponse = await this.enqueue(product, inputSource, paramsInstance);
97
- return await this.pollForResult(product, pollingOptionsInstance, jobResponse.job.id);
106
+ return await this.pollForResult(product, pollingOptionsInstance, jobResponse);
98
107
  }
99
108
  /**
100
109
  * Send a document to an endpoint and poll the server until the result is sent or
101
110
  * until the maximum number of tries is reached.
102
111
  * @protected
103
112
  */
104
- async pollForResult(product, pollingOptions, jobId) {
113
+ async pollForResult(product, pollingOptions, jobResponse) {
105
114
  logger.debug(`Waiting ${pollingOptions.initialDelaySec} seconds before polling.`);
106
115
  await setTimeout(pollingOptions.initialDelaySec * 1000, undefined, pollingOptions.initialTimerOptions);
107
- logger.debug(`Start polling for inference using job ID: ${jobId}.`);
116
+ logger.debug(`Start polling for inference using job ID: ${jobResponse.job.id}.`);
108
117
  let retryCounter = 1;
109
118
  let pollResults;
110
119
  while (retryCounter < pollingOptions.maxRetries + 1) {
111
120
  logger.debug(`Attempt ${retryCounter} of ${pollingOptions.maxRetries}`);
112
- pollResults = await this.getJob(jobId);
121
+ pollResults = await this.mindeeApi.reqGetJobByUrl(jobResponse.job.pollingUrl);
113
122
  const error = pollResults.job.error;
114
123
  if (error) {
115
124
  throw new MindeeHttpErrorV2(error);
@@ -28,8 +28,9 @@ export declare abstract class BaseParameters {
28
28
  */
29
29
  modelId: string;
30
30
  /**
31
- * Use an alias to link the file to your own DB.
32
- * If empty, no alias will be used.
31
+ * Optional: a free-form string to tag the request with your own identifier.
32
+ * For example, an internal document ID, reference number, or database key.
33
+ * If set, it will be included in the job and result responses.
33
34
  */
34
35
  alias?: string;
35
36
  /**
@@ -51,6 +51,6 @@ export declare class PollingOptions {
51
51
  /** Options passed to every recurring `setTimeout()`. */
52
52
  recurringTimerOptions?: TimerOptions;
53
53
  constructor(params?: PollingOptionsConstructor);
54
- validateOptions(): void;
54
+ validateSettings(): void;
55
55
  toString(): string;
56
56
  }
@@ -62,10 +62,10 @@ export class PollingOptions {
62
62
  if (params.recurringTimerOptions) {
63
63
  this.recurringTimerOptions = params.recurringTimerOptions;
64
64
  }
65
- this.validateOptions();
65
+ this.validateSettings();
66
66
  logger.debug(`Polling options initialized: ${this.toString()}`);
67
67
  }
68
- validateOptions() {
68
+ validateSettings() {
69
69
  if (this.delaySec < minDelaySec) {
70
70
  throw new MindeeConfigurationError(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`);
71
71
  }
@@ -1,13 +1,13 @@
1
1
  import { LocalInputSource } from "../../input/index.js";
2
2
  import { CropItem } from "../../v2/product/crop/index.js";
3
- import { CropFiles } from "../../v2/fileOperations/cropFiles.js";
4
- import { ExtractedImage } from "../../image/index.js";
3
+ import { ExtractedImage, ExtractedImages } from "../../image/index.js";
5
4
  /**
6
5
  * Extracts a single specified crop from a given input source.
7
6
  * @param inputSource Local input source.
8
7
  * @param crop Crop to extract.
8
+ * @param quality JPEG quality of extracted image.
9
9
  */
10
- export declare function extractSingleCrop(inputSource: LocalInputSource, crop: CropItem): Promise<ExtractedImage>;
10
+ export declare function extractSingleCrop(inputSource: LocalInputSource, crop: CropItem, quality?: number): Promise<ExtractedImage>;
11
11
  /**
12
12
  * Extracts a list of crops from a document.
13
13
  * @param inputSource Local input source.
@@ -15,4 +15,4 @@ export declare function extractSingleCrop(inputSource: LocalInputSource, crop: C
15
15
  * @param quality JPEG quality of extracted images.
16
16
  * @return a list of extracted files, as a CropFiles object.
17
17
  */
18
- export declare function extractCrops(inputSource: LocalInputSource, crops: CropItem[], quality?: number): Promise<CropFiles>;
18
+ export declare function extractMultipleCrops(inputSource: LocalInputSource, crops: CropItem[], quality?: number): Promise<ExtractedImages>;
@@ -1,14 +1,14 @@
1
1
  import { MindeeError } from "../../errors/index.js";
2
2
  import { extractImagesFromPolygon } from "../../image/imageExtractor.js";
3
- import { CropFiles } from "../../v2/fileOperations/cropFiles.js";
4
3
  import { logger } from "../../logger.js";
5
4
  /**
6
5
  * Extracts a single specified crop from a given input source.
7
6
  * @param inputSource Local input source.
8
7
  * @param crop Crop to extract.
8
+ * @param quality JPEG quality of extracted image.
9
9
  */
10
- export async function extractSingleCrop(inputSource, crop) {
11
- return (await extractCrops(inputSource, [crop]))[0];
10
+ export async function extractSingleCrop(inputSource, crop, quality) {
11
+ return (await extractMultipleCrops(inputSource, [crop], quality))[0];
12
12
  }
13
13
  /**
14
14
  * Extracts a list of crops from a document.
@@ -17,7 +17,7 @@ export async function extractSingleCrop(inputSource, crop) {
17
17
  * @param quality JPEG quality of extracted images.
18
18
  * @return a list of extracted files, as a CropFiles object.
19
19
  */
20
- export async function extractCrops(inputSource, crops, quality) {
20
+ export async function extractMultipleCrops(inputSource, crops, quality) {
21
21
  if (crops.length === 0) {
22
22
  throw new MindeeError("No crop indexes provided.");
23
23
  }
@@ -31,6 +31,5 @@ export async function extractCrops(inputSource, crops, quality) {
31
31
  }
32
32
  polygonsByPage.get(pageId).push(crop.location.polygon);
33
33
  }
34
- const extractedCrops = await extractImagesFromPolygon(inputSource, polygonsByPage, quality);
35
- return new CropFiles(...extractedCrops);
34
+ return await extractImagesFromPolygon(inputSource, polygonsByPage, quality);
36
35
  }
@@ -1,11 +1,11 @@
1
1
  import { LocalInputSource } from "../../input/index.js";
2
- import { SplitFiles } from "../../v2/fileOperations/splitFiles.js";
2
+ import { ExtractedPdfs } from "../../pdf/extractedPdfs.js";
3
3
  /**
4
4
  * Extracts a single specified split from a
5
5
  * @param inputSource
6
6
  * @param split
7
7
  */
8
- export declare function extractSingleSplit(inputSource: LocalInputSource, split: number[]): Promise<SplitFiles>;
8
+ export declare function extractSingleSplit(inputSource: LocalInputSource, split: number[]): Promise<ExtractedPdfs>;
9
9
  /**
10
10
  * Extracts splits as complete PDFs from the document.
11
11
  * @param inputSource Local input source.
@@ -13,7 +13,7 @@ export declare function extractSingleSplit(inputSource: LocalInputSource, split:
13
13
  * @return a list of extracted files.
14
14
  * @throws MindeeError if no indexes are provided.
15
15
  */
16
- export declare function extractSplits(inputSource: LocalInputSource, splits: number[][]): Promise<SplitFiles>;
16
+ export declare function extractMultipleSplits(inputSource: LocalInputSource, splits: number[][]): Promise<ExtractedPdfs>;
17
17
  /**
18
18
  * Expands a range of pages into a list of page indexes.
19
19
  * @param range start and end of the page range
@@ -1,15 +1,15 @@
1
1
  import { MindeeError } from "../../errors/index.js";
2
2
  import { PdfExtractor } from "../../pdf/pdfExtractor.js";
3
- import { SplitFiles } from "../../v2/fileOperations/splitFiles.js";
4
3
  import { logger } from "../../logger.js";
5
4
  import { ExtractedPdf } from "../../pdf/extractedPdf.js";
5
+ import { ExtractedPdfs } from "../../pdf/extractedPdfs.js";
6
6
  /**
7
7
  * Extracts a single specified split from a
8
8
  * @param inputSource
9
9
  * @param split
10
10
  */
11
11
  export async function extractSingleSplit(inputSource, split) {
12
- return await extractSplits(inputSource, [split]);
12
+ return await extractMultipleSplits(inputSource, [split]);
13
13
  }
14
14
  /**
15
15
  * Extracts splits as complete PDFs from the document.
@@ -18,7 +18,7 @@ export async function extractSingleSplit(inputSource, split) {
18
18
  * @return a list of extracted files.
19
19
  * @throws MindeeError if no indexes are provided.
20
20
  */
21
- export async function extractSplits(inputSource, splits) {
21
+ export async function extractMultipleSplits(inputSource, splits) {
22
22
  const pageGroups = splits.filter(e => e.length > 0);
23
23
  if (pageGroups.length === 0) {
24
24
  throw new MindeeError("No valid split indexes provided.");
@@ -28,14 +28,14 @@ export async function extractSplits(inputSource, splits) {
28
28
  const pdfExtractor = new PdfExtractor(inputSource);
29
29
  await pdfExtractor.init();
30
30
  if (splits.length === 0) {
31
- return new SplitFiles();
31
+ return new ExtractedPdfs();
32
32
  }
33
33
  const pageCount = await pdfExtractor.getPageCount();
34
34
  if (splits.length === 1 && splits[0].at(-1) === pageCount - 1) {
35
- return new SplitFiles(new ExtractedPdf(inputSource.fileObject, inputSource.filename, pageCount));
35
+ return new ExtractedPdfs(new ExtractedPdf(inputSource.fileObject, inputSource.filename, splits[0]));
36
36
  }
37
37
  const subDocuments = await pdfExtractor.extractSubDocuments(pageGroups);
38
- return new SplitFiles(...subDocuments);
38
+ return new ExtractedPdfs(...subDocuments);
39
39
  }
40
40
  /**
41
41
  * Expands a range of pages into a list of page indexes.