mindee 4.18.0 → 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.
- package/CHANGELOG.md +7 -1
- package/package.json +12 -12
- package/src/cli.js +1 -2
- package/src/client.d.ts +0 -3
- package/src/client.js +1 -1
- package/src/geometry/boundingBoxUtils.js +5 -6
- package/src/geometry/polygonUtils.js +13 -14
- package/src/http/baseEndpoint.d.ts +0 -2
- package/src/http/baseEndpoint.js +1 -1
- package/src/http/error.js +4 -4
- package/src/http/responseValidation.js +3 -4
- package/src/imageOperations/common/extractedImage.d.ts +0 -1
- package/src/imageOperations/common/imageExtractor.js +1 -2
- package/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.js +1 -2
- package/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.js +1 -2
- package/src/input/base.d.ts +0 -1
- package/src/input/localResponse.d.ts +0 -1
- package/src/input/localResponse.js +2 -2
- package/src/input/pageOptions.js +1 -1
- package/src/input/sources.d.ts +0 -2
- package/src/parsing/common/page.js +1 -1
- package/src/parsing/common/summaryHelper.js +4 -5
- package/src/parsing/custom/lineItems.js +2 -2
- package/src/parsing/generated/generatedObject.js +2 -2
- package/src/parsing/standard/paymentDetails.js +4 -4
- package/src/pdf/pdfOperation.d.ts +0 -1
- package/src/pdf/pdfOperation.js +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
##
|
|
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
|
|
4
10
|
### Changes
|
|
5
11
|
* :sparkles: add support for business cards V1
|
|
6
12
|
* :sparkles: add support for delivery note V1.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindee",
|
|
3
|
-
"version": "4.18.
|
|
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,18 +41,18 @@
|
|
|
41
41
|
"homepage": "https://mindee.com/",
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/chai": "^4.3.4",
|
|
44
|
-
"@types/mocha": "^
|
|
44
|
+
"@types/mocha": "^10.0.9",
|
|
45
45
|
"@types/node": "^18.15.11",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
47
|
-
"@typescript-eslint/parser": "^
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
|
47
|
+
"@typescript-eslint/parser": "^8.15.0",
|
|
48
48
|
"chai": "^4.3.10",
|
|
49
|
-
"eslint": "^
|
|
50
|
-
"eslint-plugin-jsdoc": "^
|
|
51
|
-
"mocha": "^10.
|
|
52
|
-
"nock": "^13.
|
|
53
|
-
"ts-node": "^10.9.
|
|
54
|
-
"typedoc": "~0.
|
|
55
|
-
"typescript": "^5.
|
|
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"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"commander": "~9.4.1",
|
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 =
|
|
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");
|
|
@@ -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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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.
|
|
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;
|
package/src/http/baseEndpoint.js
CHANGED
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 =
|
|
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
|
|
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
|
|
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.
|
|
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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractFromPage =
|
|
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 =
|
|
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 =
|
|
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;
|
package/src/input/base.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
90
|
+
catch {
|
|
91
91
|
throw new errors_1.MindeeError("Could not get HMAC signature from payload.");
|
|
92
92
|
}
|
|
93
93
|
}
|
package/src/input/pageOptions.js
CHANGED
|
@@ -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
|
|
13
|
+
})(PageOptionsOperation || (exports.PageOptionsOperation = PageOptionsOperation = {}));
|
package/src/input/sources.d.ts
CHANGED
|
@@ -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
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
24
|
+
if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[accountNumberKey])) {
|
|
25
25
|
this.accountNumber = prediction[accountNumberKey];
|
|
26
26
|
}
|
|
27
|
-
if (__classPrivateFieldGet(
|
|
27
|
+
if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[ibanKey])) {
|
|
28
28
|
this.iban = prediction[ibanKey];
|
|
29
29
|
}
|
|
30
|
-
if (__classPrivateFieldGet(
|
|
30
|
+
if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[routingNumberKey])) {
|
|
31
31
|
this.routingNumber = prediction[routingNumberKey];
|
|
32
32
|
}
|
|
33
|
-
if (__classPrivateFieldGet(
|
|
33
|
+
if (__classPrivateFieldGet(_a, _a, "m", _PaymentDetailsField_isKeySet).call(_a, prediction[swiftKey])) {
|
|
34
34
|
this.swift = prediction[swiftKey];
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/pdf/pdfOperation.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|