mindee 5.3.0 → 5.4.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 (33) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.json +3 -3
  3. package/src/image/extractedImages.d.ts +4 -0
  4. package/src/image/extractedImages.js +5 -0
  5. package/src/image/index.d.ts +1 -0
  6. package/src/image/index.js +1 -0
  7. package/src/pdf/extractedPdfs.d.ts +4 -0
  8. package/src/{v2/fileOperations/cropFiles.js → pdf/extractedPdfs.js} +1 -1
  9. package/src/pdf/index.d.ts +2 -0
  10. package/src/pdf/index.js +2 -0
  11. package/src/v2/client.d.ts +10 -0
  12. package/src/v2/client.js +14 -1
  13. package/src/v2/fileOperations/crop.d.ts +4 -4
  14. package/src/v2/fileOperations/crop.js +6 -5
  15. package/src/v2/fileOperations/split.d.ts +3 -3
  16. package/src/v2/fileOperations/split.js +6 -6
  17. package/src/v2/parsing/localResponse.d.ts +17 -5
  18. package/src/v2/parsing/localResponse.js +17 -5
  19. package/src/v2/product/crop/cropItem.d.ts +1 -1
  20. package/src/v2/product/crop/cropItem.js +3 -3
  21. package/src/v2/product/crop/cropResponse.d.ts +0 -8
  22. package/src/v2/product/crop/cropResponse.js +0 -9
  23. package/src/v2/product/crop/cropResult.d.ts +8 -0
  24. package/src/v2/product/crop/cropResult.js +9 -0
  25. package/src/v2/product/split/splitRange.d.ts +2 -1
  26. package/src/v2/product/split/splitRange.js +2 -2
  27. package/src/v2/product/split/splitResponse.d.ts +0 -7
  28. package/src/v2/product/split/splitResponse.js +0 -12
  29. package/src/v2/product/split/splitResult.d.ts +7 -0
  30. package/src/v2/product/split/splitResult.js +12 -0
  31. package/src/v2/fileOperations/cropFiles.d.ts +0 -4
  32. package/src/v2/fileOperations/splitFiles.d.ts +0 -4
  33. package/src/v2/fileOperations/splitFiles.js +0 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Mindee Node.js API Library Changelog
2
2
 
3
+ ## v5.4.0 - 2026-06-22
4
+ ### Fixes
5
+ * :bug: :boom: harmonize Crop and Split extraction (now ready for public use)
6
+
7
+
8
+ ## v5.3.1 - 2026-06-11
9
+ ### Fixes
10
+ * :arrow_up: bump 'tmp' and 'file-type'
11
+ * :bug: :sparkles: get results by URL directly
12
+
13
+
3
14
  ## v5.3.0 - 2026-05-07
4
15
  ### Changes
5
16
  * :sparkles: Add support for extraction in crop, split, and classify products
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "author": {
6
6
  "name": "Mindee",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "commander": "^14.0.3",
51
- "file-type": "^21.3.3",
52
- "tmp": "^0.2.5",
51
+ "file-type": "^21.3.4",
52
+ "tmp": "^0.2.7",
53
53
  "undici": ">=6.24.0 <7.0.0 || >=7.24.0 <8.0.0"
54
54
  },
55
55
  "optionalDependencies": {
@@ -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,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";
@@ -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";
@@ -41,6 +41,16 @@ export declare class Client {
41
41
  * @returns a `Promise` containing the inference.
42
42
  */
43
43
  getResult<P extends typeof BaseProduct>(product: P, inferenceId: string): Promise<InstanceType<P["responseClass"]>>;
44
+ /**
45
+ * Retrieves the result of a previously enqueued request.
46
+ * This method is used when manually polling the server for the result URL.
47
+ *
48
+ * @param product the product to retrieve.
49
+ * @param url URL as given in the `getJob()` response.
50
+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
51
+ * @returns a `Promise` containing the inference.
52
+ */
53
+ getResultByUrl<P extends typeof BaseProduct>(product: P, url: string): Promise<InstanceType<P["responseClass"]>>;
44
54
  /**
45
55
  * Get the processing status of a previously enqueued request.
46
56
  * Can be used for polling.
package/src/v2/client.js CHANGED
@@ -53,6 +53,19 @@ export class Client {
53
53
  logger.debug(`Attempting to get inference with ID: ${inferenceId} using response type: ${product.name}`);
54
54
  return await this.mindeeApi.getProductResultById(product, inferenceId);
55
55
  }
56
+ /**
57
+ * Retrieves the result of a previously enqueued request.
58
+ * This method is used when manually polling the server for the result URL.
59
+ *
60
+ * @param product the product to retrieve.
61
+ * @param url URL as given in the `getJob()` response.
62
+ * @typeParam T an extension of an `Inference`. Can be omitted as it will be inferred from the `productClass`.
63
+ * @returns a `Promise` containing the inference.
64
+ */
65
+ async getResultByUrl(product, url) {
66
+ logger.debug(`Attempting to get inference from: ${url} using response type: ${product.name}`);
67
+ return await this.mindeeApi.getProductResultByUrl(product, url);
68
+ }
56
69
  /**
57
70
  * Get the processing status of a previously enqueued request.
58
71
  * Can be used for polling.
@@ -109,7 +122,7 @@ export class Client {
109
122
  if (!pollResults.job.resultUrl) {
110
123
  throw new MindeeError("The result URL is undefined. This is a server error, try again later or contact support.");
111
124
  }
112
- return this.mindeeApi.getProductResultByUrl(product, pollResults.job.resultUrl);
125
+ return this.getResultByUrl(product, pollResults.job.resultUrl);
113
126
  }
114
127
  await setTimeout(pollingOptions.delaySec * 1000, undefined, pollingOptions.recurringTimerOptions);
115
128
  retryCounter++;
@@ -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,15 @@
1
1
  import { MindeeError } from "../../errors/index.js";
2
2
  import { extractImagesFromPolygon } from "../../image/imageExtractor.js";
3
- import { CropFiles } from "../../v2/fileOperations/cropFiles.js";
3
+ import { ExtractedImages } from "../../image/index.js";
4
4
  import { logger } from "../../logger.js";
5
5
  /**
6
6
  * Extracts a single specified crop from a given input source.
7
7
  * @param inputSource Local input source.
8
8
  * @param crop Crop to extract.
9
+ * @param quality JPEG quality of extracted image.
9
10
  */
10
- export async function extractSingleCrop(inputSource, crop) {
11
- return (await extractCrops(inputSource, [crop]))[0];
11
+ export async function extractSingleCrop(inputSource, crop, quality) {
12
+ return (await extractMultipleCrops(inputSource, [crop], quality))[0];
12
13
  }
13
14
  /**
14
15
  * Extracts a list of crops from a document.
@@ -17,7 +18,7 @@ export async function extractSingleCrop(inputSource, crop) {
17
18
  * @param quality JPEG quality of extracted images.
18
19
  * @return a list of extracted files, as a CropFiles object.
19
20
  */
20
- export async function extractCrops(inputSource, crops, quality) {
21
+ export async function extractMultipleCrops(inputSource, crops, quality) {
21
22
  if (crops.length === 0) {
22
23
  throw new MindeeError("No crop indexes provided.");
23
24
  }
@@ -32,5 +33,5 @@ export async function extractCrops(inputSource, crops, quality) {
32
33
  polygonsByPage.get(pageId).push(crop.location.polygon);
33
34
  }
34
35
  const extractedCrops = await extractImagesFromPolygon(inputSource, polygonsByPage, quality);
35
- return new CropFiles(...extractedCrops);
36
+ return new ExtractedImages(...extractedCrops);
36
37
  }
@@ -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, pageCount));
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.
@@ -7,13 +7,25 @@ import { BaseResponse } from "./baseResponse.js";
7
7
  */
8
8
  export declare class LocalResponse extends LocalResponseBase {
9
9
  /**
10
- * Deserialize the loaded local response into the requested CommonResponse-derived class.
10
+ * Deserialize the loaded local response into a product response class.
11
11
  *
12
- * Typically used when dealing with V2 webhook callbacks.
12
+ * Typically used when dealing with V2 webhook callbacks to parse the raw
13
+ * JSON payload pushed to your endpoint into a typed response object.
13
14
  *
14
- * @typeParam ResponseT - A class that extends `CommonResponse`.
15
- * @param responseClass - The constructor of the class into which the payload should be deserialized.
16
- * @returns An instance of `responseClass` populated with the file content.
15
+ * Pass the response class that matches the product you used when enqueuing
16
+ * the document. All product response classes are exported from the `mindee`
17
+ * package and can be used here:
18
+ *
19
+ * - `mindee.product.ExtractionResponse`
20
+ * - `mindee.product.ClassificationResponse`
21
+ * - `mindee.product.OcrResponse`
22
+ * - `mindee.product.CropResponse`
23
+ * - `mindee.product.SplitResponse`
24
+ *
25
+ * @typeParam ResponseT - A class that extends `BaseResponse`.
26
+ * @param responseClass - The constructor of the product response class into
27
+ * which the payload should be deserialized.
28
+ * @returns An instance of `responseClass` populated with the webhook payload.
17
29
  * @throws MindeeError If the provided class cannot be instantiated.
18
30
  */
19
31
  deserializeResponse<ResponseT extends BaseResponse>(responseClass: new (serverResponse: StringDict) => ResponseT): Promise<ResponseT>;
@@ -6,13 +6,25 @@ import { LocalResponseBase } from "../../parsing/localResponseBase.js";
6
6
  */
7
7
  export class LocalResponse extends LocalResponseBase {
8
8
  /**
9
- * Deserialize the loaded local response into the requested CommonResponse-derived class.
9
+ * Deserialize the loaded local response into a product response class.
10
10
  *
11
- * Typically used when dealing with V2 webhook callbacks.
11
+ * Typically used when dealing with V2 webhook callbacks to parse the raw
12
+ * JSON payload pushed to your endpoint into a typed response object.
12
13
  *
13
- * @typeParam ResponseT - A class that extends `CommonResponse`.
14
- * @param responseClass - The constructor of the class into which the payload should be deserialized.
15
- * @returns An instance of `responseClass` populated with the file content.
14
+ * Pass the response class that matches the product you used when enqueuing
15
+ * the document. All product response classes are exported from the `mindee`
16
+ * package and can be used here:
17
+ *
18
+ * - `mindee.product.ExtractionResponse`
19
+ * - `mindee.product.ClassificationResponse`
20
+ * - `mindee.product.OcrResponse`
21
+ * - `mindee.product.CropResponse`
22
+ * - `mindee.product.SplitResponse`
23
+ *
24
+ * @typeParam ResponseT - A class that extends `BaseResponse`.
25
+ * @param responseClass - The constructor of the product response class into
26
+ * which the payload should be deserialized.
27
+ * @returns An instance of `responseClass` populated with the webhook payload.
16
28
  * @throws MindeeError If the provided class cannot be instantiated.
17
29
  */
18
30
  async deserializeResponse(responseClass) {
@@ -23,5 +23,5 @@ export declare class CropItem {
23
23
  * @param inputSource The input file to extract from.
24
24
  * @param quality Optional quality parameter for image extraction, default is undefined (full quality).
25
25
  */
26
- extractFromFile(inputSource: LocalInputSource, quality?: number): Promise<ExtractedImage>;
26
+ extractFromInputSource(inputSource: LocalInputSource, quality?: number): Promise<ExtractedImage>;
27
27
  }
@@ -1,5 +1,5 @@
1
1
  import { FieldLocation } from "../../../v2/parsing/inference/field/index.js";
2
- import { extractCrops } from "../../../v2/fileOperations/crop.js";
2
+ import { extractSingleCrop } from "../../../v2/fileOperations/crop.js";
3
3
  import { ExtractionResponse } from "../../../v2/product/index.js";
4
4
  export class CropItem {
5
5
  constructor(serverResponse) {
@@ -17,7 +17,7 @@ export class CropItem {
17
17
  * @param inputSource The input file to extract from.
18
18
  * @param quality Optional quality parameter for image extraction, default is undefined (full quality).
19
19
  */
20
- async extractFromFile(inputSource, quality = 1) {
21
- return (await extractCrops(inputSource, [this], quality))[0];
20
+ async extractFromInputSource(inputSource, quality = 1) {
21
+ return (await extractSingleCrop(inputSource, this, quality));
22
22
  }
23
23
  }
@@ -1,6 +1,4 @@
1
- import { LocalInputSource } from "../../../input/index.js";
2
1
  import { StringDict } from "../../../parsing/stringDict.js";
3
- import { CropFiles } from "../../../v2/fileOperations/cropFiles.js";
4
2
  import { BaseResponse } from "../../../v2/parsing/index.js";
5
3
  import { CropInference } from "./cropInference.js";
6
4
  export declare class CropResponse extends BaseResponse {
@@ -12,10 +10,4 @@ export declare class CropResponse extends BaseResponse {
12
10
  * @param serverResponse JSON response from the server.
13
11
  */
14
12
  constructor(serverResponse: StringDict);
15
- /**
16
- * Extracts all crops from an input.
17
- * @param inputSource The input file to extract from.
18
- * @param quality Optional quality parameter for image extraction, default is undefined (full quality).
19
- */
20
- extractFromFile(inputSource: LocalInputSource, quality?: number): Promise<CropFiles>;
21
13
  }
@@ -1,4 +1,3 @@
1
- import { extractCrops } from "../../../v2/fileOperations/crop.js";
2
1
  import { BaseResponse } from "../../../v2/parsing/index.js";
3
2
  import { CropInference } from "./cropInference.js";
4
3
  export class CropResponse extends BaseResponse {
@@ -9,12 +8,4 @@ export class CropResponse extends BaseResponse {
9
8
  super(serverResponse);
10
9
  this.inference = new CropInference(serverResponse["inference"]);
11
10
  }
12
- /**
13
- * Extracts all crops from an input.
14
- * @param inputSource The input file to extract from.
15
- * @param quality Optional quality parameter for image extraction, default is undefined (full quality).
16
- */
17
- async extractFromFile(inputSource, quality = 1) {
18
- return await extractCrops(inputSource, this.inference.result.crops, quality);
19
- }
20
11
  }
@@ -1,5 +1,7 @@
1
1
  import { StringDict } from "../../../parsing/stringDict.js";
2
2
  import { CropItem } from "../../../v2/product/crop/cropItem.js";
3
+ import { LocalInputSource } from "../../../input/index.js";
4
+ import { ExtractedImages } from "../../../image/extractedImages.js";
3
5
  export declare class CropResult {
4
6
  /**
5
7
  * Fields contained in the inference.
@@ -7,4 +9,10 @@ export declare class CropResult {
7
9
  crops: CropItem[];
8
10
  constructor(serverResponse: StringDict);
9
11
  toString(): string;
12
+ /**
13
+ * Extracts a single crop from an input.
14
+ * @param inputSource The input file to extract from.
15
+ * @param quality Optional quality parameter for image extraction, default is undefined (full quality).
16
+ */
17
+ extractFromInputSource(inputSource: LocalInputSource, quality?: number): Promise<ExtractedImages>;
10
18
  }
@@ -1,4 +1,5 @@
1
1
  import { CropItem } from "../../../v2/product/crop/cropItem.js";
2
+ import { extractMultipleCrops } from "../../../v2/fileOperations/crop.js";
2
3
  export class CropResult {
3
4
  constructor(serverResponse) {
4
5
  /**
@@ -11,4 +12,12 @@ export class CropResult {
11
12
  const crops = this.crops.map(item => item.toString()).join("\n");
12
13
  return `Crops\n=====\n${crops}`;
13
14
  }
15
+ /**
16
+ * Extracts a single crop from an input.
17
+ * @param inputSource The input file to extract from.
18
+ * @param quality Optional quality parameter for image extraction, default is undefined (full quality).
19
+ */
20
+ async extractFromInputSource(inputSource, quality = 1) {
21
+ return (await extractMultipleCrops(inputSource, this.crops, quality));
22
+ }
14
23
  }
@@ -1,6 +1,7 @@
1
1
  import { StringDict } from "../../../parsing/index.js";
2
2
  import { LocalInputSource } from "../../../input/index.js";
3
3
  import { ExtractionResponse } from "../../../v2/product/index.js";
4
+ import { ExtractedPdf } from "../../../pdf/index.js";
4
5
  /**
5
6
  * Split inference result.
6
7
  */
@@ -24,5 +25,5 @@ export declare class SplitRange {
24
25
  * Extracts a single split from the input file.
25
26
  * @param inputSource The input file to extract from.
26
27
  */
27
- extractFromFile(inputSource: LocalInputSource): Promise<import("../../../pdf/extractedPdf.js").ExtractedPdf>;
28
+ extractFromFile(inputSource: LocalInputSource): Promise<ExtractedPdf>;
28
29
  }
@@ -1,4 +1,4 @@
1
- import { expandRange, extractSplits } from "../../../v2/fileOperations/split.js";
1
+ import { expandRange, extractMultipleSplits } from "../../../v2/fileOperations/split.js";
2
2
  import { ExtractionResponse } from "../../../v2/product/index.js";
3
3
  /**
4
4
  * Split inference result.
@@ -21,6 +21,6 @@ export class SplitRange {
21
21
  */
22
22
  async extractFromFile(inputSource) {
23
23
  const pageRange = [expandRange(this.pageRange)];
24
- return (await extractSplits(inputSource, pageRange))[0];
24
+ return (await extractMultipleSplits(inputSource, pageRange))[0];
25
25
  }
26
26
  }
@@ -1,8 +1,6 @@
1
1
  import { StringDict } from "../../../parsing/stringDict.js";
2
2
  import { SplitInference } from "./splitInference.js";
3
3
  import { BaseResponse } from "../../../v2/parsing/index.js";
4
- import { LocalInputSource } from "../../../input/index.js";
5
- import { SplitFiles } from "../../../v2/fileOperations/splitFiles.js";
6
4
  export declare class SplitResponse extends BaseResponse {
7
5
  /**
8
6
  * Response for an OCR utility inference.
@@ -12,9 +10,4 @@ export declare class SplitResponse extends BaseResponse {
12
10
  * @param serverResponse JSON response from the server.
13
11
  */
14
12
  constructor(serverResponse: StringDict);
15
- /**
16
- * Extracts all splits from an input PDF.
17
- * @param inputSource The input file to extract from.
18
- */
19
- extractFromFile(inputSource: LocalInputSource): Promise<SplitFiles>;
20
13
  }
@@ -1,6 +1,5 @@
1
1
  import { SplitInference } from "./splitInference.js";
2
2
  import { BaseResponse } from "../../../v2/parsing/index.js";
3
- import { expandRange, extractSplits } from "../../../v2/fileOperations/split.js";
4
3
  export class SplitResponse extends BaseResponse {
5
4
  /**
6
5
  * @param serverResponse JSON response from the server.
@@ -9,15 +8,4 @@ export class SplitResponse extends BaseResponse {
9
8
  super(serverResponse);
10
9
  this.inference = new SplitInference(serverResponse["inference"]);
11
10
  }
12
- /**
13
- * Extracts all splits from an input PDF.
14
- * @param inputSource The input file to extract from.
15
- */
16
- async extractFromFile(inputSource) {
17
- const splits = [];
18
- for (const split of this.inference.result.splits) {
19
- splits.push(expandRange(split.pageRange));
20
- }
21
- return await extractSplits(inputSource, splits);
22
- }
23
11
  }
@@ -1,5 +1,7 @@
1
1
  import { SplitRange } from "./splitRange.js";
2
2
  import { StringDict } from "../../../parsing/index.js";
3
+ import { LocalInputSource } from "../../../input/index.js";
4
+ import { ExtractedPdfs } from "../../../pdf/index.js";
3
5
  /**
4
6
  * Split result info.
5
7
  */
@@ -9,5 +11,10 @@ export declare class SplitResult {
9
11
  */
10
12
  splits: SplitRange[];
11
13
  constructor(rawResponse: StringDict);
14
+ /**
15
+ * Extracts all splits from an input PDF.
16
+ * @param inputSource The input file to extract from.
17
+ */
18
+ extractFromInputSource(inputSource: LocalInputSource): Promise<ExtractedPdfs>;
12
19
  toString(): string;
13
20
  }
@@ -1,4 +1,5 @@
1
1
  import { SplitRange } from "./splitRange.js";
2
+ import { extractMultipleSplits, expandRange } from "../../../v2/fileOperations/split.js";
2
3
  /**
3
4
  * Split result info.
4
5
  */
@@ -6,6 +7,17 @@ export class SplitResult {
6
7
  constructor(rawResponse) {
7
8
  this.splits = rawResponse.splits.map((split) => new SplitRange(split));
8
9
  }
10
+ /**
11
+ * Extracts all splits from an input PDF.
12
+ * @param inputSource The input file to extract from.
13
+ */
14
+ async extractFromInputSource(inputSource) {
15
+ const splits = [];
16
+ for (const split of this.splits) {
17
+ splits.push(expandRange(split.pageRange));
18
+ }
19
+ return await extractMultipleSplits(inputSource, splits);
20
+ }
9
21
  toString() {
10
22
  let splits = "\n";
11
23
  if (this.splits.length > 0) {
@@ -1,4 +0,0 @@
1
- import { ExtractedImage } from "../../image/index.js";
2
- export declare class CropFiles extends Array<ExtractedImage> {
3
- constructor(...items: ExtractedImage[]);
4
- }
@@ -1,4 +0,0 @@
1
- import { ExtractedPdf } from "../../pdf/extractedPdf.js";
2
- export declare class SplitFiles extends Array<ExtractedPdf> {
3
- constructor(...args: ExtractedPdf[]);
4
- }
@@ -1,5 +0,0 @@
1
- export class SplitFiles extends Array {
2
- constructor(...args) {
3
- super(...args);
4
- }
5
- }