mindee 4.16.0 → 4.17.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 +13 -1
- package/package.json +1 -1
- package/src/parsing/generated/generatedObject.d.ts +3 -0
- package/src/parsing/generated/generatedObject.js +11 -1
- package/src/parsing/standard/date.d.ts +2 -0
- package/src/parsing/standard/date.js +4 -2
- package/src/product/financialDocument/financialDocumentV1Document.d.ts +5 -1
- package/src/product/financialDocument/financialDocumentV1Document.js +11 -1
- package/src/product/invoice/invoiceV4Document.d.ts +5 -1
- package/src/product/invoice/invoiceV4Document.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## v4.17.1 - 2024-10-17
|
|
4
|
+
### Fixes
|
|
5
|
+
* :bug: fix invalid handling of boolean fields & fix accidental coercion into numbers in `GeneratedObjectField` fields
|
|
6
|
+
* :bug: fix `GeneratedObjectField` fields being inaccessible in typescript without going through the main object
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## v4.17.0 - 2024-10-11
|
|
10
|
+
### Changes
|
|
11
|
+
* :sparkles: add support for Financial Document v1.10
|
|
12
|
+
* :sparkles: add support for Invoice v4.8
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## v4.16.0 - 2024-09-17
|
|
4
16
|
### Changes
|
|
5
17
|
* :sparkles: add support for US Mail V2
|
|
6
18
|
* :sparkles: add support for Bill of Lading V1
|
package/package.json
CHANGED
|
@@ -10,6 +10,8 @@ export declare class GeneratedObjectField {
|
|
|
10
10
|
rawValue?: string;
|
|
11
11
|
/** List of all printable field names. */
|
|
12
12
|
private printableValues;
|
|
13
|
+
/** All potentially present fields. */
|
|
14
|
+
[key: string]: string | number | boolean | object | undefined;
|
|
13
15
|
constructor({ prediction, pageId, }: BaseFieldConstructor);
|
|
14
16
|
/**
|
|
15
17
|
* ReSTructured-compliant string representation.
|
|
@@ -24,6 +26,7 @@ export declare class GeneratedObjectField {
|
|
|
24
26
|
*/
|
|
25
27
|
private toNumberString;
|
|
26
28
|
toString(): string;
|
|
29
|
+
get(fieldName: string): string | number | boolean | object | undefined;
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* Checks whether a field is a custom object or not.
|
|
@@ -28,9 +28,16 @@ class GeneratedObjectField {
|
|
|
28
28
|
this.rawValue = fieldValue;
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
if (fieldValue !== null &&
|
|
31
|
+
if (fieldValue !== null &&
|
|
32
|
+
fieldValue !== undefined &&
|
|
33
|
+
typeof fieldValue === "number" &&
|
|
34
|
+
!isNaN(fieldValue) &&
|
|
35
|
+
fieldName !== "degrees") {
|
|
32
36
|
Object.assign(this, { [fieldName]: this.toNumberString(fieldValue) });
|
|
33
37
|
}
|
|
38
|
+
else if (typeof fieldValue === "boolean") {
|
|
39
|
+
Object.assign(this, { [fieldName]: fieldValue });
|
|
40
|
+
}
|
|
34
41
|
else {
|
|
35
42
|
Object.assign(this, {
|
|
36
43
|
[fieldName]: (fieldValue !== undefined && fieldValue !== null) ?
|
|
@@ -70,6 +77,9 @@ class GeneratedObjectField {
|
|
|
70
77
|
toString() {
|
|
71
78
|
return this.toStringLevel();
|
|
72
79
|
}
|
|
80
|
+
get(fieldName) {
|
|
81
|
+
return this[fieldName];
|
|
82
|
+
}
|
|
73
83
|
}
|
|
74
84
|
exports.GeneratedObjectField = GeneratedObjectField;
|
|
75
85
|
/**
|
|
@@ -8,6 +8,8 @@ export declare class DateField extends Field {
|
|
|
8
8
|
value?: string;
|
|
9
9
|
/** Date as a standard JavaScript `Date` object. */
|
|
10
10
|
dateObject?: Date;
|
|
11
|
+
/** Whether the field was computed or retrieved directly from the document. */
|
|
12
|
+
isComputed?: boolean;
|
|
11
13
|
/**
|
|
12
14
|
* @param {BaseFieldConstructor} constructor Constructor parameters.
|
|
13
15
|
*/
|
|
@@ -11,6 +11,9 @@ class DateField extends field_1.Field {
|
|
|
11
11
|
*/
|
|
12
12
|
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
|
|
13
13
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
14
|
+
if ("is_computed" in prediction) {
|
|
15
|
+
this.isComputed = prediction["is_computed"];
|
|
16
|
+
}
|
|
14
17
|
if (typeof this.value === "string") {
|
|
15
18
|
this.dateObject = new Date(this.value);
|
|
16
19
|
if (isNaN(this.dateObject.valueOf())) {
|
|
@@ -24,10 +27,9 @@ class DateField extends field_1.Field {
|
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
static compareDates(date1, date2) {
|
|
27
|
-
|
|
30
|
+
return date1.getFullYear() === date2.getFullYear() &&
|
|
28
31
|
date1.getMonth() === date2.getMonth() &&
|
|
29
32
|
date1.getDate() === date2.getDate();
|
|
30
|
-
return check;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
exports.DateField = DateField;
|
|
@@ -2,7 +2,7 @@ import { Prediction, StringDict } from "../../parsing/common";
|
|
|
2
2
|
import { FinancialDocumentV1LineItem } from "./financialDocumentV1LineItem";
|
|
3
3
|
import { AmountField, ClassificationField, CompanyRegistrationField, DateField, LocaleField, PaymentDetailsField, StringField, Taxes } from "../../parsing/standard";
|
|
4
4
|
/**
|
|
5
|
-
* Financial Document API version 1.
|
|
5
|
+
* Financial Document API version 1.10 document data.
|
|
6
6
|
*/
|
|
7
7
|
export declare class FinancialDocumentV1Document implements Prediction {
|
|
8
8
|
/** The customer's address used for billing. */
|
|
@@ -31,6 +31,10 @@ export declare class FinancialDocumentV1Document implements Prediction {
|
|
|
31
31
|
lineItems: FinancialDocumentV1LineItem[];
|
|
32
32
|
/** The locale detected on the document. */
|
|
33
33
|
locale: LocaleField;
|
|
34
|
+
/** The date on which the payment is due / fullfilled. */
|
|
35
|
+
paymentDate: DateField;
|
|
36
|
+
/** The purchase order number. */
|
|
37
|
+
poNumber: StringField;
|
|
34
38
|
/** The receipt number or identifier only if document is a receipt. */
|
|
35
39
|
receiptNumber: StringField;
|
|
36
40
|
/** List of Reference numbers, including PO number. */
|
|
@@ -5,7 +5,7 @@ const common_1 = require("../../parsing/common");
|
|
|
5
5
|
const financialDocumentV1LineItem_1 = require("./financialDocumentV1LineItem");
|
|
6
6
|
const standard_1 = require("../../parsing/standard");
|
|
7
7
|
/**
|
|
8
|
-
* Financial Document API version 1.
|
|
8
|
+
* Financial Document API version 1.10 document data.
|
|
9
9
|
*/
|
|
10
10
|
class FinancialDocumentV1Document {
|
|
11
11
|
constructor(rawPrediction, pageId) {
|
|
@@ -70,6 +70,14 @@ class FinancialDocumentV1Document {
|
|
|
70
70
|
this.locale = new standard_1.LocaleField({
|
|
71
71
|
prediction: rawPrediction["locale"],
|
|
72
72
|
});
|
|
73
|
+
this.paymentDate = new standard_1.DateField({
|
|
74
|
+
prediction: rawPrediction["payment_date"],
|
|
75
|
+
pageId: pageId,
|
|
76
|
+
});
|
|
77
|
+
this.poNumber = new standard_1.StringField({
|
|
78
|
+
prediction: rawPrediction["po_number"],
|
|
79
|
+
pageId: pageId,
|
|
80
|
+
});
|
|
73
81
|
this.receiptNumber = new standard_1.StringField({
|
|
74
82
|
prediction: rawPrediction["receipt_number"],
|
|
75
83
|
pageId: pageId,
|
|
@@ -163,11 +171,13 @@ class FinancialDocumentV1Document {
|
|
|
163
171
|
}
|
|
164
172
|
const outStr = `:Locale: ${this.locale}
|
|
165
173
|
:Invoice Number: ${this.invoiceNumber}
|
|
174
|
+
:Purchase Order Number: ${this.poNumber}
|
|
166
175
|
:Receipt Number: ${this.receiptNumber}
|
|
167
176
|
:Document Number: ${this.documentNumber}
|
|
168
177
|
:Reference Numbers: ${referenceNumbers}
|
|
169
178
|
:Purchase Date: ${this.date}
|
|
170
179
|
:Due Date: ${this.dueDate}
|
|
180
|
+
:Payment Date: ${this.paymentDate}
|
|
171
181
|
:Total Net: ${this.totalNet}
|
|
172
182
|
:Total Amount: ${this.totalAmount}
|
|
173
183
|
:Taxes: ${this.taxes}
|
|
@@ -2,7 +2,7 @@ import { Prediction, StringDict } from "../../parsing/common";
|
|
|
2
2
|
import { InvoiceV4LineItem } from "./invoiceV4LineItem";
|
|
3
3
|
import { AmountField, ClassificationField, CompanyRegistrationField, DateField, LocaleField, PaymentDetailsField, StringField, Taxes } from "../../parsing/standard";
|
|
4
4
|
/**
|
|
5
|
-
* Invoice API version 4.
|
|
5
|
+
* Invoice API version 4.8 document data.
|
|
6
6
|
*/
|
|
7
7
|
export declare class InvoiceV4Document implements Prediction {
|
|
8
8
|
/** The customer's address used for billing. */
|
|
@@ -27,6 +27,10 @@ export declare class InvoiceV4Document implements Prediction {
|
|
|
27
27
|
lineItems: InvoiceV4LineItem[];
|
|
28
28
|
/** The locale detected on the document. */
|
|
29
29
|
locale: LocaleField;
|
|
30
|
+
/** The date on which the payment is due/ was full-filled. */
|
|
31
|
+
paymentDate: DateField;
|
|
32
|
+
/** The purchase order number. */
|
|
33
|
+
poNumber: StringField;
|
|
30
34
|
/** List of Reference numbers, including PO number. */
|
|
31
35
|
referenceNumbers: StringField[];
|
|
32
36
|
/** Customer's delivery address. */
|
|
@@ -5,7 +5,7 @@ const common_1 = require("../../parsing/common");
|
|
|
5
5
|
const invoiceV4LineItem_1 = require("./invoiceV4LineItem");
|
|
6
6
|
const standard_1 = require("../../parsing/standard");
|
|
7
7
|
/**
|
|
8
|
-
* Invoice API version 4.
|
|
8
|
+
* Invoice API version 4.8 document data.
|
|
9
9
|
*/
|
|
10
10
|
class InvoiceV4Document {
|
|
11
11
|
constructor(rawPrediction, pageId) {
|
|
@@ -63,6 +63,14 @@ class InvoiceV4Document {
|
|
|
63
63
|
this.locale = new standard_1.LocaleField({
|
|
64
64
|
prediction: rawPrediction["locale"],
|
|
65
65
|
});
|
|
66
|
+
this.paymentDate = new standard_1.DateField({
|
|
67
|
+
prediction: rawPrediction["payment_date"],
|
|
68
|
+
pageId: pageId,
|
|
69
|
+
});
|
|
70
|
+
this.poNumber = new standard_1.StringField({
|
|
71
|
+
prediction: rawPrediction["po_number"],
|
|
72
|
+
pageId: pageId,
|
|
73
|
+
});
|
|
66
74
|
rawPrediction["reference_numbers"] &&
|
|
67
75
|
rawPrediction["reference_numbers"].map((itemPrediction) => this.referenceNumbers.push(new standard_1.StringField({
|
|
68
76
|
prediction: itemPrediction,
|
|
@@ -141,9 +149,11 @@ class InvoiceV4Document {
|
|
|
141
149
|
}
|
|
142
150
|
const outStr = `:Locale: ${this.locale}
|
|
143
151
|
:Invoice Number: ${this.invoiceNumber}
|
|
152
|
+
:Purchase Order Number: ${this.poNumber}
|
|
144
153
|
:Reference Numbers: ${referenceNumbers}
|
|
145
154
|
:Purchase Date: ${this.date}
|
|
146
155
|
:Due Date: ${this.dueDate}
|
|
156
|
+
:Payment Date: ${this.paymentDate}
|
|
147
157
|
:Total Net: ${this.totalNet}
|
|
148
158
|
:Total Amount: ${this.totalAmount}
|
|
149
159
|
:Total Tax: ${this.totalTax}
|