mindee 4.9.1 → 4.10.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.
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/src/errors/handler.d.ts +1 -0
- package/src/errors/handler.js +1 -0
- package/src/http/error.js +9 -3
- package/src/input/sources.js +1 -2
- package/src/product/invoice/invoiceV4Document.d.ts +4 -0
- package/src/product/invoice/invoiceV4Document.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
# v4.10.0 - 2024-04-12
|
|
4
|
+
### Changes
|
|
5
|
+
* :sparkles: update Invoice to v4.5 (#264)
|
|
6
|
+
|
|
7
|
+
### Fixes
|
|
8
|
+
* :bug: fix error management not following intended flow (#267)
|
|
9
|
+
* :recycle: deprecated old error handler (#266)
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
## v4.9.1 - 2024-03-05
|
|
4
13
|
### Changes
|
|
5
14
|
* :recycle: update error handling to account for future evolutions
|
package/package.json
CHANGED
package/src/errors/handler.d.ts
CHANGED
package/src/errors/handler.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.errorHandler = exports.ErrorHandler = void 0;
|
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
/**
|
|
6
6
|
* Custom Error handling class.
|
|
7
|
+
* @deprecated Clashes with current implementation of some errors, which may cause unexpected behaviors.
|
|
7
8
|
*/
|
|
8
9
|
class ErrorHandler {
|
|
9
10
|
constructor(throwOnError = true) {
|
package/src/http/error.js
CHANGED
|
@@ -5,10 +5,16 @@ const errors_1 = require("../errors");
|
|
|
5
5
|
const handler_1 = require("../errors/handler");
|
|
6
6
|
function handleError(urlName, response, serverError) {
|
|
7
7
|
let code;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
try {
|
|
9
|
+
if (response.data.api_request["status_code"] === 200 && response.data?.job?.error?.code) {
|
|
10
|
+
code = 500;
|
|
11
|
+
response.data.api_request.error = response.data.job.error;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
code = response.data.api_request["status_code"];
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
|
-
|
|
17
|
+
catch (e) {
|
|
12
18
|
code = 500;
|
|
13
19
|
}
|
|
14
20
|
let errorObj;
|
package/src/input/sources.js
CHANGED
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.BufferInput = exports.UrlInput = exports.BytesInput = exports.StreamInput = exports.Base64Input = exports.PathInput = void 0;
|
|
27
27
|
const fs_1 = require("fs");
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
|
-
const handler_1 = require("../errors/handler");
|
|
30
29
|
const buffer_1 = require("buffer");
|
|
31
30
|
const logger_1 = require("../logger");
|
|
32
31
|
const base_1 = require("./base");
|
|
@@ -113,7 +112,7 @@ class UrlInput extends base_1.InputSource {
|
|
|
113
112
|
}
|
|
114
113
|
async init() {
|
|
115
114
|
if (!this.url.toLowerCase().startsWith("https")) {
|
|
116
|
-
|
|
115
|
+
throw new Error("URL must be HTTPS");
|
|
117
116
|
}
|
|
118
117
|
this.fileObject = this.url;
|
|
119
118
|
}
|
|
@@ -5,6 +5,8 @@ import { AmountField, ClassificationField, CompanyRegistrationField, DateField,
|
|
|
5
5
|
* Document data for Invoice, API version 4.
|
|
6
6
|
*/
|
|
7
7
|
export declare class InvoiceV4Document implements Prediction {
|
|
8
|
+
/** The customer's address used for billing. */
|
|
9
|
+
billingAddress: StringField;
|
|
8
10
|
/** The address of the customer. */
|
|
9
11
|
customerAddress: StringField;
|
|
10
12
|
/** List of company registrations associated to the customer. */
|
|
@@ -25,6 +27,8 @@ export declare class InvoiceV4Document implements Prediction {
|
|
|
25
27
|
locale: LocaleField;
|
|
26
28
|
/** List of Reference numbers, including PO number. */
|
|
27
29
|
referenceNumbers: StringField[];
|
|
30
|
+
/** Customer's delivery address. */
|
|
31
|
+
shippingAddress: StringField;
|
|
28
32
|
/** The address of the supplier or merchant. */
|
|
29
33
|
supplierAddress: StringField;
|
|
30
34
|
/** List of company registrations associated to the supplier. */
|
|
@@ -19,6 +19,10 @@ class InvoiceV4Document {
|
|
|
19
19
|
this.supplierCompanyRegistrations = [];
|
|
20
20
|
/** List of payment details associated to the supplier. */
|
|
21
21
|
this.supplierPaymentDetails = [];
|
|
22
|
+
this.billingAddress = new standard_1.StringField({
|
|
23
|
+
prediction: rawPrediction["billing_address"],
|
|
24
|
+
pageId: pageId,
|
|
25
|
+
});
|
|
22
26
|
this.customerAddress = new standard_1.StringField({
|
|
23
27
|
prediction: rawPrediction["customer_address"],
|
|
24
28
|
pageId: pageId,
|
|
@@ -60,6 +64,10 @@ class InvoiceV4Document {
|
|
|
60
64
|
prediction: itemPrediction,
|
|
61
65
|
pageId: pageId,
|
|
62
66
|
})));
|
|
67
|
+
this.shippingAddress = new standard_1.StringField({
|
|
68
|
+
prediction: rawPrediction["shipping_address"],
|
|
69
|
+
pageId: pageId,
|
|
70
|
+
});
|
|
63
71
|
this.supplierAddress = new standard_1.StringField({
|
|
64
72
|
prediction: rawPrediction["supplier_address"],
|
|
65
73
|
pageId: pageId,
|
|
@@ -130,6 +138,8 @@ class InvoiceV4Document {
|
|
|
130
138
|
:Customer Name: ${this.customerName}
|
|
131
139
|
:Customer Company Registrations: ${customerCompanyRegistrations}
|
|
132
140
|
:Customer Address: ${this.customerAddress}
|
|
141
|
+
:Shipping Address: ${this.shippingAddress}
|
|
142
|
+
:Billing Address: ${this.billingAddress}
|
|
133
143
|
:Document Type: ${this.documentType}
|
|
134
144
|
:Line Items: ${lineItemsSummary}`.trimEnd();
|
|
135
145
|
return (0, common_1.cleanOutString)(outStr);
|