mindee 4.30.0 → 4.31.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.31.1 - 2025-10-08
4
+ ### Fixes
5
+ * :bug: make sure input sources are only initialized once
6
+
7
+
8
+ ## v4.31.0 - 2025-10-07
9
+ ### Changes
10
+ * :sparkles: allow comparing v2 field confidence
11
+ * :coffin: remove obsolete US Mail V2
12
+
13
+
3
14
  ## v4.30.0 - 2025-09-04
4
15
  ### Changes
5
16
  * :sparkles: add support for inference options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.30.0",
3
+ "version": "4.31.1",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
package/src/clientV2.js CHANGED
@@ -46,9 +46,7 @@ class ClientV2 {
46
46
  if (inputSource === undefined) {
47
47
  throw new Error("The 'enqueue' function requires an input document.");
48
48
  }
49
- if (!inputSource.isInitialized()) {
50
- await inputSource.init();
51
- }
49
+ await inputSource.init();
52
50
  return await this.mindeeApi.reqPostInferenceEnqueue(inputSource, params);
53
51
  }
54
52
  /**
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Base64Input = void 0;
4
4
  const localInputSource_1 = require("./localInputSource");
5
5
  const inputSource_1 = require("./inputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class Base64Input extends localInputSource_1.LocalInputSource {
7
8
  constructor({ inputString, filename }) {
8
9
  super({
@@ -13,6 +14,10 @@ class Base64Input extends localInputSource_1.LocalInputSource {
13
14
  this.inputString = inputString;
14
15
  }
15
16
  async init() {
17
+ if (this.initialized) {
18
+ return;
19
+ }
20
+ logger_1.logger.debug("Loading from base64");
16
21
  this.fileObject = Buffer.from(this.inputString, "base64");
17
22
  this.mimeType = await this.checkMimetype();
18
23
  // clear out the string
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BufferInput = void 0;
4
4
  const localInputSource_1 = require("./localInputSource");
5
5
  const inputSource_1 = require("./inputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class BufferInput extends localInputSource_1.LocalInputSource {
7
8
  constructor({ buffer, filename }) {
8
9
  super({
@@ -12,6 +13,10 @@ class BufferInput extends localInputSource_1.LocalInputSource {
12
13
  this.filename = filename;
13
14
  }
14
15
  async init() {
16
+ if (this.initialized) {
17
+ return;
18
+ }
19
+ logger_1.logger.debug("Loading from buffer");
15
20
  this.mimeType = await this.checkMimetype();
16
21
  this.initialized = true;
17
22
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BytesInput = void 0;
4
4
  const inputSource_1 = require("./inputSource");
5
5
  const localInputSource_1 = require("./localInputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class BytesInput extends localInputSource_1.LocalInputSource {
7
8
  constructor({ inputBytes, filename }) {
8
9
  super({
@@ -13,6 +14,10 @@ class BytesInput extends localInputSource_1.LocalInputSource {
13
14
  this.inputBytes = inputBytes;
14
15
  }
15
16
  async init() {
17
+ if (this.initialized) {
18
+ return;
19
+ }
20
+ logger_1.logger.debug("Loading from bytes");
16
21
  this.fileObject = Buffer.from(this.inputBytes);
17
22
  this.mimeType = await this.checkMimetype();
18
23
  this.inputBytes = new Uint8Array(0);
@@ -19,7 +19,10 @@ class PathInput extends localInputSource_1.LocalInputSource {
19
19
  this.filename = path_1.default.basename(this.inputPath);
20
20
  }
21
21
  async init() {
22
- logger_1.logger.debug(`Loading from: ${this.inputPath}`);
22
+ if (this.initialized) {
23
+ return;
24
+ }
25
+ logger_1.logger.debug(`Loading from path: ${this.inputPath}`);
23
26
  this.fileObject = Buffer.from(await fs_1.promises.readFile(this.inputPath));
24
27
  this.mimeType = await this.checkMimetype();
25
28
  this.initialized = true;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StreamInput = void 0;
4
4
  const localInputSource_1 = require("./localInputSource");
5
5
  const inputSource_1 = require("./inputSource");
6
+ const logger_1 = require("../../logger");
6
7
  class StreamInput extends localInputSource_1.LocalInputSource {
7
8
  constructor({ inputStream, filename }) {
8
9
  super({
@@ -13,6 +14,10 @@ class StreamInput extends localInputSource_1.LocalInputSource {
13
14
  this.inputStream = inputStream;
14
15
  }
15
16
  async init() {
17
+ if (this.initialized) {
18
+ return;
19
+ }
20
+ logger_1.logger.debug("Loading from stream");
16
21
  this.fileObject = await this.stream2buffer(this.inputStream);
17
22
  this.mimeType = await this.checkMimetype();
18
23
  this.initialized = true;
@@ -8,12 +8,17 @@ const crypto_1 = require("crypto");
8
8
  const promises_1 = require("fs/promises");
9
9
  const https_1 = require("https");
10
10
  const bytesInput_1 = require("./bytesInput");
11
+ const logger_1 = require("../../logger");
11
12
  class UrlInput extends inputSource_1.InputSource {
12
13
  constructor({ url }) {
13
14
  super();
14
15
  this.url = url;
15
16
  }
16
17
  async init() {
18
+ if (this.initialized) {
19
+ return;
20
+ }
21
+ logger_1.logger.debug(`source URL: ${this.url}`);
17
22
  if (!this.url.toLowerCase().startsWith("https")) {
18
23
  throw new Error("URL must be HTTPS");
19
24
  }
@@ -7,3 +7,39 @@ export declare enum FieldConfidence {
7
7
  Medium = "Medium",
8
8
  Low = "Low"
9
9
  }
10
+ export declare namespace FieldConfidence {
11
+ /**
12
+ * Converts a FieldConfidence value to an integer.
13
+ * @param confidence The FieldConfidence value to convert
14
+ * @returns Integer representation (Certain=4, High=3, Medium=2, Low=1)
15
+ */
16
+ function toInt(confidence: FieldConfidence | undefined): number;
17
+ /**
18
+ * Checks if the first FieldConfidence is greater than the second.
19
+ * @param a First FieldConfidence value
20
+ * @param b Second FieldConfidence value
21
+ * @returns true if a > b
22
+ */
23
+ function greaterThan(a: FieldConfidence | undefined, b: FieldConfidence | undefined): boolean;
24
+ /**
25
+ * Checks if the first FieldConfidence is greater than or equal to the second.
26
+ * @param a First FieldConfidence value
27
+ * @param b Second FieldConfidence value
28
+ * @returns true if a >= b
29
+ */
30
+ function greaterThanOrEqual(a: FieldConfidence | undefined, b: FieldConfidence | undefined): boolean;
31
+ /**
32
+ * Checks if the first FieldConfidence is less than the second.
33
+ * @param a First FieldConfidence value
34
+ * @param b Second FieldConfidence value
35
+ * @returns true if a < b
36
+ */
37
+ function lessThan(a: FieldConfidence | undefined, b: FieldConfidence | undefined): boolean;
38
+ /**
39
+ * Checks if the first FieldConfidence is less than or equal to the second.
40
+ * @param a First FieldConfidence value
41
+ * @param b Second FieldConfidence value
42
+ * @returns true if a <= b
43
+ */
44
+ function lessThanOrEqual(a: FieldConfidence | undefined, b: FieldConfidence | undefined): boolean;
45
+ }
@@ -12,3 +12,66 @@ var FieldConfidence;
12
12
  FieldConfidence["Medium"] = "Medium";
13
13
  FieldConfidence["Low"] = "Low";
14
14
  })(FieldConfidence || (exports.FieldConfidence = FieldConfidence = {}));
15
+ // eslint-disable-next-line @typescript-eslint/no-namespace
16
+ (function (FieldConfidence) {
17
+ /**
18
+ * Converts a FieldConfidence value to an integer.
19
+ * @param confidence The FieldConfidence value to convert
20
+ * @returns Integer representation (Certain=4, High=3, Medium=2, Low=1)
21
+ */
22
+ function toInt(confidence) {
23
+ switch (confidence) {
24
+ case FieldConfidence.Certain:
25
+ return 4;
26
+ case FieldConfidence.High:
27
+ return 3;
28
+ case FieldConfidence.Medium:
29
+ return 2;
30
+ case FieldConfidence.Low:
31
+ return 1;
32
+ default:
33
+ throw new Error(`Unknown FieldConfidence value: ${confidence}`);
34
+ }
35
+ }
36
+ FieldConfidence.toInt = toInt;
37
+ /**
38
+ * Checks if the first FieldConfidence is greater than the second.
39
+ * @param a First FieldConfidence value
40
+ * @param b Second FieldConfidence value
41
+ * @returns true if a > b
42
+ */
43
+ function greaterThan(a, b) {
44
+ return toInt(a) > toInt(b);
45
+ }
46
+ FieldConfidence.greaterThan = greaterThan;
47
+ /**
48
+ * Checks if the first FieldConfidence is greater than or equal to the second.
49
+ * @param a First FieldConfidence value
50
+ * @param b Second FieldConfidence value
51
+ * @returns true if a >= b
52
+ */
53
+ function greaterThanOrEqual(a, b) {
54
+ return toInt(a) >= toInt(b);
55
+ }
56
+ FieldConfidence.greaterThanOrEqual = greaterThanOrEqual;
57
+ /**
58
+ * Checks if the first FieldConfidence is less than the second.
59
+ * @param a First FieldConfidence value
60
+ * @param b Second FieldConfidence value
61
+ * @returns true if a < b
62
+ */
63
+ function lessThan(a, b) {
64
+ return toInt(a) < toInt(b);
65
+ }
66
+ FieldConfidence.lessThan = lessThan;
67
+ /**
68
+ * Checks if the first FieldConfidence is less than or equal to the second.
69
+ * @param a First FieldConfidence value
70
+ * @param b Second FieldConfidence value
71
+ * @returns true if a <= b
72
+ */
73
+ function lessThanOrEqual(a, b) {
74
+ return toInt(a) <= toInt(b);
75
+ }
76
+ FieldConfidence.lessThanOrEqual = lessThanOrEqual;
77
+ })(FieldConfidence || (exports.FieldConfidence = FieldConfidence = {}));
@@ -1,4 +1,3 @@
1
1
  export { BankCheckV1 } from "./bankCheck/bankCheckV1";
2
2
  export { HealthcareCardV1 } from "./healthcareCard/healthcareCardV1";
3
- export { UsMailV2 } from "./usMail/usMailV2";
4
3
  export { UsMailV3 } from "./usMail/usMailV3";
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsMailV3 = exports.UsMailV2 = exports.HealthcareCardV1 = exports.BankCheckV1 = void 0;
3
+ exports.UsMailV3 = exports.HealthcareCardV1 = 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 healthcareCardV1_1 = require("./healthcareCard/healthcareCardV1");
7
7
  Object.defineProperty(exports, "HealthcareCardV1", { enumerable: true, get: function () { return healthcareCardV1_1.HealthcareCardV1; } });
8
- var usMailV2_1 = require("./usMail/usMailV2");
9
- Object.defineProperty(exports, "UsMailV2", { enumerable: true, get: function () { return usMailV2_1.UsMailV2; } });
10
8
  var usMailV3_1 = require("./usMail/usMailV3");
11
9
  Object.defineProperty(exports, "UsMailV3", { enumerable: true, get: function () { return usMailV3_1.UsMailV3; } });
@@ -1,2 +1 @@
1
- export { UsMailV2 } from "./usMailV2";
2
1
  export { UsMailV3 } from "./usMailV3";
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsMailV3 = exports.UsMailV2 = void 0;
4
- var usMailV2_1 = require("./usMailV2");
5
- Object.defineProperty(exports, "UsMailV2", { enumerable: true, get: function () { return usMailV2_1.UsMailV2; } });
3
+ exports.UsMailV3 = void 0;
6
4
  var usMailV3_1 = require("./usMailV3");
7
5
  Object.defineProperty(exports, "UsMailV3", { enumerable: true, get: function () { return usMailV3_1.UsMailV3; } });
@@ -1,7 +1,3 @@
1
- export { UsMailV2 } from "./usMailV2";
2
- export { UsMailV2Document } from "./usMailV2Document";
3
- export { UsMailV2RecipientAddress } from "./usMailV2RecipientAddress";
4
- export { UsMailV2SenderAddress } from "./usMailV2SenderAddress";
5
1
  export { UsMailV3 } from "./usMailV3";
6
2
  export { UsMailV3Document } from "./usMailV3Document";
7
3
  export { UsMailV3RecipientAddress } from "./usMailV3RecipientAddress";
@@ -1,14 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsMailV3SenderAddress = exports.UsMailV3RecipientAddress = exports.UsMailV3Document = exports.UsMailV3 = 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; } });
3
+ exports.UsMailV3SenderAddress = exports.UsMailV3RecipientAddress = exports.UsMailV3Document = exports.UsMailV3 = void 0;
12
4
  var usMailV3_1 = require("./usMailV3");
13
5
  Object.defineProperty(exports, "UsMailV3", { enumerable: true, get: function () { return usMailV3_1.UsMailV3; } });
14
6
  var usMailV3Document_1 = require("./usMailV3Document");
@@ -1,16 +0,0 @@
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
- }
@@ -1,27 +0,0 @@
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;
@@ -1,22 +0,0 @@
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
- }
@@ -1,62 +0,0 @@
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;
@@ -1,40 +0,0 @@
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 | null;
10
- /** The complete address of the recipient. */
11
- complete: string | null;
12
- /** Indicates if the recipient's address is a change of address. */
13
- isAddressChange: boolean | null;
14
- /** The postal code of the recipient's address. */
15
- postalCode: string | null;
16
- /** The private mailbox number of the recipient's address. */
17
- privateMailboxNumber: string | null;
18
- /** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */
19
- state: string | null;
20
- /** The street of the recipient's address. */
21
- street: string | null;
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
- }
@@ -1,119 +0,0 @@
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
- const common_1 = require("../../../parsing/common");
11
- const geometry_1 = require("../../../geometry");
12
- /**
13
- * The addresses of the recipients.
14
- */
15
- class UsMailV2RecipientAddress {
16
- constructor({ prediction = {} }) {
17
- _UsMailV2RecipientAddress_instances.add(this);
18
- /** Confidence score */
19
- this.confidence = 0.0;
20
- /**
21
- * Contains the relative vertices coordinates (points) of a polygon containing
22
- * the field in the document.
23
- */
24
- this.polygon = new geometry_1.Polygon();
25
- this.city = prediction["city"];
26
- this.complete = prediction["complete"];
27
- this.isAddressChange = prediction["is_address_change"];
28
- this.postalCode = prediction["postal_code"];
29
- this.privateMailboxNumber = prediction["private_mailbox_number"];
30
- this.state = prediction["state"];
31
- this.street = prediction["street"];
32
- this.pageId = prediction["page_id"];
33
- this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
34
- if (prediction["polygon"]) {
35
- this.polygon = prediction.polygon;
36
- }
37
- }
38
- /**
39
- * Default string representation.
40
- */
41
- toString() {
42
- const printable = __classPrivateFieldGet(this, _UsMailV2RecipientAddress_instances, "m", _UsMailV2RecipientAddress_printableValues).call(this);
43
- return ("City: " +
44
- printable.city +
45
- ", Complete Address: " +
46
- printable.complete +
47
- ", Is Address Change: " +
48
- printable.isAddressChange +
49
- ", Postal Code: " +
50
- printable.postalCode +
51
- ", Private Mailbox Number: " +
52
- printable.privateMailboxNumber +
53
- ", State: " +
54
- printable.state +
55
- ", Street: " +
56
- printable.street);
57
- }
58
- /**
59
- * Output in a format suitable for inclusion in an rST table.
60
- */
61
- toTableLine() {
62
- const printable = __classPrivateFieldGet(this, _UsMailV2RecipientAddress_instances, "m", _UsMailV2RecipientAddress_printableValues).call(this);
63
- return ("| " +
64
- printable.city.padEnd(15) +
65
- " | " +
66
- printable.complete.padEnd(35) +
67
- " | " +
68
- printable.isAddressChange.padEnd(17) +
69
- " | " +
70
- printable.postalCode.padEnd(11) +
71
- " | " +
72
- printable.privateMailboxNumber.padEnd(22) +
73
- " | " +
74
- printable.state.padEnd(5) +
75
- " | " +
76
- printable.street.padEnd(25) +
77
- " |");
78
- }
79
- }
80
- exports.UsMailV2RecipientAddress = UsMailV2RecipientAddress;
81
- _UsMailV2RecipientAddress_instances = new WeakSet(), _UsMailV2RecipientAddress_printableValues = function _UsMailV2RecipientAddress_printableValues() {
82
- return {
83
- city: this.city ?
84
- this.city.length <= 15 ?
85
- (0, common_1.cleanSpecialChars)(this.city) :
86
- (0, common_1.cleanSpecialChars)(this.city).slice(0, 12) + "..." :
87
- "",
88
- complete: this.complete ?
89
- this.complete.length <= 35 ?
90
- (0, common_1.cleanSpecialChars)(this.complete) :
91
- (0, common_1.cleanSpecialChars)(this.complete).slice(0, 32) + "..." :
92
- "",
93
- isAddressChange: this.isAddressChange === true ?
94
- "True" :
95
- this.isAddressChange === false ?
96
- "False" :
97
- "",
98
- postalCode: this.postalCode ?
99
- this.postalCode.length <= 11 ?
100
- (0, common_1.cleanSpecialChars)(this.postalCode) :
101
- (0, common_1.cleanSpecialChars)(this.postalCode).slice(0, 8) + "..." :
102
- "",
103
- privateMailboxNumber: this.privateMailboxNumber ?
104
- this.privateMailboxNumber.length <= 22 ?
105
- (0, common_1.cleanSpecialChars)(this.privateMailboxNumber) :
106
- (0, common_1.cleanSpecialChars)(this.privateMailboxNumber).slice(0, 19) + "..." :
107
- "",
108
- state: this.state ?
109
- this.state.length <= 5 ?
110
- (0, common_1.cleanSpecialChars)(this.state) :
111
- (0, common_1.cleanSpecialChars)(this.state).slice(0, 2) + "..." :
112
- "",
113
- street: this.street ?
114
- this.street.length <= 25 ?
115
- (0, common_1.cleanSpecialChars)(this.street) :
116
- (0, common_1.cleanSpecialChars)(this.street).slice(0, 22) + "..." :
117
- "",
118
- };
119
- };
@@ -1,36 +0,0 @@
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 | null;
10
- /** The complete address of the sender. */
11
- complete: string | null;
12
- /** The postal code of the sender's address. */
13
- postalCode: string | null;
14
- /** Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. */
15
- state: string | null;
16
- /** The street of the sender's address. */
17
- street: string | null;
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
- }
@@ -1,73 +0,0 @@
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
- const geometry_1 = require("../../../geometry");
11
- /**
12
- * The address of the sender.
13
- */
14
- class UsMailV2SenderAddress {
15
- constructor({ prediction = {} }) {
16
- _UsMailV2SenderAddress_instances.add(this);
17
- /** Confidence score */
18
- this.confidence = 0.0;
19
- /**
20
- * Contains the relative vertices coordinates (points) of a polygon containing
21
- * the field in the document.
22
- */
23
- this.polygon = new geometry_1.Polygon();
24
- this.city = prediction["city"];
25
- this.complete = prediction["complete"];
26
- this.postalCode = prediction["postal_code"];
27
- this.state = prediction["state"];
28
- this.street = prediction["street"];
29
- this.pageId = prediction["page_id"];
30
- this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
31
- if (prediction["polygon"]) {
32
- this.polygon = prediction.polygon;
33
- }
34
- }
35
- /**
36
- * Default string representation.
37
- */
38
- toString() {
39
- const printable = __classPrivateFieldGet(this, _UsMailV2SenderAddress_instances, "m", _UsMailV2SenderAddress_printableValues).call(this);
40
- return ("City: " +
41
- printable.city +
42
- ", Complete Address: " +
43
- printable.complete +
44
- ", Postal Code: " +
45
- printable.postalCode +
46
- ", State: " +
47
- printable.state +
48
- ", Street: " +
49
- printable.street);
50
- }
51
- /**
52
- * Output in a format suitable for inclusion in a field list.
53
- */
54
- toFieldList() {
55
- const printable = __classPrivateFieldGet(this, _UsMailV2SenderAddress_instances, "m", _UsMailV2SenderAddress_printableValues).call(this);
56
- return `
57
- :City: ${printable.city}
58
- :Complete Address: ${printable.complete}
59
- :Postal Code: ${printable.postalCode}
60
- :State: ${printable.state}
61
- :Street: ${printable.street}`.trimEnd();
62
- }
63
- }
64
- exports.UsMailV2SenderAddress = UsMailV2SenderAddress;
65
- _UsMailV2SenderAddress_instances = new WeakSet(), _UsMailV2SenderAddress_printableValues = function _UsMailV2SenderAddress_printableValues() {
66
- return {
67
- city: this.city ?? "",
68
- complete: this.complete ?? "",
69
- postalCode: this.postalCode ?? "",
70
- state: this.state ?? "",
71
- street: this.street ?? "",
72
- };
73
- };