mindee 4.11.0 → 4.13.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 +16 -0
- package/package.json +1 -1
- package/src/client.d.ts +2 -1
- package/src/client.js +20 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/input/index.d.ts +1 -0
- package/src/input/index.js +3 -1
- package/src/input/localResponse.d.ts +33 -0
- package/src/input/localResponse.js +103 -0
- package/src/parsing/standard/base.d.ts +1 -1
- package/src/parsing/standard/boolean.d.ts +17 -0
- package/src/parsing/standard/boolean.js +22 -0
- package/src/parsing/standard/index.d.ts +1 -0
- package/src/parsing/standard/index.js +3 -1
- package/src/parsing/standard/locale.js +1 -1
- package/src/product/financialDocument/financialDocumentV1Document.d.ts +6 -2
- package/src/product/financialDocument/financialDocumentV1Document.js +11 -1
- package/src/product/receipt/receiptV5Document.d.ts +3 -1
- package/src/product/receipt/receiptV5Document.js +6 -1
- package/src/product/us/index.d.ts +1 -0
- package/src/product/us/index.js +3 -1
- package/src/product/us/internal.d.ts +2 -0
- package/src/product/us/internal.js +3 -1
- package/src/product/us/usMail/internal.d.ts +4 -0
- package/src/product/us/usMail/internal.js +11 -0
- package/src/product/us/usMail/usMailV2.d.ts +16 -0
- package/src/product/us/usMail/usMailV2.js +27 -0
- package/src/product/us/usMail/usMailV2Document.d.ts +22 -0
- package/src/product/us/usMail/usMailV2Document.js +62 -0
- package/src/product/us/usMail/usMailV2RecipientAddress.d.ts +40 -0
- package/src/product/us/usMail/usMailV2RecipientAddress.js +116 -0
- package/src/product/us/usMail/usMailV2SenderAddress.d.ts +36 -0
- package/src/product/us/usMail/usMailV2SenderAddress.js +92 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v4.13.0 - 2024-05-28
|
|
4
|
+
### Changes
|
|
5
|
+
* :sparkles: add support for local response loading
|
|
6
|
+
* :sparkles: add support for HMAC validation for webhooks
|
|
7
|
+
* :sparkles: add support for US Mail V2
|
|
8
|
+
* :sparkles: add support for boolean fields
|
|
9
|
+
|
|
10
|
+
### Fixes
|
|
11
|
+
* :recycle: fixed Locale display
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## v4.12.0 - 2024-05-16
|
|
15
|
+
### Changes
|
|
16
|
+
* :sparkles: update receipt to 5.2 and financial document to 1.7 (#270)
|
|
17
|
+
|
|
18
|
+
|
|
3
19
|
# v4.11.0 - 2024-04-30
|
|
4
20
|
### Changes
|
|
5
21
|
* :sparkles: update invoice to 4.6 & financial document to 1.6 (#269)
|
package/package.json
CHANGED
package/src/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import { Readable } from "stream";
|
|
5
|
-
import { Base64Input, BytesInput, InputSource, PathInput, StreamInput, PageOptions, UrlInput, BufferInput } from "./input";
|
|
5
|
+
import { Base64Input, BytesInput, InputSource, PathInput, StreamInput, PageOptions, UrlInput, BufferInput, LocalResponse } from "./input";
|
|
6
6
|
import { Endpoint } from "./http";
|
|
7
7
|
import { AsyncPredictResponse, FeedbackResponse, Inference, PredictResponse, StringDict } from "./parsing/common";
|
|
8
8
|
/**
|
|
@@ -111,6 +111,7 @@ export declare class Client {
|
|
|
111
111
|
* parsing is complete.
|
|
112
112
|
*/
|
|
113
113
|
parseQueued<T extends Inference>(productClass: new (httpResponse: StringDict) => T, queueId: string, params?: PredictOptions): Promise<AsyncPredictResponse<T>>;
|
|
114
|
+
loadPrediction<T extends Inference>(productClass: new (httpResponse: StringDict) => T, localResponse: LocalResponse): Promise<AsyncPredictResponse<T> | PredictResponse<T>>;
|
|
114
115
|
/**
|
|
115
116
|
* Fetch prediction results from a document already processed.
|
|
116
117
|
*
|
package/src/client.js
CHANGED
|
@@ -15,6 +15,7 @@ const logger_1 = require("./logger");
|
|
|
15
15
|
const inference_1 = require("./parsing/common/inference");
|
|
16
16
|
const product_1 = require("./product");
|
|
17
17
|
const promises_1 = require("node:timers/promises");
|
|
18
|
+
const errors_1 = require("./errors");
|
|
18
19
|
/**
|
|
19
20
|
* Mindee Client class that centralizes most basic operations.
|
|
20
21
|
*
|
|
@@ -103,6 +104,25 @@ class Client {
|
|
|
103
104
|
const docResponse = await endpoint.getQueuedDocument(queueId);
|
|
104
105
|
return new common_1.AsyncPredictResponse(productClass, docResponse.data);
|
|
105
106
|
}
|
|
107
|
+
async loadPrediction(productClass, localResponse) {
|
|
108
|
+
/**
|
|
109
|
+
* Load a prediction.
|
|
110
|
+
*
|
|
111
|
+
* @param productClass Product class to use for calling the API and parsing the response.
|
|
112
|
+
* @param localResponse Local response to load.
|
|
113
|
+
* @category Asynchronous
|
|
114
|
+
* @returns A valid prediction
|
|
115
|
+
*/
|
|
116
|
+
try {
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(localResponse.asDict(), "job")) {
|
|
118
|
+
return new common_1.AsyncPredictResponse(productClass, localResponse.asDict());
|
|
119
|
+
}
|
|
120
|
+
return new common_1.PredictResponse(productClass, localResponse.asDict());
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
throw new errors_1.MindeeError("No prediction found in local response.");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
106
126
|
/**
|
|
107
127
|
* Fetch prediction results from a document already processed.
|
|
108
128
|
*
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as product from "./product";
|
|
2
2
|
export { Client, PredictOptions } from "./client";
|
|
3
3
|
export { AsyncPredictResponse, PredictResponse, Inference, Prediction, Document, Page, } from "./parsing/common";
|
|
4
|
-
export { InputSource, PageOptionsOperation } from "./input";
|
|
4
|
+
export { InputSource, PageOptionsOperation, LocalResponse } from "./input";
|
|
5
5
|
export * as internal from "./internal";
|
|
6
6
|
export * as imageOperations from "./imageOperations";
|
package/src/index.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.imageOperations = exports.internal = exports.PageOptionsOperation = exports.InputSource = exports.Page = exports.Document = exports.Prediction = exports.Inference = exports.PredictResponse = exports.AsyncPredictResponse = exports.Client = exports.product = void 0;
|
|
26
|
+
exports.imageOperations = exports.internal = exports.LocalResponse = exports.PageOptionsOperation = exports.InputSource = exports.Page = exports.Document = exports.Prediction = exports.Inference = exports.PredictResponse = exports.AsyncPredictResponse = exports.Client = exports.product = void 0;
|
|
27
27
|
exports.product = __importStar(require("./product"));
|
|
28
28
|
var client_1 = require("./client");
|
|
29
29
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
@@ -37,5 +37,6 @@ Object.defineProperty(exports, "Page", { enumerable: true, get: function () { re
|
|
|
37
37
|
var input_1 = require("./input");
|
|
38
38
|
Object.defineProperty(exports, "InputSource", { enumerable: true, get: function () { return input_1.InputSource; } });
|
|
39
39
|
Object.defineProperty(exports, "PageOptionsOperation", { enumerable: true, get: function () { return input_1.PageOptionsOperation; } });
|
|
40
|
+
Object.defineProperty(exports, "LocalResponse", { enumerable: true, get: function () { return input_1.LocalResponse; } });
|
|
40
41
|
exports.internal = __importStar(require("./internal"));
|
|
41
42
|
exports.imageOperations = __importStar(require("./imageOperations"));
|
package/src/input/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { PageOptions, PageOptionsOperation } from "./pageOptions";
|
|
2
2
|
export { Base64Input, BytesInput, PathInput, StreamInput, UrlInput, BufferInput, } from "./sources";
|
|
3
3
|
export { InputSource, INPUT_TYPE_BASE64, INPUT_TYPE_BYTES, INPUT_TYPE_PATH, INPUT_TYPE_STREAM, INPUT_TYPE_BUFFER, } from "./base";
|
|
4
|
+
export { LocalResponse } from "./localResponse";
|
package/src/input/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INPUT_TYPE_BUFFER = exports.INPUT_TYPE_STREAM = exports.INPUT_TYPE_PATH = exports.INPUT_TYPE_BYTES = exports.INPUT_TYPE_BASE64 = exports.InputSource = exports.BufferInput = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.Base64Input = exports.PageOptionsOperation = void 0;
|
|
3
|
+
exports.LocalResponse = exports.INPUT_TYPE_BUFFER = exports.INPUT_TYPE_STREAM = exports.INPUT_TYPE_PATH = exports.INPUT_TYPE_BYTES = exports.INPUT_TYPE_BASE64 = exports.InputSource = exports.BufferInput = exports.UrlInput = exports.StreamInput = exports.PathInput = exports.BytesInput = exports.Base64Input = exports.PageOptionsOperation = void 0;
|
|
4
4
|
var pageOptions_1 = require("./pageOptions");
|
|
5
5
|
Object.defineProperty(exports, "PageOptionsOperation", { enumerable: true, get: function () { return pageOptions_1.PageOptionsOperation; } });
|
|
6
6
|
var sources_1 = require("./sources");
|
|
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "INPUT_TYPE_BYTES", { enumerable: true, get: func
|
|
|
17
17
|
Object.defineProperty(exports, "INPUT_TYPE_PATH", { enumerable: true, get: function () { return base_1.INPUT_TYPE_PATH; } });
|
|
18
18
|
Object.defineProperty(exports, "INPUT_TYPE_STREAM", { enumerable: true, get: function () { return base_1.INPUT_TYPE_STREAM; } });
|
|
19
19
|
Object.defineProperty(exports, "INPUT_TYPE_BUFFER", { enumerable: true, get: function () { return base_1.INPUT_TYPE_BUFFER; } });
|
|
20
|
+
var localResponse_1 = require("./localResponse");
|
|
21
|
+
Object.defineProperty(exports, "LocalResponse", { enumerable: true, get: function () { return localResponse_1.LocalResponse; } });
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { StringDict } from "../parsing/common";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
/**
|
|
5
|
+
* Local response loaded from a file.
|
|
6
|
+
*/
|
|
7
|
+
export declare class LocalResponse {
|
|
8
|
+
private file;
|
|
9
|
+
private readonly inputHandle;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of LocalResponse.
|
|
12
|
+
*/
|
|
13
|
+
constructor(inputFile: Buffer | string);
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the dictionary representation of the file.
|
|
17
|
+
* @returns A JSON-like object.
|
|
18
|
+
*/
|
|
19
|
+
asDict(): StringDict;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the HMAC signature of the local response, from the secret key provided.
|
|
22
|
+
* @param secretKey - Secret key, either a string or a byte/byte array.
|
|
23
|
+
* @returns The HMAC signature of the local response.
|
|
24
|
+
*/
|
|
25
|
+
getHmacSignature(secretKey: string | Buffer | Uint8Array): string;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the HMAC signature of the local response is valid.
|
|
28
|
+
* @param secretKey - Secret key, either a string or a byte/byte array.
|
|
29
|
+
* @param signature - The signature to be compared with.
|
|
30
|
+
* @returns True if the HMAC signature is valid.
|
|
31
|
+
*/
|
|
32
|
+
isValidHmacSignature(secretKey: string | Buffer | Uint8Array, signature: string): boolean;
|
|
33
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.LocalResponse = void 0;
|
|
27
|
+
const crypto = __importStar(require("crypto"));
|
|
28
|
+
const fs = __importStar(require("node:fs/promises"));
|
|
29
|
+
const errors_1 = require("../errors");
|
|
30
|
+
const buffer_1 = require("buffer");
|
|
31
|
+
/**
|
|
32
|
+
* Local response loaded from a file.
|
|
33
|
+
*/
|
|
34
|
+
class LocalResponse {
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of LocalResponse.
|
|
37
|
+
*/
|
|
38
|
+
constructor(inputFile) {
|
|
39
|
+
this.file = buffer_1.Buffer.alloc(0);
|
|
40
|
+
this.inputHandle = inputFile;
|
|
41
|
+
}
|
|
42
|
+
async init() {
|
|
43
|
+
/**
|
|
44
|
+
* @param inputFile - The input file, which can be a Buffer, string, or PathLike.
|
|
45
|
+
*/
|
|
46
|
+
if (buffer_1.Buffer.isBuffer(this.inputHandle)) {
|
|
47
|
+
this.file = this.inputHandle;
|
|
48
|
+
}
|
|
49
|
+
else if (typeof this.inputHandle === "string") {
|
|
50
|
+
let fileContents;
|
|
51
|
+
try {
|
|
52
|
+
await fs.access(this.inputHandle);
|
|
53
|
+
fileContents = await fs.readFile(this.inputHandle, { encoding: "utf-8" });
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
fileContents = this.inputHandle;
|
|
57
|
+
}
|
|
58
|
+
this.file = buffer_1.Buffer.from(fileContents.replace(/\r/g, "").replace(/\n/g, ""), "utf-8");
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new errors_1.MindeeError("Incompatible type for input.");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the dictionary representation of the file.
|
|
66
|
+
* @returns A JSON-like object.
|
|
67
|
+
*/
|
|
68
|
+
asDict() {
|
|
69
|
+
try {
|
|
70
|
+
const content = this.file.toString("utf-8");
|
|
71
|
+
return JSON.parse(content);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new errors_1.MindeeError("File is not a valid dictionary.");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the HMAC signature of the local response, from the secret key provided.
|
|
79
|
+
* @param secretKey - Secret key, either a string or a byte/byte array.
|
|
80
|
+
* @returns The HMAC signature of the local response.
|
|
81
|
+
*/
|
|
82
|
+
getHmacSignature(secretKey) {
|
|
83
|
+
const algorithm = "sha256";
|
|
84
|
+
try {
|
|
85
|
+
const hmac = crypto.createHmac(algorithm, secretKey);
|
|
86
|
+
hmac.update(this.file);
|
|
87
|
+
return hmac.digest("hex");
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new errors_1.MindeeError("Could not get HMAC signature from payload.");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Checks if the HMAC signature of the local response is valid.
|
|
95
|
+
* @param secretKey - Secret key, either a string or a byte/byte array.
|
|
96
|
+
* @param signature - The signature to be compared with.
|
|
97
|
+
* @returns True if the HMAC signature is valid.
|
|
98
|
+
*/
|
|
99
|
+
isValidHmacSignature(secretKey, signature) {
|
|
100
|
+
return signature === this.getHmacSignature(secretKey);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.LocalResponse = LocalResponse;
|
|
@@ -16,7 +16,7 @@ export interface BaseFieldConstructor {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class BaseField {
|
|
18
18
|
/** The value. */
|
|
19
|
-
value?: string | number;
|
|
19
|
+
value?: string | number | boolean;
|
|
20
20
|
/** `true` when the field was reconstructed or computed using other fields. */
|
|
21
21
|
reconstructed: boolean;
|
|
22
22
|
/** Page ID for multi-page document. */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StringDict } from "../common";
|
|
2
|
+
import { Field } from "./field";
|
|
3
|
+
export interface FieldConstructor {
|
|
4
|
+
prediction: StringDict;
|
|
5
|
+
valueKey?: string;
|
|
6
|
+
reconstructed?: boolean;
|
|
7
|
+
pageId?: number | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A field containing a text value.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BooleanField extends Field {
|
|
13
|
+
/** The value. */
|
|
14
|
+
value?: boolean;
|
|
15
|
+
constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanField = void 0;
|
|
4
|
+
const field_1 = require("./field");
|
|
5
|
+
/**
|
|
6
|
+
* A field containing a text value.
|
|
7
|
+
*/
|
|
8
|
+
class BooleanField extends field_1.Field {
|
|
9
|
+
constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
|
|
10
|
+
super({ prediction, valueKey, reconstructed, pageId });
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
if (this.value === true) {
|
|
14
|
+
return "True";
|
|
15
|
+
}
|
|
16
|
+
else if (this.value === false) {
|
|
17
|
+
return "False";
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.BooleanField = BooleanField;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { ClassificationField } from "./classification";
|
|
2
2
|
export { Taxes, TaxField } from "./tax";
|
|
3
3
|
export { PaymentDetailsField } from "./paymentDetails";
|
|
4
|
+
export { BooleanField } from "./boolean";
|
|
4
5
|
export { LocaleField } from "./locale";
|
|
5
6
|
export { AmountField, floatToString } from "./amount";
|
|
6
7
|
export { DateField } from "./date";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Field = exports.StringField = exports.PositionField = exports.CompanyRegistrationField = exports.BaseField = exports.DateField = exports.floatToString = exports.AmountField = exports.LocaleField = exports.PaymentDetailsField = exports.TaxField = exports.Taxes = exports.ClassificationField = void 0;
|
|
3
|
+
exports.Field = exports.StringField = exports.PositionField = exports.CompanyRegistrationField = exports.BaseField = exports.DateField = exports.floatToString = exports.AmountField = exports.LocaleField = exports.BooleanField = exports.PaymentDetailsField = exports.TaxField = exports.Taxes = exports.ClassificationField = void 0;
|
|
4
4
|
var classification_1 = require("./classification");
|
|
5
5
|
Object.defineProperty(exports, "ClassificationField", { enumerable: true, get: function () { return classification_1.ClassificationField; } });
|
|
6
6
|
var tax_1 = require("./tax");
|
|
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "Taxes", { enumerable: true, get: function () { r
|
|
|
8
8
|
Object.defineProperty(exports, "TaxField", { enumerable: true, get: function () { return tax_1.TaxField; } });
|
|
9
9
|
var paymentDetails_1 = require("./paymentDetails");
|
|
10
10
|
Object.defineProperty(exports, "PaymentDetailsField", { enumerable: true, get: function () { return paymentDetails_1.PaymentDetailsField; } });
|
|
11
|
+
var boolean_1 = require("./boolean");
|
|
12
|
+
Object.defineProperty(exports, "BooleanField", { enumerable: true, get: function () { return boolean_1.BooleanField; } });
|
|
11
13
|
var locale_1 = require("./locale");
|
|
12
14
|
Object.defineProperty(exports, "LocaleField", { enumerable: true, get: function () { return locale_1.LocaleField; } });
|
|
13
15
|
var amount_1 = require("./amount");
|
|
@@ -10,7 +10,7 @@ class LocaleField extends base_1.BaseField {
|
|
|
10
10
|
* @param {BaseFieldConstructor} constructor Constructor parameters.
|
|
11
11
|
*/
|
|
12
12
|
constructor({ prediction = {}, reconstructed = false, pageId = undefined, }) {
|
|
13
|
-
const valueKey = prediction["value"]
|
|
13
|
+
const valueKey = prediction["value"] ? "value" : "language";
|
|
14
14
|
super({ prediction, valueKey, reconstructed, pageId });
|
|
15
15
|
this.confidence = prediction["confidence"] ? prediction["confidence"] : 0.0;
|
|
16
16
|
this.language =
|
|
@@ -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.7 document data.
|
|
6
6
|
*/
|
|
7
7
|
export declare class FinancialDocumentV1Document implements Prediction {
|
|
8
8
|
/** The customer's address used for billing. */
|
|
@@ -19,16 +19,20 @@ export declare class FinancialDocumentV1Document implements Prediction {
|
|
|
19
19
|
customerName: StringField;
|
|
20
20
|
/** The date the purchase was made. */
|
|
21
21
|
date: DateField;
|
|
22
|
+
/** The document number or identifier. */
|
|
23
|
+
documentNumber: StringField;
|
|
22
24
|
/** One of: 'INVOICE', 'CREDIT NOTE', 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'. */
|
|
23
25
|
documentType: ClassificationField;
|
|
24
26
|
/** The date on which the payment is due. */
|
|
25
27
|
dueDate: DateField;
|
|
26
|
-
/** The invoice number or identifier. */
|
|
28
|
+
/** The invoice number or identifier only if document is an invoice. */
|
|
27
29
|
invoiceNumber: StringField;
|
|
28
30
|
/** List of line item details. */
|
|
29
31
|
lineItems: FinancialDocumentV1LineItem[];
|
|
30
32
|
/** The locale detected on the document. */
|
|
31
33
|
locale: LocaleField;
|
|
34
|
+
/** The receipt number or identifier only if document is a receipt. */
|
|
35
|
+
receiptNumber: StringField;
|
|
32
36
|
/** List of Reference numbers, including PO number. */
|
|
33
37
|
referenceNumbers: StringField[];
|
|
34
38
|
/** The customer's address used for shipping. */
|
|
@@ -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.7 document data.
|
|
9
9
|
*/
|
|
10
10
|
class FinancialDocumentV1Document {
|
|
11
11
|
constructor(rawPrediction, pageId) {
|
|
@@ -47,6 +47,10 @@ class FinancialDocumentV1Document {
|
|
|
47
47
|
prediction: rawPrediction["date"],
|
|
48
48
|
pageId: pageId,
|
|
49
49
|
});
|
|
50
|
+
this.documentNumber = new standard_1.StringField({
|
|
51
|
+
prediction: rawPrediction["document_number"],
|
|
52
|
+
pageId: pageId,
|
|
53
|
+
});
|
|
50
54
|
this.documentType = new standard_1.ClassificationField({
|
|
51
55
|
prediction: rawPrediction["document_type"],
|
|
52
56
|
});
|
|
@@ -66,6 +70,10 @@ class FinancialDocumentV1Document {
|
|
|
66
70
|
this.locale = new standard_1.LocaleField({
|
|
67
71
|
prediction: rawPrediction["locale"],
|
|
68
72
|
});
|
|
73
|
+
this.receiptNumber = new standard_1.StringField({
|
|
74
|
+
prediction: rawPrediction["receipt_number"],
|
|
75
|
+
pageId: pageId,
|
|
76
|
+
});
|
|
69
77
|
rawPrediction["reference_numbers"] &&
|
|
70
78
|
rawPrediction["reference_numbers"].map((itemPrediction) => this.referenceNumbers.push(new standard_1.StringField({
|
|
71
79
|
prediction: itemPrediction,
|
|
@@ -154,6 +162,8 @@ class FinancialDocumentV1Document {
|
|
|
154
162
|
}
|
|
155
163
|
const outStr = `:Locale: ${this.locale}
|
|
156
164
|
:Invoice Number: ${this.invoiceNumber}
|
|
165
|
+
:Receipt Number: ${this.receiptNumber}
|
|
166
|
+
:Document Number: ${this.documentNumber}
|
|
157
167
|
:Reference Numbers: ${referenceNumbers}
|
|
158
168
|
:Purchase Date: ${this.date}
|
|
159
169
|
:Due Date: ${this.dueDate}
|
|
@@ -2,7 +2,7 @@ import { Prediction, StringDict } from "../../parsing/common";
|
|
|
2
2
|
import { ReceiptV5LineItem } from "./receiptV5LineItem";
|
|
3
3
|
import { AmountField, ClassificationField, CompanyRegistrationField, DateField, LocaleField, StringField, Taxes } from "../../parsing/standard";
|
|
4
4
|
/**
|
|
5
|
-
* Receipt API version 5.
|
|
5
|
+
* Receipt API version 5.2 document data.
|
|
6
6
|
*/
|
|
7
7
|
export declare class ReceiptV5Document implements Prediction {
|
|
8
8
|
/** The purchase category among predefined classes. */
|
|
@@ -15,6 +15,8 @@ export declare class ReceiptV5Document implements Prediction {
|
|
|
15
15
|
lineItems: ReceiptV5LineItem[];
|
|
16
16
|
/** The locale detected on the document. */
|
|
17
17
|
locale: LocaleField;
|
|
18
|
+
/** The receipt number or identifier. */
|
|
19
|
+
receiptNumber: StringField;
|
|
18
20
|
/** The purchase subcategory among predefined classes for transport and food. */
|
|
19
21
|
subcategory: ClassificationField;
|
|
20
22
|
/** The address of the supplier or merchant. */
|
|
@@ -5,7 +5,7 @@ const common_1 = require("../../parsing/common");
|
|
|
5
5
|
const receiptV5LineItem_1 = require("./receiptV5LineItem");
|
|
6
6
|
const standard_1 = require("../../parsing/standard");
|
|
7
7
|
/**
|
|
8
|
-
* Receipt API version 5.
|
|
8
|
+
* Receipt API version 5.2 document data.
|
|
9
9
|
*/
|
|
10
10
|
class ReceiptV5Document {
|
|
11
11
|
constructor(rawPrediction, pageId) {
|
|
@@ -31,6 +31,10 @@ class ReceiptV5Document {
|
|
|
31
31
|
this.locale = new standard_1.LocaleField({
|
|
32
32
|
prediction: rawPrediction["locale"],
|
|
33
33
|
});
|
|
34
|
+
this.receiptNumber = new standard_1.StringField({
|
|
35
|
+
prediction: rawPrediction["receipt_number"],
|
|
36
|
+
pageId: pageId,
|
|
37
|
+
});
|
|
34
38
|
this.subcategory = new standard_1.ClassificationField({
|
|
35
39
|
prediction: rawPrediction["subcategory"],
|
|
36
40
|
});
|
|
@@ -104,6 +108,7 @@ class ReceiptV5Document {
|
|
|
104
108
|
:Supplier Company Registrations: ${supplierCompanyRegistrations}
|
|
105
109
|
:Supplier Address: ${this.supplierAddress}
|
|
106
110
|
:Supplier Phone Number: ${this.supplierPhoneNumber}
|
|
111
|
+
:Receipt Number: ${this.receiptNumber}
|
|
107
112
|
:Line Items: ${lineItemsSummary}`.trimEnd();
|
|
108
113
|
return (0, common_1.cleanOutString)(outStr);
|
|
109
114
|
}
|
package/src/product/us/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.W9V1 = exports.DriverLicenseV1 = exports.BankCheckV1 = void 0;
|
|
3
|
+
exports.UsMailV2 = exports.W9V1 = exports.DriverLicenseV1 = exports.BankCheckV1 = void 0;
|
|
4
4
|
var bankCheckV1_1 = require("./bankCheck/bankCheckV1");
|
|
5
5
|
Object.defineProperty(exports, "BankCheckV1", { enumerable: true, get: function () { return bankCheckV1_1.BankCheckV1; } });
|
|
6
6
|
var driverLicenseV1_1 = require("./driverLicense/driverLicenseV1");
|
|
7
7
|
Object.defineProperty(exports, "DriverLicenseV1", { enumerable: true, get: function () { return driverLicenseV1_1.DriverLicenseV1; } });
|
|
8
8
|
var w9V1_1 = require("./w9/w9V1");
|
|
9
9
|
Object.defineProperty(exports, "W9V1", { enumerable: true, get: function () { return w9V1_1.W9V1; } });
|
|
10
|
+
var usMailV2_1 = require("./usMail/usMailV2");
|
|
11
|
+
Object.defineProperty(exports, "UsMailV2", { enumerable: true, get: function () { return usMailV2_1.UsMailV2; } });
|
|
@@ -23,6 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.driverLicense = exports.bankCheck = void 0;
|
|
26
|
+
exports.w9 = exports.usMail = exports.driverLicense = exports.bankCheck = void 0;
|
|
27
27
|
exports.bankCheck = __importStar(require("./bankCheck/internal"));
|
|
28
28
|
exports.driverLicense = __importStar(require("./driverLicense/internal"));
|
|
29
|
+
exports.usMail = __importStar(require("./usMail/internal"));
|
|
30
|
+
exports.w9 = __importStar(require("./w9/internal"));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsMailV2SenderAddress = exports.UsMailV2RecipientAddress = exports.UsMailV2Document = exports.UsMailV2 = void 0;
|
|
4
|
+
var usMailV2_1 = require("./usMailV2");
|
|
5
|
+
Object.defineProperty(exports, "UsMailV2", { enumerable: true, get: function () { return usMailV2_1.UsMailV2; } });
|
|
6
|
+
var usMailV2Document_1 = require("./usMailV2Document");
|
|
7
|
+
Object.defineProperty(exports, "UsMailV2Document", { enumerable: true, get: function () { return usMailV2Document_1.UsMailV2Document; } });
|
|
8
|
+
var usMailV2RecipientAddress_1 = require("./usMailV2RecipientAddress");
|
|
9
|
+
Object.defineProperty(exports, "UsMailV2RecipientAddress", { enumerable: true, get: function () { return usMailV2RecipientAddress_1.UsMailV2RecipientAddress; } });
|
|
10
|
+
var usMailV2SenderAddress_1 = require("./usMailV2SenderAddress");
|
|
11
|
+
Object.defineProperty(exports, "UsMailV2SenderAddress", { enumerable: true, get: function () { return usMailV2SenderAddress_1.UsMailV2SenderAddress; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Inference, StringDict, Page } from "../../../parsing/common";
|
|
2
|
+
import { UsMailV2Document } from "./usMailV2Document";
|
|
3
|
+
/**
|
|
4
|
+
* US Mail API version 2 inference prediction.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UsMailV2 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: UsMailV2Document;
|
|
13
|
+
/** The document's pages. */
|
|
14
|
+
pages: Page<UsMailV2Document>[];
|
|
15
|
+
constructor(rawPrediction: StringDict);
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsMailV2 = void 0;
|
|
4
|
+
const common_1 = require("../../../parsing/common");
|
|
5
|
+
const usMailV2Document_1 = require("./usMailV2Document");
|
|
6
|
+
/**
|
|
7
|
+
* US Mail API version 2 inference prediction.
|
|
8
|
+
*/
|
|
9
|
+
class UsMailV2 extends common_1.Inference {
|
|
10
|
+
constructor(rawPrediction) {
|
|
11
|
+
super(rawPrediction);
|
|
12
|
+
/** The endpoint's name. */
|
|
13
|
+
this.endpointName = "us_mail";
|
|
14
|
+
/** The endpoint's version. */
|
|
15
|
+
this.endpointVersion = "2";
|
|
16
|
+
/** The document's pages. */
|
|
17
|
+
this.pages = [];
|
|
18
|
+
this.prediction = new usMailV2Document_1.UsMailV2Document(rawPrediction["prediction"]);
|
|
19
|
+
rawPrediction["pages"].forEach((page) => {
|
|
20
|
+
if (page.prediction !== undefined && page.prediction !== null &&
|
|
21
|
+
Object.keys(page.prediction).length > 0) {
|
|
22
|
+
this.pages.push(new common_1.Page(usMailV2Document_1.UsMailV2Document, page, page["id"], page["orientation"]));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.UsMailV2 = UsMailV2;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Prediction, StringDict } from "../../../parsing/common";
|
|
2
|
+
import { UsMailV2SenderAddress } from "./usMailV2SenderAddress";
|
|
3
|
+
import { UsMailV2RecipientAddress } from "./usMailV2RecipientAddress";
|
|
4
|
+
import { StringField } from "../../../parsing/standard";
|
|
5
|
+
/**
|
|
6
|
+
* US Mail API version 2.0 document data.
|
|
7
|
+
*/
|
|
8
|
+
export declare class UsMailV2Document implements Prediction {
|
|
9
|
+
/** The addresses of the recipients. */
|
|
10
|
+
recipientAddresses: UsMailV2RecipientAddress[];
|
|
11
|
+
/** The names of the recipients. */
|
|
12
|
+
recipientNames: StringField[];
|
|
13
|
+
/** The address of the sender. */
|
|
14
|
+
senderAddress: UsMailV2SenderAddress;
|
|
15
|
+
/** The name of the sender. */
|
|
16
|
+
senderName: StringField;
|
|
17
|
+
constructor(rawPrediction: StringDict, pageId?: number);
|
|
18
|
+
/**
|
|
19
|
+
* Default string representation.
|
|
20
|
+
*/
|
|
21
|
+
toString(): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsMailV2Document = void 0;
|
|
4
|
+
const common_1 = require("../../../parsing/common");
|
|
5
|
+
const usMailV2SenderAddress_1 = require("./usMailV2SenderAddress");
|
|
6
|
+
const usMailV2RecipientAddress_1 = require("./usMailV2RecipientAddress");
|
|
7
|
+
const standard_1 = require("../../../parsing/standard");
|
|
8
|
+
/**
|
|
9
|
+
* US Mail API version 2.0 document data.
|
|
10
|
+
*/
|
|
11
|
+
class UsMailV2Document {
|
|
12
|
+
constructor(rawPrediction, pageId) {
|
|
13
|
+
/** The addresses of the recipients. */
|
|
14
|
+
this.recipientAddresses = [];
|
|
15
|
+
/** The names of the recipients. */
|
|
16
|
+
this.recipientNames = [];
|
|
17
|
+
rawPrediction["recipient_addresses"] &&
|
|
18
|
+
rawPrediction["recipient_addresses"].map((itemPrediction) => this.recipientAddresses.push(new usMailV2RecipientAddress_1.UsMailV2RecipientAddress({
|
|
19
|
+
prediction: itemPrediction,
|
|
20
|
+
pageId: pageId,
|
|
21
|
+
})));
|
|
22
|
+
rawPrediction["recipient_names"] &&
|
|
23
|
+
rawPrediction["recipient_names"].map((itemPrediction) => this.recipientNames.push(new standard_1.StringField({
|
|
24
|
+
prediction: itemPrediction,
|
|
25
|
+
pageId: pageId,
|
|
26
|
+
})));
|
|
27
|
+
this.senderAddress = new usMailV2SenderAddress_1.UsMailV2SenderAddress({
|
|
28
|
+
prediction: rawPrediction["sender_address"],
|
|
29
|
+
pageId: pageId,
|
|
30
|
+
});
|
|
31
|
+
this.senderName = new standard_1.StringField({
|
|
32
|
+
prediction: rawPrediction["sender_name"],
|
|
33
|
+
pageId: pageId,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Default string representation.
|
|
38
|
+
*/
|
|
39
|
+
toString() {
|
|
40
|
+
const recipientNames = this.recipientNames.join("\n ");
|
|
41
|
+
let recipientAddressesSummary = "";
|
|
42
|
+
if (this.recipientAddresses && this.recipientAddresses.length > 0) {
|
|
43
|
+
const recipientAddressesColSizes = [17, 37, 19, 13, 24, 7, 27];
|
|
44
|
+
recipientAddressesSummary += "\n" + (0, common_1.lineSeparator)(recipientAddressesColSizes, "-") + "\n ";
|
|
45
|
+
recipientAddressesSummary += "| City ";
|
|
46
|
+
recipientAddressesSummary += "| Complete Address ";
|
|
47
|
+
recipientAddressesSummary += "| Is Address Change ";
|
|
48
|
+
recipientAddressesSummary += "| Postal Code ";
|
|
49
|
+
recipientAddressesSummary += "| Private Mailbox Number ";
|
|
50
|
+
recipientAddressesSummary += "| State ";
|
|
51
|
+
recipientAddressesSummary += "| Street ";
|
|
52
|
+
recipientAddressesSummary += "|\n" + (0, common_1.lineSeparator)(recipientAddressesColSizes, "=");
|
|
53
|
+
recipientAddressesSummary += this.recipientAddresses.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(recipientAddressesColSizes, "-")).join("");
|
|
54
|
+
}
|
|
55
|
+
const outStr = `:Sender Name: ${this.senderName}
|
|
56
|
+
:Sender Address: ${this.senderAddress.toFieldList()}
|
|
57
|
+
:Recipient Names: ${recipientNames}
|
|
58
|
+
:Recipient Addresses: ${recipientAddressesSummary}`.trimEnd();
|
|
59
|
+
return (0, common_1.cleanOutString)(outStr);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.UsMailV2Document = UsMailV2Document;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/common";
|
|
2
|
+
import { Polygon } from "../../../geometry";
|
|
3
|
+
/**
|
|
4
|
+
* The addresses of the recipients.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UsMailV2RecipientAddress {
|
|
7
|
+
#private;
|
|
8
|
+
/** The city of the recipient's address. */
|
|
9
|
+
city: string | undefined;
|
|
10
|
+
/** The complete address of the recipient. */
|
|
11
|
+
complete: string | undefined;
|
|
12
|
+
/** Indicates if the recipient's address is a change of address. */
|
|
13
|
+
isAddressChange: boolean | undefined;
|
|
14
|
+
/** The postal code of the recipient's address. */
|
|
15
|
+
postalCode: string | undefined;
|
|
16
|
+
/** The private mailbox number of the recipient's address. */
|
|
17
|
+
privateMailboxNumber: string | undefined;
|
|
18
|
+
/** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */
|
|
19
|
+
state: string | undefined;
|
|
20
|
+
/** The street of the recipient's address. */
|
|
21
|
+
street: string | undefined;
|
|
22
|
+
/** Confidence score */
|
|
23
|
+
confidence: number;
|
|
24
|
+
/** The document page on which the information was found. */
|
|
25
|
+
pageId: number;
|
|
26
|
+
/**
|
|
27
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
28
|
+
* the field in the document.
|
|
29
|
+
*/
|
|
30
|
+
polygon: Polygon;
|
|
31
|
+
constructor({ prediction }: StringDict);
|
|
32
|
+
/**
|
|
33
|
+
* Default string representation.
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
38
|
+
*/
|
|
39
|
+
toTableLine(): string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _UsMailV2RecipientAddress_instances, _UsMailV2RecipientAddress_printableValues;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.UsMailV2RecipientAddress = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* The addresses of the recipients.
|
|
12
|
+
*/
|
|
13
|
+
class UsMailV2RecipientAddress {
|
|
14
|
+
constructor({ prediction = {} }) {
|
|
15
|
+
_UsMailV2RecipientAddress_instances.add(this);
|
|
16
|
+
/** Confidence score */
|
|
17
|
+
this.confidence = 0.0;
|
|
18
|
+
/**
|
|
19
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
20
|
+
* the field in the document.
|
|
21
|
+
*/
|
|
22
|
+
this.polygon = [];
|
|
23
|
+
this.city = prediction["city"];
|
|
24
|
+
this.complete = prediction["complete"];
|
|
25
|
+
this.isAddressChange = prediction["is_address_change"];
|
|
26
|
+
this.postalCode = prediction["postal_code"];
|
|
27
|
+
this.privateMailboxNumber = prediction["private_mailbox_number"];
|
|
28
|
+
this.state = prediction["state"];
|
|
29
|
+
this.street = prediction["street"];
|
|
30
|
+
this.pageId = prediction["page_id"];
|
|
31
|
+
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
|
|
32
|
+
if (prediction["polygon"]) {
|
|
33
|
+
this.polygon = prediction.polygon;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Default string representation.
|
|
38
|
+
*/
|
|
39
|
+
toString() {
|
|
40
|
+
const printable = __classPrivateFieldGet(this, _UsMailV2RecipientAddress_instances, "m", _UsMailV2RecipientAddress_printableValues).call(this);
|
|
41
|
+
return ("City: " +
|
|
42
|
+
printable.city +
|
|
43
|
+
", Complete Address: " +
|
|
44
|
+
printable.complete +
|
|
45
|
+
", Is Address Change: " +
|
|
46
|
+
printable.isAddressChange +
|
|
47
|
+
", Postal Code: " +
|
|
48
|
+
printable.postalCode +
|
|
49
|
+
", Private Mailbox Number: " +
|
|
50
|
+
printable.privateMailboxNumber +
|
|
51
|
+
", State: " +
|
|
52
|
+
printable.state +
|
|
53
|
+
", Street: " +
|
|
54
|
+
printable.street);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Output in a format suitable for inclusion in an rST table.
|
|
58
|
+
*/
|
|
59
|
+
toTableLine() {
|
|
60
|
+
const printable = __classPrivateFieldGet(this, _UsMailV2RecipientAddress_instances, "m", _UsMailV2RecipientAddress_printableValues).call(this);
|
|
61
|
+
return ("| " +
|
|
62
|
+
printable.city.padEnd(15) +
|
|
63
|
+
" | " +
|
|
64
|
+
printable.complete.padEnd(35) +
|
|
65
|
+
" | " +
|
|
66
|
+
printable.isAddressChange.padEnd(17) +
|
|
67
|
+
" | " +
|
|
68
|
+
printable.postalCode.padEnd(11) +
|
|
69
|
+
" | " +
|
|
70
|
+
printable.privateMailboxNumber.padEnd(22) +
|
|
71
|
+
" | " +
|
|
72
|
+
printable.state.padEnd(5) +
|
|
73
|
+
" | " +
|
|
74
|
+
printable.street.padEnd(25) +
|
|
75
|
+
" |");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.UsMailV2RecipientAddress = UsMailV2RecipientAddress;
|
|
79
|
+
_UsMailV2RecipientAddress_instances = new WeakSet(), _UsMailV2RecipientAddress_printableValues = function _UsMailV2RecipientAddress_printableValues() {
|
|
80
|
+
return {
|
|
81
|
+
city: this.city ?
|
|
82
|
+
this.city.length <= 15 ?
|
|
83
|
+
this.city :
|
|
84
|
+
this.city.slice(0, 12) + "..." :
|
|
85
|
+
"",
|
|
86
|
+
complete: this.complete ?
|
|
87
|
+
this.complete.length <= 35 ?
|
|
88
|
+
this.complete :
|
|
89
|
+
this.complete.slice(0, 32) + "..." :
|
|
90
|
+
"",
|
|
91
|
+
isAddressChange: this.isAddressChange === true ?
|
|
92
|
+
"True" : this.isAddressChange === false ?
|
|
93
|
+
"False" :
|
|
94
|
+
"",
|
|
95
|
+
postalCode: this.postalCode ?
|
|
96
|
+
this.postalCode.length <= 11 ?
|
|
97
|
+
this.postalCode :
|
|
98
|
+
this.postalCode.slice(0, 8) + "..." :
|
|
99
|
+
"",
|
|
100
|
+
privateMailboxNumber: this.privateMailboxNumber ?
|
|
101
|
+
this.privateMailboxNumber.length <= 22 ?
|
|
102
|
+
this.privateMailboxNumber :
|
|
103
|
+
this.privateMailboxNumber.slice(0, 19) + "..." :
|
|
104
|
+
"",
|
|
105
|
+
state: this.state ?
|
|
106
|
+
this.state.length <= 5 ?
|
|
107
|
+
this.state :
|
|
108
|
+
this.state.slice(0, 2) + "..." :
|
|
109
|
+
"",
|
|
110
|
+
street: this.street ?
|
|
111
|
+
this.street.length <= 25 ?
|
|
112
|
+
this.street :
|
|
113
|
+
this.street.slice(0, 22) + "..." :
|
|
114
|
+
"",
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StringDict } from "../../../parsing/common";
|
|
2
|
+
import { Polygon } from "../../../geometry";
|
|
3
|
+
/**
|
|
4
|
+
* The address of the sender.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UsMailV2SenderAddress {
|
|
7
|
+
#private;
|
|
8
|
+
/** The city of the sender's address. */
|
|
9
|
+
city: string | undefined;
|
|
10
|
+
/** The complete address of the sender. */
|
|
11
|
+
complete: string | undefined;
|
|
12
|
+
/** The postal code of the sender's address. */
|
|
13
|
+
postalCode: string | undefined;
|
|
14
|
+
/** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */
|
|
15
|
+
state: string | undefined;
|
|
16
|
+
/** The street of the sender's address. */
|
|
17
|
+
street: string | undefined;
|
|
18
|
+
/** Confidence score */
|
|
19
|
+
confidence: number;
|
|
20
|
+
/** The document page on which the information was found. */
|
|
21
|
+
pageId: number;
|
|
22
|
+
/**
|
|
23
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
24
|
+
* the field in the document.
|
|
25
|
+
*/
|
|
26
|
+
polygon: Polygon;
|
|
27
|
+
constructor({ prediction }: StringDict);
|
|
28
|
+
/**
|
|
29
|
+
* Default string representation.
|
|
30
|
+
*/
|
|
31
|
+
toString(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Output in a format suitable for inclusion in a field list.
|
|
34
|
+
*/
|
|
35
|
+
toFieldList(): string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _UsMailV2SenderAddress_instances, _UsMailV2SenderAddress_printableValues;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.UsMailV2SenderAddress = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* The address of the sender.
|
|
12
|
+
*/
|
|
13
|
+
class UsMailV2SenderAddress {
|
|
14
|
+
constructor({ prediction = {} }) {
|
|
15
|
+
_UsMailV2SenderAddress_instances.add(this);
|
|
16
|
+
/** Confidence score */
|
|
17
|
+
this.confidence = 0.0;
|
|
18
|
+
/**
|
|
19
|
+
* Contains the relative vertices coordinates (points) of a polygon containing
|
|
20
|
+
* the field in the document.
|
|
21
|
+
*/
|
|
22
|
+
this.polygon = [];
|
|
23
|
+
this.city = prediction["city"];
|
|
24
|
+
this.complete = prediction["complete"];
|
|
25
|
+
this.postalCode = prediction["postal_code"];
|
|
26
|
+
this.state = prediction["state"];
|
|
27
|
+
this.street = prediction["street"];
|
|
28
|
+
this.pageId = prediction["page_id"];
|
|
29
|
+
this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
|
|
30
|
+
if (prediction["polygon"]) {
|
|
31
|
+
this.polygon = prediction.polygon;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default string representation.
|
|
36
|
+
*/
|
|
37
|
+
toString() {
|
|
38
|
+
const printable = __classPrivateFieldGet(this, _UsMailV2SenderAddress_instances, "m", _UsMailV2SenderAddress_printableValues).call(this);
|
|
39
|
+
return ("City: " +
|
|
40
|
+
printable.city +
|
|
41
|
+
", Complete Address: " +
|
|
42
|
+
printable.complete +
|
|
43
|
+
", Postal Code: " +
|
|
44
|
+
printable.postalCode +
|
|
45
|
+
", State: " +
|
|
46
|
+
printable.state +
|
|
47
|
+
", Street: " +
|
|
48
|
+
printable.street);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Output in a format suitable for inclusion in a field list.
|
|
52
|
+
*/
|
|
53
|
+
toFieldList() {
|
|
54
|
+
const printable = __classPrivateFieldGet(this, _UsMailV2SenderAddress_instances, "m", _UsMailV2SenderAddress_printableValues).call(this);
|
|
55
|
+
return `
|
|
56
|
+
:City: ${printable.city}
|
|
57
|
+
:Complete Address: ${printable.complete}
|
|
58
|
+
:Postal Code: ${printable.postalCode}
|
|
59
|
+
:State: ${printable.state}
|
|
60
|
+
:Street: ${printable.street}`.trimEnd();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.UsMailV2SenderAddress = UsMailV2SenderAddress;
|
|
64
|
+
_UsMailV2SenderAddress_instances = new WeakSet(), _UsMailV2SenderAddress_printableValues = function _UsMailV2SenderAddress_printableValues() {
|
|
65
|
+
return {
|
|
66
|
+
city: this.city ?
|
|
67
|
+
this.city.length <= 15 ?
|
|
68
|
+
this.city :
|
|
69
|
+
this.city.slice(0, 12) + "..." :
|
|
70
|
+
"",
|
|
71
|
+
complete: this.complete ?
|
|
72
|
+
this.complete.length <= 35 ?
|
|
73
|
+
this.complete :
|
|
74
|
+
this.complete.slice(0, 32) + "..." :
|
|
75
|
+
"",
|
|
76
|
+
postalCode: this.postalCode ?
|
|
77
|
+
this.postalCode.length <= 11 ?
|
|
78
|
+
this.postalCode :
|
|
79
|
+
this.postalCode.slice(0, 8) + "..." :
|
|
80
|
+
"",
|
|
81
|
+
state: this.state ?
|
|
82
|
+
this.state.length <= 5 ?
|
|
83
|
+
this.state :
|
|
84
|
+
this.state.slice(0, 2) + "..." :
|
|
85
|
+
"",
|
|
86
|
+
street: this.street ?
|
|
87
|
+
this.street.length <= 25 ?
|
|
88
|
+
this.street :
|
|
89
|
+
this.street.slice(0, 22) + "..." :
|
|
90
|
+
"",
|
|
91
|
+
};
|
|
92
|
+
};
|