mindee 4.17.1 → 4.18.1

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 (67) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.json +12 -15
  3. package/src/cli.js +5 -6
  4. package/src/client.d.ts +0 -3
  5. package/src/client.js +8 -8
  6. package/src/geometry/boundingBoxUtils.js +5 -6
  7. package/src/geometry/polygonUtils.js +13 -14
  8. package/src/http/baseEndpoint.d.ts +0 -2
  9. package/src/http/baseEndpoint.js +1 -1
  10. package/src/http/error.js +4 -4
  11. package/src/http/responseValidation.js +3 -4
  12. package/src/imageOperations/common/extractedImage.d.ts +0 -1
  13. package/src/imageOperations/common/imageExtractor.js +1 -2
  14. package/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.js +1 -2
  15. package/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.js +1 -2
  16. package/src/input/base.d.ts +0 -1
  17. package/src/input/localResponse.d.ts +0 -1
  18. package/src/input/localResponse.js +2 -2
  19. package/src/input/pageOptions.js +1 -1
  20. package/src/input/sources.d.ts +0 -2
  21. package/src/parsing/common/page.js +1 -1
  22. package/src/parsing/common/summaryHelper.js +4 -5
  23. package/src/parsing/custom/lineItems.js +2 -2
  24. package/src/parsing/generated/generatedObject.js +2 -2
  25. package/src/parsing/standard/paymentDetails.js +4 -4
  26. package/src/pdf/pdfOperation.d.ts +0 -1
  27. package/src/pdf/pdfOperation.js +2 -3
  28. package/src/product/businessCard/businessCardV1.d.ts +16 -0
  29. package/src/product/businessCard/businessCardV1.js +27 -0
  30. package/src/product/businessCard/businessCardV1Document.d.ts +34 -0
  31. package/src/product/businessCard/businessCardV1Document.js +78 -0
  32. package/src/product/businessCard/index.d.ts +1 -0
  33. package/src/product/businessCard/index.js +5 -0
  34. package/src/product/businessCard/internal.d.ts +2 -0
  35. package/src/product/businessCard/internal.js +7 -0
  36. package/src/product/deliveryNote/deliveryNoteV1.d.ts +16 -0
  37. package/src/product/deliveryNote/deliveryNoteV1.js +27 -0
  38. package/src/product/deliveryNote/deliveryNoteV1Document.d.ts +26 -0
  39. package/src/product/deliveryNote/deliveryNoteV1Document.js +54 -0
  40. package/src/product/deliveryNote/index.d.ts +1 -0
  41. package/src/product/deliveryNote/index.js +5 -0
  42. package/src/product/deliveryNote/internal.d.ts +2 -0
  43. package/src/product/deliveryNote/internal.js +7 -0
  44. package/src/product/financialDocument/financialDocumentV1Document.d.ts +1 -1
  45. package/src/product/financialDocument/financialDocumentV1Document.js +1 -1
  46. package/src/product/ind/index.d.ts +1 -0
  47. package/src/product/ind/index.js +5 -0
  48. package/src/product/ind/indianPassport/index.d.ts +1 -0
  49. package/src/product/ind/indianPassport/index.js +5 -0
  50. package/src/product/ind/indianPassport/indianPassportV1.d.ts +16 -0
  51. package/src/product/ind/indianPassport/indianPassportV1.js +27 -0
  52. package/src/product/ind/indianPassport/indianPassportV1Document.d.ts +58 -0
  53. package/src/product/ind/indianPassport/indianPassportV1Document.js +132 -0
  54. package/src/product/ind/indianPassport/internal.d.ts +2 -0
  55. package/src/product/ind/indianPassport/internal.js +7 -0
  56. package/src/product/ind/internal.d.ts +1 -0
  57. package/src/product/ind/internal.js +27 -0
  58. package/src/product/index.d.ts +3 -0
  59. package/src/product/index.js +6 -1
  60. package/src/product/internal.d.ts +2 -0
  61. package/src/product/internal.js +3 -1
  62. package/src/product/invoice/invoiceV4Document.d.ts +1 -1
  63. package/src/product/invoice/invoiceV4Document.js +1 -1
  64. package/src/product/resume/resumeV1Document.d.ts +1 -1
  65. package/src/product/resume/resumeV1Document.js +3 -2
  66. package/src/product/resume/resumeV1ProfessionalExperience.d.ts +2 -0
  67. package/src/product/resume/resumeV1ProfessionalExperience.js +10 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.18.1 - 2024-11-19
4
+ ### Fixes
5
+ * :bug: fix composed API server response not properly filling full_text_ocr in pages
6
+ * :arrow_up: bump dependencies
7
+
8
+
9
+ ## v4.18.0 - 2024-11-14
10
+ ### Changes
11
+ * :sparkles: add support for business cards V1
12
+ * :sparkles: add support for delivery note V1.1
13
+ * :sparkles: add support for indian passport V1
14
+ * :sparkles: add support for resume V1.1
15
+ ### Fixes
16
+ * :recycle: adjust default values for async delays
17
+ * :recycle: remove unused dependencies
18
+
19
+
3
20
  ## v4.17.1 - 2024-10-17
4
21
  ### Fixes
5
22
  * :bug: fix invalid handling of boolean fields & fix accidental coercion into numbers in `GeneratedObjectField` fields
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.17.1",
3
+ "version": "4.18.1",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -9,7 +9,7 @@
9
9
  "build": "tsc --build",
10
10
  "build-for-dist": "tsc --build && cp LICENSE README.md CHANGELOG.md ./dist",
11
11
  "clean": "rm -rf ./dist ./docs/_build",
12
- "test": "mocha 'tests/**/*.spec.ts'",
12
+ "test": "mocha 'tests/**/*.spec.ts' --config .mocharc.json",
13
13
  "test-integration": "mocha 'tests/**/*.integration.ts'",
14
14
  "lint": "eslint './src/**/*.ts' --report-unused-disable-directives && echo 'Your .ts files look good.'",
15
15
  "lint-fix": "eslint './src/**/*.ts' --fix",
@@ -41,26 +41,23 @@
41
41
  "homepage": "https://mindee.com/",
42
42
  "devDependencies": {
43
43
  "@types/chai": "^4.3.4",
44
- "@types/lint-staged": "^13.2.0",
45
- "@types/mocha": "^9.1.1",
44
+ "@types/mocha": "^10.0.9",
46
45
  "@types/node": "^18.15.11",
47
- "@typescript-eslint/eslint-plugin": "^5.57.1",
48
- "@typescript-eslint/parser": "^5.57.1",
46
+ "@typescript-eslint/eslint-plugin": "^8.15.0",
47
+ "@typescript-eslint/parser": "^8.15.0",
49
48
  "chai": "^4.3.10",
50
- "eslint": "^8.49.0",
51
- "eslint-plugin-jsdoc": "^46.8.2",
52
- "lint-staged": "^15.2.10",
53
- "mocha": "^10.1.0",
54
- "nock": "^13.3.3",
55
- "ts-node": "^10.9.1",
56
- "typedoc": "~0.23",
57
- "typescript": "^5.0.4"
49
+ "eslint": "^9.15.0",
50
+ "eslint-plugin-jsdoc": "^50.5.0",
51
+ "mocha": "^10.8.2",
52
+ "nock": "^13.5.6",
53
+ "ts-node": "^10.9.2",
54
+ "typedoc": "~0.26.11",
55
+ "typescript": "^5.6.3"
58
56
  },
59
57
  "dependencies": {
60
58
  "commander": "~9.4.1",
61
59
  "file-type": "~16.5.4",
62
60
  "form-data": "~3.0.1",
63
- "mrz": "~3.2.1",
64
61
  "pdf-lib": "~1.17.1"
65
62
  },
66
63
  "keywords": [
package/src/cli.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.cli = void 0;
26
+ exports.cli = cli;
27
27
  const commander_1 = require("commander");
28
28
  const product = __importStar(require("./product"));
29
29
  const client_1 = require("./client");
@@ -339,8 +339,8 @@ async function callEnqueueAndParse(productClass, command, inputPath, options) {
339
339
  pageOptions: pageOptions,
340
340
  allWords: predictParams.allWords,
341
341
  cropper: predictParams.cropper,
342
- initialDelaySec: 4,
343
- delaySec: 2,
342
+ initialDelaySec: 2,
343
+ delaySec: 1.5,
344
344
  maxRetries: 60,
345
345
  });
346
346
  }
@@ -349,8 +349,8 @@ async function callEnqueueAndParse(productClass, command, inputPath, options) {
349
349
  pageOptions: pageOptions,
350
350
  allWords: predictParams.allWords,
351
351
  cropper: predictParams.cropper,
352
- initialDelaySec: 4,
353
- delaySec: 2,
352
+ initialDelaySec: 2,
353
+ delaySec: 1.5,
354
354
  maxRetries: 60,
355
355
  });
356
356
  if (!response.document) {
@@ -491,4 +491,3 @@ function cli() {
491
491
  });
492
492
  program.parse(process.argv);
493
493
  }
494
- exports.cli = cli;
package/src/client.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import { Readable } from "stream";
5
2
  import { Base64Input, BufferInput, BytesInput, InputSource, LocalResponse, PageOptions, PathInput, StreamInput, UrlInput } from "./input";
6
3
  import { Endpoint } from "./http";
package/src/client.js CHANGED
@@ -122,7 +122,7 @@ class Client {
122
122
  }
123
123
  return new common_1.PredictResponse(productClass, localResponse.asDict());
124
124
  }
125
- catch (err) {
125
+ catch {
126
126
  throw new errors_1.MindeeError("No prediction found in local response.");
127
127
  }
128
128
  }
@@ -177,8 +177,8 @@ class Client {
177
177
  fullText: undefined,
178
178
  cropper: undefined,
179
179
  pageOptions: undefined,
180
- initialDelaySec: 4,
181
- delaySec: 2,
180
+ initialDelaySec: 2,
181
+ delaySec: 1.5,
182
182
  maxRetries: 60,
183
183
  initialTimerOptions: undefined,
184
184
  recurringTimerOptions: undefined,
@@ -310,17 +310,17 @@ Job status: ${pollResults.job.status}.`);
310
310
  exports.Client = Client;
311
311
  _Client_instances = new WeakSet(), _Client_setAsyncParams = function _Client_setAsyncParams(asyncParams) {
312
312
  const minDelaySec = 1;
313
- const minInitialDelay = 2;
313
+ const minInitialDelay = 1;
314
314
  const minRetries = 2;
315
315
  const newAsyncParams = { ...asyncParams };
316
- newAsyncParams.delaySec ?? (newAsyncParams.delaySec = 2);
317
- newAsyncParams.initialDelaySec ?? (newAsyncParams.initialDelaySec = 4);
316
+ newAsyncParams.delaySec ?? (newAsyncParams.delaySec = 1.5);
317
+ newAsyncParams.initialDelaySec ?? (newAsyncParams.initialDelaySec = 2);
318
318
  newAsyncParams.maxRetries ?? (newAsyncParams.maxRetries = 60);
319
319
  if (newAsyncParams.delaySec < minDelaySec) {
320
- throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} seconds.`);
320
+ throw Error(`Cannot set auto-parsing delay to less than ${minDelaySec} second(s).`);
321
321
  }
322
322
  if (newAsyncParams.initialDelaySec < minInitialDelay) {
323
- throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} seconds.`);
323
+ throw Error(`Cannot set initial parsing delay to less than ${minInitialDelay} second(s).`);
324
324
  }
325
325
  if (newAsyncParams.maxRetries < minRetries) {
326
326
  throw Error(`Cannot set retry to less than ${minRetries}.`);
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBBoxForPolygons = exports.getBbox = exports.mergeBbox = exports.getBoundingBoxFromBBox = exports.getBoundingBox = void 0;
3
+ exports.getBoundingBox = getBoundingBox;
4
+ exports.getBoundingBoxFromBBox = getBoundingBoxFromBBox;
5
+ exports.mergeBbox = mergeBbox;
6
+ exports.getBbox = getBbox;
7
+ exports.getBBoxForPolygons = getBBoxForPolygons;
4
8
  const boundingBox_1 = require("./boundingBox");
5
9
  /**
6
10
  * Given a Polygon, calculate a polygon that encompasses all points.
@@ -9,7 +13,6 @@ function getBoundingBox(polygon) {
9
13
  const bbox = getBbox(polygon);
10
14
  return getBoundingBoxFromBBox(bbox);
11
15
  }
12
- exports.getBoundingBox = getBoundingBox;
13
16
  /**
14
17
  * Given a BBox, generate the associated bounding box.
15
18
  */
@@ -21,14 +24,12 @@ function getBoundingBoxFromBBox(bbox) {
21
24
  [bbox.xMin, bbox.yMax],
22
25
  ];
23
26
  }
24
- exports.getBoundingBoxFromBBox = getBoundingBoxFromBBox;
25
27
  /**
26
28
  * Given 2 bbox, merge them.
27
29
  */
28
30
  function mergeBbox(bbox1, bbox2) {
29
31
  return new boundingBox_1.BBox(Math.min(bbox1.xMin, bbox2.xMin), Math.min(bbox1.yMin, bbox2.yMin), Math.max(bbox1.xMax, bbox2.xMax), Math.max(bbox1.yMax, bbox2.yMax));
30
32
  }
31
- exports.mergeBbox = mergeBbox;
32
33
  /**
33
34
  * Given a Polygon, calculate a BBox that encompasses all points.
34
35
  */
@@ -37,7 +38,6 @@ function getBbox(polygon) {
37
38
  const allX = polygon.map((point) => point[0]);
38
39
  return new boundingBox_1.BBox(Math.min(...allX), Math.min(...allY), Math.max(...allX), Math.max(...allY));
39
40
  }
40
- exports.getBbox = getBbox;
41
41
  /**
42
42
  * Given polygons, calculate a BBox that encompasses all points.
43
43
  */
@@ -46,4 +46,3 @@ function getBBoxForPolygons(polygons) {
46
46
  const allX = polygons.flatMap((polygon) => polygon.map((point) => point[0]));
47
47
  return new boundingBox_1.BBox(Math.min(...allX), Math.min(...allY), Math.max(...allX), Math.max(...allY));
48
48
  }
49
- exports.getBBoxForPolygons = getBBoxForPolygons;
@@ -1,6 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareOnX = exports.compareOnY = exports.getMinXCoordinate = exports.getMinYCoordinate = exports.relativeX = exports.isPointInPolygonX = exports.getMinMaxX = exports.isPointInX = exports.relativeY = exports.isPointInPolygonY = exports.getMinMaxY = exports.isPointInY = exports.getCentroid = void 0;
3
+ exports.getCentroid = getCentroid;
4
+ exports.isPointInY = isPointInY;
5
+ exports.getMinMaxY = getMinMaxY;
6
+ exports.isPointInPolygonY = isPointInPolygonY;
7
+ exports.relativeY = relativeY;
8
+ exports.isPointInX = isPointInX;
9
+ exports.getMinMaxX = getMinMaxX;
10
+ exports.isPointInPolygonX = isPointInPolygonX;
11
+ exports.relativeX = relativeX;
12
+ exports.getMinYCoordinate = getMinYCoordinate;
13
+ exports.getMinXCoordinate = getMinXCoordinate;
14
+ exports.compareOnY = compareOnY;
15
+ exports.compareOnX = compareOnX;
4
16
  /**
5
17
  * Get the central point (centroid) given a list of points.
6
18
  */
@@ -14,14 +26,12 @@ function getCentroid(vertices) {
14
26
  .reduce((prev, cur) => prev + cur);
15
27
  return [xSum / numbVertices, ySum / numbVertices];
16
28
  }
17
- exports.getCentroid = getCentroid;
18
29
  /**
19
30
  * Determine if a Point is within two Y coordinates.
20
31
  */
21
32
  function isPointInY(centroid, yMin, yMax) {
22
33
  return yMin <= centroid[1] && centroid[1] <= yMax;
23
34
  }
24
- exports.isPointInY = isPointInY;
25
35
  /**
26
36
  * Get the maximum and minimum Y coordinates in a given list of Points.
27
37
  */
@@ -29,7 +39,6 @@ function getMinMaxY(vertices) {
29
39
  const points = vertices.map((point) => point[1]);
30
40
  return { min: Math.min(...points), max: Math.max(...points) };
31
41
  }
32
- exports.getMinMaxY = getMinMaxY;
33
42
  /**
34
43
  * Determine if a Point is within a Polygon's Y axis.
35
44
  */
@@ -37,7 +46,6 @@ function isPointInPolygonY(centroid, polygon) {
37
46
  const yCoords = getMinMaxY(polygon);
38
47
  return isPointInY(centroid, yCoords.min, yCoords.max);
39
48
  }
40
- exports.isPointInPolygonY = isPointInPolygonY;
41
49
  /**
42
50
  * Calculate the relative Y position of a Polygon.
43
51
  *
@@ -49,14 +57,12 @@ function relativeY(polygon) {
49
57
  .reduce((prev, cur) => prev + cur);
50
58
  return polygon.length * sum;
51
59
  }
52
- exports.relativeY = relativeY;
53
60
  /**
54
61
  * Determine if a Point is within two X coordinates.
55
62
  */
56
63
  function isPointInX(centroid, xMin, xMax) {
57
64
  return xMin <= centroid[0] && centroid[0] <= xMax;
58
65
  }
59
- exports.isPointInX = isPointInX;
60
66
  /**
61
67
  * Get the maximum and minimum X coordinates in a given list of Points.
62
68
  */
@@ -64,7 +70,6 @@ function getMinMaxX(vertices) {
64
70
  const points = vertices.map((point) => point[0]);
65
71
  return { min: Math.min(...points), max: Math.max(...points) };
66
72
  }
67
- exports.getMinMaxX = getMinMaxX;
68
73
  /**
69
74
  * Determine if a Point is within a Polygon's X axis.
70
75
  */
@@ -72,7 +77,6 @@ function isPointInPolygonX(centroid, polygon) {
72
77
  const xCoords = getMinMaxX(polygon);
73
78
  return isPointInX(centroid, xCoords.min, xCoords.max);
74
79
  }
75
- exports.isPointInPolygonX = isPointInPolygonX;
76
80
  /**
77
81
  * Calculate the relative X position of a Polygon.
78
82
  *
@@ -84,7 +88,6 @@ function relativeX(polygon) {
84
88
  .reduce((prev, cur) => prev + cur);
85
89
  return polygon.length * sum;
86
90
  }
87
- exports.relativeX = relativeX;
88
91
  function getMinYCoordinate(polygon) {
89
92
  return polygon.sort((point1, point2) => {
90
93
  if (point1[1] < point2[1]) {
@@ -96,7 +99,6 @@ function getMinYCoordinate(polygon) {
96
99
  return 0;
97
100
  })[0][1];
98
101
  }
99
- exports.getMinYCoordinate = getMinYCoordinate;
100
102
  function getMinXCoordinate(polygon) {
101
103
  return polygon.sort((point1, point2) => {
102
104
  if (point1[0] < point2[0]) {
@@ -108,7 +110,6 @@ function getMinXCoordinate(polygon) {
108
110
  return 0;
109
111
  })[0][0];
110
112
  }
111
- exports.getMinXCoordinate = getMinXCoordinate;
112
113
  function compareOnY(polygon1, polygon2) {
113
114
  const sort = getMinYCoordinate(polygon1) - getMinYCoordinate(polygon2);
114
115
  if (sort === 0) {
@@ -116,7 +117,6 @@ function compareOnY(polygon1, polygon2) {
116
117
  }
117
118
  return sort < 0 ? -1 : 1;
118
119
  }
119
- exports.compareOnY = compareOnY;
120
120
  function compareOnX(polygon1, polygon2) {
121
121
  const sort = getMinXCoordinate(polygon1) - getMinXCoordinate(polygon2);
122
122
  if (sort === 0) {
@@ -124,4 +124,3 @@ function compareOnX(polygon1, polygon2) {
124
124
  }
125
125
  return sort < 0 ? -1 : 1;
126
126
  }
127
- exports.compareOnX = compareOnX;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { ApiSettings } from "./apiSettings";
4
2
  import { IncomingMessage, ClientRequest } from "http";
5
3
  import { RequestOptions } from "https";
@@ -46,7 +46,7 @@ class BaseEndpoint {
46
46
  reject(error);
47
47
  }
48
48
  }
49
- catch (error) {
49
+ catch {
50
50
  logger_1.logger.error("Could not parse the return as JSON.");
51
51
  logger_1.logger.debug(responseBody);
52
52
  resolve({
package/src/http/error.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = exports.handleError = void 0;
3
+ exports.MindeeHttp504Error = exports.MindeeHttp500Error = exports.MindeeHttp429Error = exports.MindeeHttp413Error = exports.MindeeHttp404Error = exports.MindeeHttp403Error = exports.MindeeHttp401Error = exports.MindeeHttp400Error = exports.MindeeHttpError = void 0;
4
+ exports.handleError = handleError;
4
5
  const errors_1 = require("../errors");
5
6
  const handler_1 = require("../errors/handler");
6
7
  function handleError(urlName, response, serverError) {
@@ -14,7 +15,7 @@ function handleError(urlName, response, serverError) {
14
15
  code = response.data.api_request["status_code"];
15
16
  }
16
17
  }
17
- catch (e) {
18
+ catch {
18
19
  code = 500;
19
20
  }
20
21
  let errorObj;
@@ -22,7 +23,7 @@ function handleError(urlName, response, serverError) {
22
23
  //Regular instances where the returned error is in JSON format.
23
24
  errorObj = response.data.api_request.error;
24
25
  }
25
- catch (err) {
26
+ catch {
26
27
  //Rare instances where errors are returned as HTML instead of JSON.
27
28
  if (!("reconstructedResponse" in response.data)) {
28
29
  response.data.reconstructedResponse = "";
@@ -108,7 +109,6 @@ function handleError(urlName, response, serverError) {
108
109
  }
109
110
  handler_1.errorHandler.throw(errorToThrow);
110
111
  }
111
- exports.handleError = handleError;
112
112
  /**
113
113
  * `Error` wrapper for server (HTTP) errors.
114
114
  * Is used when an error is lacking a handled error code.
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanRequestData = exports.isValidAsyncResponse = exports.isValidSyncResponse = void 0;
3
+ exports.isValidSyncResponse = isValidSyncResponse;
4
+ exports.isValidAsyncResponse = isValidAsyncResponse;
5
+ exports.cleanRequestData = cleanRequestData;
4
6
  /**
5
7
  * Checks if the synchronous response is valid. Returns True if the response is valid.
6
8
  *
@@ -15,7 +17,6 @@ function isValidSyncResponse(response) {
15
17
  parseInt(response.messageObj.statusCode.toString()) < 200 ||
16
18
  parseInt(response.messageObj.statusCode.toString()) > 302);
17
19
  }
18
- exports.isValidSyncResponse = isValidSyncResponse;
19
20
  /**
20
21
  * Checks if the asynchronous response is valid. Also checks if it is a valid synchronous response.
21
22
  * Returns True if the response is valid.
@@ -43,7 +44,6 @@ function isValidAsyncResponse(response) {
43
44
  response.data["job"]["error"] &&
44
45
  Object.keys(response.data["job"]["error"]).length > 0);
45
46
  }
46
- exports.isValidAsyncResponse = isValidAsyncResponse;
47
47
  /**
48
48
  * Checks and correct the response object depending on the possible kinds of returns.
49
49
  *
@@ -70,4 +70,3 @@ function cleanRequestData(response) {
70
70
  }
71
71
  return response;
72
72
  }
73
- exports.cleanRequestData = cleanRequestData;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Buffer } from "node:buffer";
3
2
  import { BufferInput } from "../../input";
4
3
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractFromPage = void 0;
3
+ exports.extractFromPage = extractFromPage;
4
4
  const pdf_lib_1 = require("pdf-lib");
5
5
  const geometry_1 = require("../../geometry");
6
6
  /**
@@ -31,4 +31,3 @@ async function extractFromPage(pdfPage, polygons) {
31
31
  }
32
32
  return extractedElements;
33
33
  }
34
- exports.extractFromPage = extractFromPage;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractInvoices = void 0;
3
+ exports.extractInvoices = extractInvoices;
4
4
  const pdf_lib_1 = require("pdf-lib");
5
5
  const errors_1 = require("../../errors");
6
6
  const product_1 = require("../../product");
@@ -71,4 +71,3 @@ async function extractInvoices(inputFile, indexes, strict = false) {
71
71
  });
72
72
  return await splitPdf(pdfDoc, customIndexes);
73
73
  }
74
- exports.extractInvoices = extractInvoices;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractReceipts = void 0;
3
+ exports.extractReceipts = extractReceipts;
4
4
  const pdf_lib_1 = require("pdf-lib");
5
5
  const errors_1 = require("../../errors");
6
6
  const extractedMultiReceiptImage_1 = require("./extractedMultiReceiptImage");
@@ -68,4 +68,3 @@ async function extractReceipts(inputFile, inference) {
68
68
  }
69
69
  return images;
70
70
  }
71
- exports.extractReceipts = extractReceipts;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PageOptions } from "./pageOptions";
3
2
  /**
4
3
  * @param {string} inputType - the type of input used in file ("base64", "path", "dummy").
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { StringDict } from "../parsing/common";
3
2
  import { Buffer } from "buffer";
4
3
  /**
@@ -71,7 +71,7 @@ class LocalResponse {
71
71
  const content = this.file.toString("utf-8");
72
72
  return JSON.parse(content);
73
73
  }
74
- catch (error) {
74
+ catch {
75
75
  throw new errors_1.MindeeError("File is not a valid dictionary.");
76
76
  }
77
77
  }
@@ -87,7 +87,7 @@ class LocalResponse {
87
87
  hmac.update(this.file);
88
88
  return hmac.digest("hex");
89
89
  }
90
- catch (error) {
90
+ catch {
91
91
  throw new errors_1.MindeeError("Could not get HMAC signature from payload.");
92
92
  }
93
93
  }
@@ -10,4 +10,4 @@ var PageOptionsOperation;
10
10
  PageOptionsOperation["KeepOnly"] = "KEEP_ONLY";
11
11
  /** Remove pages matching the provided indexes. */
12
12
  PageOptionsOperation["Remove"] = "REMOVE";
13
- })(PageOptionsOperation = exports.PageOptionsOperation || (exports.PageOptionsOperation = {}));
13
+ })(PageOptionsOperation || (exports.PageOptionsOperation = PageOptionsOperation = {}));
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { Readable } from "stream";
4
2
  import { Buffer } from "buffer";
5
3
  import { LocalInputSource, InputSource } from "./base";
@@ -58,7 +58,7 @@ ${this.prediction.toString()}
58
58
  if (!("extras" in rawPrediction) || !("full_text_ocr" in rawPrediction["extras"])) {
59
59
  return;
60
60
  }
61
- const fullTextOcr = rawPrediction.map((e) => e["extras"]["full_text_ocr"]["content"]).join("\n");
61
+ const fullTextOcr = rawPrediction["extras"]["full_text_ocr"]["content"];
62
62
  const artificialTextObj = {
63
63
  // eslint-disable-next-line @typescript-eslint/naming-convention
64
64
  "full_text_ocr": {
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.floatToString = exports.cleanSpecialChars = exports.lineSeparator = exports.cleanOutString = void 0;
3
+ exports.cleanOutString = cleanOutString;
4
+ exports.lineSeparator = lineSeparator;
5
+ exports.cleanSpecialChars = cleanSpecialChars;
6
+ exports.floatToString = floatToString;
4
7
  function cleanOutString(outStr) {
5
8
  const lines = / \n/gm;
6
9
  return outStr.replace(lines, "\n");
7
10
  }
8
- exports.cleanOutString = cleanOutString;
9
11
  /**
10
12
  *
11
13
  * @param columnSizes Size of each column in the table
@@ -19,7 +21,6 @@ function lineSeparator(columnSizes, separator) {
19
21
  });
20
22
  return outStr;
21
23
  }
22
- exports.lineSeparator = lineSeparator;
23
24
  /**
24
25
  * Replaces all special characters like \n, \r, \t, with an equivalent that can be displayed on a single line.
25
26
  * Also trims line breaks at the end of the string.
@@ -31,7 +32,6 @@ function cleanSpecialChars(outStr) {
31
32
  .replace(/\r/g, "\\r")
32
33
  .replace(/\t/g, "\\t");
33
34
  }
34
- exports.cleanSpecialChars = cleanSpecialChars;
35
35
  /**
36
36
  * Return a float as a string with at least 2 levels of precision.
37
37
  */
@@ -45,4 +45,3 @@ function floatToString(value) {
45
45
  useGrouping: false,
46
46
  });
47
47
  }
48
- exports.floatToString = floatToString;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLineItems = exports.CustomLines = exports.CustomLine = void 0;
3
+ exports.CustomLines = exports.CustomLine = void 0;
4
+ exports.getLineItems = getLineItems;
4
5
  const handler_1 = require("../../errors/handler");
5
6
  const errors_1 = require("../../errors");
6
7
  const geometry_1 = require("../../geometry");
@@ -72,7 +73,6 @@ function getLineItems(anchorNames, fieldNames, fields, heightLineTolerance) {
72
73
  });
73
74
  return linesPrepared;
74
75
  }
75
- exports.getLineItems = getLineItems;
76
76
  /**
77
77
  * Loop through the possible anchor fields and find the one with the most values.
78
78
  */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isGeneratedObject = exports.GeneratedObjectField = void 0;
3
+ exports.GeneratedObjectField = void 0;
4
+ exports.isGeneratedObject = isGeneratedObject;
4
5
  const standard_1 = require("../standard");
5
6
  /** A JSON-like object, with miscellaneous values. */
6
7
  class GeneratedObjectField {
@@ -104,4 +105,3 @@ function isGeneratedObject(strDict) {
104
105
  }
105
106
  return false;
106
107
  }
107
- exports.isGeneratedObject = isGeneratedObject;
@@ -21,16 +21,16 @@ class PaymentDetailsField extends field_1.Field {
21
21
  this.iban = undefined;
22
22
  this.routingNumber = undefined;
23
23
  this.swift = undefined;
24
- if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[accountNumberKey])) {
24
+ if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[accountNumberKey])) {
25
25
  this.accountNumber = prediction[accountNumberKey];
26
26
  }
27
- if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[ibanKey])) {
27
+ if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[ibanKey])) {
28
28
  this.iban = prediction[ibanKey];
29
29
  }
30
- if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[routingNumberKey])) {
30
+ if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[routingNumberKey])) {
31
31
  this.routingNumber = prediction[routingNumberKey];
32
32
  }
33
- if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[swiftKey])) {
33
+ if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[swiftKey])) {
34
34
  this.swift = prediction[swiftKey];
35
35
  }
36
36
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PageOptions } from "../input";
3
2
  export interface SplitPdf {
4
3
  file: Buffer;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.countPages = exports.extractPages = void 0;
3
+ exports.extractPages = extractPages;
4
+ exports.countPages = countPages;
4
5
  const handler_1 = require("../errors/handler");
5
6
  const pdf_lib_1 = require("pdf-lib");
6
7
  const input_1 = require("../input");
@@ -64,11 +65,9 @@ async function extractPages(file, pageOptions) {
64
65
  const fileBuffer = Buffer.from(await newPdf.save());
65
66
  return { file: fileBuffer, totalPagesRemoved: sumRemovedPages };
66
67
  }
67
- exports.extractPages = extractPages;
68
68
  async function countPages(file) {
69
69
  const currentPdf = await pdf_lib_1.PDFDocument.load(file, {
70
70
  ignoreEncryption: true,
71
71
  });
72
72
  return currentPdf.getPageCount();
73
73
  }
74
- exports.countPages = countPages;
@@ -0,0 +1,16 @@
1
+ import { Inference, StringDict, Page } from "../../parsing/common";
2
+ import { BusinessCardV1Document } from "./businessCardV1Document";
3
+ /**
4
+ * Business Card API version 1 inference prediction.
5
+ */
6
+ export declare class BusinessCardV1 extends Inference {
7
+ /** The endpoint's name. */
8
+ endpointName: string;
9
+ /** The endpoint's version. */
10
+ endpointVersion: string;
11
+ /** The document-level prediction. */
12
+ prediction: BusinessCardV1Document;
13
+ /** The document's pages. */
14
+ pages: Page<BusinessCardV1Document>[];
15
+ constructor(rawPrediction: StringDict);
16
+ }