mindee 4.15.0 → 4.17.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/package.json +1 -1
  3. package/src/parsing/common/index.d.ts +1 -0
  4. package/src/parsing/common/index.js +4 -1
  5. package/src/parsing/common/summaryHelper.d.ts +10 -0
  6. package/src/parsing/common/summaryHelper.js +27 -1
  7. package/src/parsing/standard/amount.d.ts +0 -1
  8. package/src/parsing/standard/amount.js +4 -11
  9. package/src/parsing/standard/date.d.ts +2 -0
  10. package/src/parsing/standard/date.js +4 -2
  11. package/src/parsing/standard/index.d.ts +1 -1
  12. package/src/parsing/standard/index.js +1 -2
  13. package/src/parsing/standard/tax.js +4 -4
  14. package/src/product/billOfLading/billOfLadingV1.d.ts +16 -0
  15. package/src/product/billOfLading/billOfLadingV1.js +27 -0
  16. package/src/product/billOfLading/billOfLadingV1Carrier.d.ts +32 -0
  17. package/src/product/billOfLading/billOfLadingV1Carrier.js +62 -0
  18. package/src/product/billOfLading/billOfLadingV1CarrierItem.d.ts +38 -0
  19. package/src/product/billOfLading/billOfLadingV1CarrierItem.js +117 -0
  20. package/src/product/billOfLading/billOfLadingV1Consignee.d.ts +34 -0
  21. package/src/product/billOfLading/billOfLadingV1Consignee.js +67 -0
  22. package/src/product/billOfLading/billOfLadingV1Document.d.ts +39 -0
  23. package/src/product/billOfLading/billOfLadingV1Document.js +95 -0
  24. package/src/product/billOfLading/billOfLadingV1NotifyParty.d.ts +34 -0
  25. package/src/product/billOfLading/billOfLadingV1NotifyParty.js +67 -0
  26. package/src/product/billOfLading/billOfLadingV1Shipper.d.ts +34 -0
  27. package/src/product/billOfLading/billOfLadingV1Shipper.js +67 -0
  28. package/src/product/billOfLading/index.d.ts +1 -0
  29. package/src/product/billOfLading/index.js +5 -0
  30. package/src/product/billOfLading/internal.d.ts +7 -0
  31. package/src/product/billOfLading/internal.js +17 -0
  32. package/src/product/financialDocument/financialDocumentV1Document.d.ts +5 -1
  33. package/src/product/financialDocument/financialDocumentV1Document.js +11 -1
  34. package/src/product/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
  35. package/src/product/financialDocument/financialDocumentV1LineItem.js +47 -22
  36. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +4 -4
  37. package/src/product/fr/energyBill/energyBillV1.d.ts +16 -0
  38. package/src/product/fr/energyBill/energyBillV1.js +27 -0
  39. package/src/product/fr/energyBill/energyBillV1Document.d.ts +49 -0
  40. package/src/product/fr/energyBill/energyBillV1Document.js +143 -0
  41. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.d.ts +30 -0
  42. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.js +57 -0
  43. package/src/product/fr/energyBill/energyBillV1EnergySupplier.d.ts +30 -0
  44. package/src/product/fr/energyBill/energyBillV1EnergySupplier.js +57 -0
  45. package/src/product/fr/energyBill/energyBillV1EnergyUsage.d.ts +38 -0
  46. package/src/product/fr/energyBill/energyBillV1EnergyUsage.js +117 -0
  47. package/src/product/fr/energyBill/energyBillV1MeterDetail.d.ts +32 -0
  48. package/src/product/fr/energyBill/energyBillV1MeterDetail.js +62 -0
  49. package/src/product/fr/energyBill/energyBillV1Subscription.d.ts +38 -0
  50. package/src/product/fr/energyBill/energyBillV1Subscription.js +117 -0
  51. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.d.ts +38 -0
  52. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.js +117 -0
  53. package/src/product/fr/energyBill/index.d.ts +1 -0
  54. package/src/product/fr/energyBill/index.js +5 -0
  55. package/src/product/fr/energyBill/internal.d.ts +8 -0
  56. package/src/product/fr/energyBill/internal.js +19 -0
  57. package/src/product/fr/index.d.ts +2 -0
  58. package/src/product/fr/index.js +5 -1
  59. package/src/product/fr/internal.d.ts +2 -0
  60. package/src/product/fr/internal.js +3 -1
  61. package/src/product/fr/payslip/index.d.ts +1 -0
  62. package/src/product/fr/payslip/index.js +5 -0
  63. package/src/product/fr/payslip/internal.d.ts +10 -0
  64. package/src/product/fr/payslip/internal.js +23 -0
  65. package/src/product/fr/payslip/payslipV2.d.ts +16 -0
  66. package/src/product/fr/payslip/payslipV2.js +27 -0
  67. package/src/product/fr/payslip/payslipV2BankAccountDetail.d.ts +32 -0
  68. package/src/product/fr/payslip/payslipV2BankAccountDetail.js +62 -0
  69. package/src/product/fr/payslip/payslipV2Document.d.ts +35 -0
  70. package/src/product/fr/payslip/payslipV2Document.js +80 -0
  71. package/src/product/fr/payslip/payslipV2Employee.d.ts +40 -0
  72. package/src/product/fr/payslip/payslipV2Employee.js +82 -0
  73. package/src/product/fr/payslip/payslipV2Employer.d.ts +40 -0
  74. package/src/product/fr/payslip/payslipV2Employer.js +82 -0
  75. package/src/product/fr/payslip/payslipV2Employment.d.ts +38 -0
  76. package/src/product/fr/payslip/payslipV2Employment.js +85 -0
  77. package/src/product/fr/payslip/payslipV2PayDetail.d.ts +46 -0
  78. package/src/product/fr/payslip/payslipV2PayDetail.js +168 -0
  79. package/src/product/fr/payslip/payslipV2PayPeriod.d.ts +36 -0
  80. package/src/product/fr/payslip/payslipV2PayPeriod.js +72 -0
  81. package/src/product/fr/payslip/payslipV2Pto.d.ts +32 -0
  82. package/src/product/fr/payslip/payslipV2Pto.js +84 -0
  83. package/src/product/fr/payslip/payslipV2SalaryDetail.d.ts +34 -0
  84. package/src/product/fr/payslip/payslipV2SalaryDetail.js +97 -0
  85. package/src/product/index.d.ts +2 -0
  86. package/src/product/index.js +5 -1
  87. package/src/product/internal.d.ts +2 -0
  88. package/src/product/internal.js +3 -1
  89. package/src/product/invoice/invoiceV4Document.d.ts +5 -1
  90. package/src/product/invoice/invoiceV4Document.js +11 -1
  91. package/src/product/invoice/invoiceV4LineItem.d.ts +8 -8
  92. package/src/product/invoice/invoiceV4LineItem.js +47 -22
  93. package/src/product/nutritionFactsLabel/index.d.ts +1 -0
  94. package/src/product/nutritionFactsLabel/index.js +5 -0
  95. package/src/product/nutritionFactsLabel/internal.d.ts +15 -0
  96. package/src/product/nutritionFactsLabel/internal.js +33 -0
  97. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1.d.ts +16 -0
  98. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1.js +27 -0
  99. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.d.ts +32 -0
  100. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.js +84 -0
  101. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.d.ts +32 -0
  102. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.js +84 -0
  103. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.d.ts +32 -0
  104. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.js +84 -0
  105. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.d.ts +32 -0
  106. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.js +84 -0
  107. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.d.ts +53 -0
  108. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.js +117 -0
  109. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.d.ts +36 -0
  110. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.js +107 -0
  111. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.d.ts +32 -0
  112. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.js +84 -0
  113. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.d.ts +32 -0
  114. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.js +84 -0
  115. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.d.ts +30 -0
  116. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.js +65 -0
  117. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.d.ts +34 -0
  118. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.js +89 -0
  119. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.d.ts +32 -0
  120. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.js +84 -0
  121. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.d.ts +32 -0
  122. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.js +84 -0
  123. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.d.ts +32 -0
  124. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.js +84 -0
  125. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.d.ts +32 -0
  126. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.js +84 -0
  127. package/src/product/receipt/receiptV5LineItem.d.ts +4 -4
  128. package/src/product/receipt/receiptV5LineItem.js +27 -12
  129. package/src/product/resume/resumeV1Certificate.d.ts +4 -4
  130. package/src/product/resume/resumeV1Certificate.js +9 -8
  131. package/src/product/resume/resumeV1Education.d.ts +7 -7
  132. package/src/product/resume/resumeV1Education.js +15 -14
  133. package/src/product/resume/resumeV1Language.d.ts +2 -2
  134. package/src/product/resume/resumeV1Language.js +5 -4
  135. package/src/product/resume/resumeV1ProfessionalExperience.d.ts +8 -8
  136. package/src/product/resume/resumeV1ProfessionalExperience.js +17 -16
  137. package/src/product/resume/resumeV1SocialNetworksUrl.d.ts +2 -2
  138. package/src/product/resume/resumeV1SocialNetworksUrl.js +5 -4
  139. package/src/product/us/healthcareCard/healthcareCardV1Copay.d.ts +2 -2
  140. package/src/product/us/healthcareCard/healthcareCardV1Copay.js +11 -6
  141. package/src/product/us/usMail/index.d.ts +1 -0
  142. package/src/product/us/usMail/index.js +5 -0
  143. package/src/product/us/usMail/usMailV2RecipientAddress.d.ts +7 -7
  144. package/src/product/us/usMail/usMailV2RecipientAddress.js +17 -15
  145. package/src/product/us/usMail/usMailV2SenderAddress.d.ts +5 -5
  146. package/src/product/us/usMail/usMailV2SenderAddress.js +5 -25
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.17.0 - 2024-10-11
4
+ ### Changes
5
+ * :sparkles: add support for Financial Document v1.10
6
+ * :sparkles: add support for Invoice v4.8
7
+
8
+
9
+ ## v4.16.0 - 2024-09-17
10
+ ### Changes
11
+ * :sparkles: add support for US Mail V2
12
+ * :sparkles: add support for Bill of Lading V1
13
+ * :sparkles: add support for FR Energy Bill V1
14
+ * :sparkles: add support for FR Payslips V1
15
+ * :sparkles: add support for Nutrition Facts Label V1
16
+ * :recycle: refactor internals to accommodate for new changes
17
+
18
+ ### Fixes
19
+ * :bug: fix float numbers not containing more 3 decimals in some instances
20
+ * :bug: fix boolean field display issues
21
+ * :bug: fix values being extracted as `undefined` instead of `null`, as is present in the initial prediction.
22
+
23
+
3
24
  ## v4.15.0 - 2024-09-12
4
25
  ### Changes
5
26
  * :sparkles: add support for full text OCR extraction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindee",
3
- "version": "4.15.0",
3
+ "version": "4.17.0",
4
4
  "description": "Mindee Client Library for Node.js",
5
5
  "main": "src/index.js",
6
6
  "bin": "bin/mindee.js",
@@ -9,3 +9,4 @@ export { Prediction } from "./prediction";
9
9
  export { Page } from "./page";
10
10
  export { cleanOutString, lineSeparator } from "./summaryHelper";
11
11
  export * as extras from "./extras";
12
+ export { floatToString, cleanSpecialChars } from "./summaryHelper";
@@ -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.extras = exports.lineSeparator = exports.cleanOutString = exports.Page = exports.Prediction = exports.PredictResponse = exports.AsyncPredictResponse = exports.Inference = exports.OrientationField = exports.FeedbackResponse = exports.Document = void 0;
26
+ exports.cleanSpecialChars = exports.floatToString = exports.extras = exports.lineSeparator = exports.cleanOutString = exports.Page = exports.Prediction = exports.PredictResponse = exports.AsyncPredictResponse = exports.Inference = exports.OrientationField = exports.FeedbackResponse = exports.Document = void 0;
27
27
  var document_1 = require("./document");
28
28
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
29
29
  var feedbackResponse_1 = require("./feedback/feedbackResponse");
@@ -44,3 +44,6 @@ var summaryHelper_1 = require("./summaryHelper");
44
44
  Object.defineProperty(exports, "cleanOutString", { enumerable: true, get: function () { return summaryHelper_1.cleanOutString; } });
45
45
  Object.defineProperty(exports, "lineSeparator", { enumerable: true, get: function () { return summaryHelper_1.lineSeparator; } });
46
46
  exports.extras = __importStar(require("./extras"));
47
+ var summaryHelper_2 = require("./summaryHelper");
48
+ Object.defineProperty(exports, "floatToString", { enumerable: true, get: function () { return summaryHelper_2.floatToString; } });
49
+ Object.defineProperty(exports, "cleanSpecialChars", { enumerable: true, get: function () { return summaryHelper_2.cleanSpecialChars; } });
@@ -6,3 +6,13 @@ export declare function cleanOutString(outStr: string): string;
6
6
  * @returns A separator for table lines
7
7
  */
8
8
  export declare function lineSeparator(columnSizes: number[], separator: string): string;
9
+ /**
10
+ * Replaces all special characters like \n, \r, \t, with an equivalent that can be displayed on a single line.
11
+ * Also trims line breaks at the end of the string.
12
+ * @param outStr
13
+ */
14
+ export declare function cleanSpecialChars(outStr: string): string;
15
+ /**
16
+ * Return a float as a string with at least 2 levels of precision.
17
+ */
18
+ export declare function floatToString(value: number | null): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lineSeparator = exports.cleanOutString = void 0;
3
+ exports.floatToString = exports.cleanSpecialChars = exports.lineSeparator = exports.cleanOutString = void 0;
4
4
  function cleanOutString(outStr) {
5
5
  const lines = / \n/gm;
6
6
  return outStr.replace(lines, "\n");
@@ -20,3 +20,29 @@ function lineSeparator(columnSizes, separator) {
20
20
  return outStr;
21
21
  }
22
22
  exports.lineSeparator = lineSeparator;
23
+ /**
24
+ * Replaces all special characters like \n, \r, \t, with an equivalent that can be displayed on a single line.
25
+ * Also trims line breaks at the end of the string.
26
+ * @param outStr
27
+ */
28
+ function cleanSpecialChars(outStr) {
29
+ return outStr
30
+ .replace(/\n/g, "\\n")
31
+ .replace(/\r/g, "\\r")
32
+ .replace(/\t/g, "\\t");
33
+ }
34
+ exports.cleanSpecialChars = cleanSpecialChars;
35
+ /**
36
+ * Return a float as a string with at least 2 levels of precision.
37
+ */
38
+ function floatToString(value) {
39
+ if (value === null) {
40
+ return "";
41
+ }
42
+ return value.toLocaleString(undefined, {
43
+ minimumFractionDigits: 2,
44
+ maximumFractionDigits: 5,
45
+ useGrouping: false,
46
+ });
47
+ }
48
+ exports.floatToString = floatToString;
@@ -1,6 +1,5 @@
1
1
  import { Field } from "./field";
2
2
  import { BaseFieldConstructor } from "./base";
3
- export declare function floatToString(value: number): string;
4
3
  /**
5
4
  * A field containing an amount value.
6
5
  */
@@ -1,15 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AmountField = exports.floatToString = void 0;
3
+ exports.AmountField = void 0;
4
4
  const field_1 = require("./field");
5
- function floatToString(value) {
6
- return value.toLocaleString(undefined, {
7
- minimumFractionDigits: 2,
8
- maximumFractionDigits: 3,
9
- useGrouping: false,
10
- });
11
- }
12
- exports.floatToString = floatToString;
5
+ const common_1 = require("../common");
13
6
  /**
14
7
  * A field containing an amount value.
15
8
  */
@@ -21,7 +14,7 @@ class AmountField extends field_1.Field {
21
14
  super({ prediction, valueKey, reconstructed, pageId });
22
15
  /** The value. */
23
16
  this.value = undefined;
24
- this.value = +parseFloat(prediction[valueKey]).toFixed(3);
17
+ this.value = +parseFloat(prediction[valueKey]);
25
18
  if (isNaN(this.value)) {
26
19
  this.value = undefined;
27
20
  this.confidence = 0.0;
@@ -32,7 +25,7 @@ class AmountField extends field_1.Field {
32
25
  */
33
26
  toString() {
34
27
  if (this.value !== undefined) {
35
- return floatToString(this.value);
28
+ return (0, common_1.floatToString)(this.value);
36
29
  }
37
30
  return "";
38
31
  }
@@ -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
- const check = date1.getFullYear() === date2.getFullYear() &&
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;
@@ -3,7 +3,7 @@ export { Taxes, TaxField } from "./tax";
3
3
  export { PaymentDetailsField } from "./paymentDetails";
4
4
  export { BooleanField } from "./boolean";
5
5
  export { LocaleField } from "./locale";
6
- export { AmountField, floatToString } from "./amount";
6
+ export { AmountField } from "./amount";
7
7
  export { DateField } from "./date";
8
8
  export { BaseField, BaseFieldConstructor } from "./base";
9
9
  export { Word } from "./word";
@@ -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.BooleanField = exports.PaymentDetailsField = exports.TaxField = exports.Taxes = exports.ClassificationField = void 0;
3
+ exports.Field = exports.StringField = exports.PositionField = exports.CompanyRegistrationField = exports.BaseField = exports.DateField = 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");
@@ -14,7 +14,6 @@ var locale_1 = require("./locale");
14
14
  Object.defineProperty(exports, "LocaleField", { enumerable: true, get: function () { return locale_1.LocaleField; } });
15
15
  var amount_1 = require("./amount");
16
16
  Object.defineProperty(exports, "AmountField", { enumerable: true, get: function () { return amount_1.AmountField; } });
17
- Object.defineProperty(exports, "floatToString", { enumerable: true, get: function () { return amount_1.floatToString; } });
18
17
  var date_1 = require("./date");
19
18
  Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return date_1.DateField; } });
20
19
  var base_1 = require("./base");
@@ -7,8 +7,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
7
7
  var _TaxField_instances, _TaxField_printableValues, _Taxes_instances, _Taxes_lineSeparator;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Taxes = exports.TaxField = void 0;
10
+ const common_1 = require("../common");
10
11
  const field_1 = require("./field");
11
- const amount_1 = require("./amount");
12
12
  /**
13
13
  * Represent a single tax line.
14
14
  */
@@ -77,9 +77,9 @@ exports.TaxField = TaxField;
77
77
  _TaxField_instances = new WeakSet(), _TaxField_printableValues = function _TaxField_printableValues() {
78
78
  return {
79
79
  code: this.code ?? "",
80
- base: this.base !== undefined ? (0, amount_1.floatToString)(this.base) : "",
81
- rate: this.rate !== undefined ? (0, amount_1.floatToString)(this.rate) : "",
82
- value: this.value !== undefined ? (0, amount_1.floatToString)(this.value) : "",
80
+ base: this.base !== undefined ? (0, common_1.floatToString)(this.base) : "",
81
+ rate: this.rate !== undefined ? (0, common_1.floatToString)(this.rate) : "",
82
+ value: this.value !== undefined ? (0, common_1.floatToString)(this.value) : "",
83
83
  };
84
84
  };
85
85
  /**
@@ -0,0 +1,16 @@
1
+ import { Inference, StringDict, Page } from "../../parsing/common";
2
+ import { BillOfLadingV1Document } from "./billOfLadingV1Document";
3
+ /**
4
+ * Bill of Lading API version 1 inference prediction.
5
+ */
6
+ export declare class BillOfLadingV1 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: BillOfLadingV1Document;
13
+ /** The document's pages. */
14
+ pages: Page<BillOfLadingV1Document>[];
15
+ constructor(rawPrediction: StringDict);
16
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillOfLadingV1 = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const billOfLadingV1Document_1 = require("./billOfLadingV1Document");
6
+ /**
7
+ * Bill of Lading API version 1 inference prediction.
8
+ */
9
+ class BillOfLadingV1 extends common_1.Inference {
10
+ constructor(rawPrediction) {
11
+ super(rawPrediction);
12
+ /** The endpoint's name. */
13
+ this.endpointName = "bill_of_lading";
14
+ /** The endpoint's version. */
15
+ this.endpointVersion = "1";
16
+ /** The document's pages. */
17
+ this.pages = [];
18
+ this.prediction = new billOfLadingV1Document_1.BillOfLadingV1Document(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(billOfLadingV1Document_1.BillOfLadingV1Document, page, page["id"], page["orientation"]));
23
+ }
24
+ });
25
+ }
26
+ }
27
+ exports.BillOfLadingV1 = BillOfLadingV1;
@@ -0,0 +1,32 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The shipping company responsible for transporting the goods.
5
+ */
6
+ export declare class BillOfLadingV1Carrier {
7
+ #private;
8
+ /** The name of the carrier. */
9
+ name: string | null;
10
+ /** The professional number of the carrier. */
11
+ professionalNumber: string | null;
12
+ /** The Standard Carrier Alpha Code (SCAC) of the carrier. */
13
+ scac: string | null;
14
+ /** Confidence score */
15
+ confidence: number;
16
+ /** The document page on which the information was found. */
17
+ pageId: number;
18
+ /**
19
+ * Contains the relative vertices coordinates (points) of a polygon containing
20
+ * the field in the document.
21
+ */
22
+ polygon: Polygon;
23
+ constructor({ prediction }: StringDict);
24
+ /**
25
+ * Default string representation.
26
+ */
27
+ toString(): string;
28
+ /**
29
+ * Output in a format suitable for inclusion in a field list.
30
+ */
31
+ toFieldList(): string;
32
+ }
@@ -0,0 +1,62 @@
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 _BillOfLadingV1Carrier_instances, _BillOfLadingV1Carrier_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BillOfLadingV1Carrier = void 0;
10
+ /**
11
+ * The shipping company responsible for transporting the goods.
12
+ */
13
+ class BillOfLadingV1Carrier {
14
+ constructor({ prediction = {} }) {
15
+ _BillOfLadingV1Carrier_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.name = prediction["name"];
24
+ this.professionalNumber = prediction["professional_number"];
25
+ this.scac = prediction["scac"];
26
+ this.pageId = prediction["page_id"];
27
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
28
+ if (prediction["polygon"]) {
29
+ this.polygon = prediction.polygon;
30
+ }
31
+ }
32
+ /**
33
+ * Default string representation.
34
+ */
35
+ toString() {
36
+ const printable = __classPrivateFieldGet(this, _BillOfLadingV1Carrier_instances, "m", _BillOfLadingV1Carrier_printableValues).call(this);
37
+ return ("Name: " +
38
+ printable.name +
39
+ ", Professional Number: " +
40
+ printable.professionalNumber +
41
+ ", SCAC: " +
42
+ printable.scac);
43
+ }
44
+ /**
45
+ * Output in a format suitable for inclusion in a field list.
46
+ */
47
+ toFieldList() {
48
+ const printable = __classPrivateFieldGet(this, _BillOfLadingV1Carrier_instances, "m", _BillOfLadingV1Carrier_printableValues).call(this);
49
+ return `
50
+ :Name: ${printable.name}
51
+ :Professional Number: ${printable.professionalNumber}
52
+ :SCAC: ${printable.scac}`.trimEnd();
53
+ }
54
+ }
55
+ exports.BillOfLadingV1Carrier = BillOfLadingV1Carrier;
56
+ _BillOfLadingV1Carrier_instances = new WeakSet(), _BillOfLadingV1Carrier_printableValues = function _BillOfLadingV1Carrier_printableValues() {
57
+ return {
58
+ name: this.name ?? "",
59
+ professionalNumber: this.professionalNumber ?? "",
60
+ scac: this.scac ?? "",
61
+ };
62
+ };
@@ -0,0 +1,38 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The goods being shipped.
5
+ */
6
+ export declare class BillOfLadingV1CarrierItem {
7
+ #private;
8
+ /** A description of the item. */
9
+ description: string | null;
10
+ /** The gross weight of the item. */
11
+ grossWeight: number | null;
12
+ /** The measurement of the item. */
13
+ measurement: number | null;
14
+ /** The unit of measurement for the measurement. */
15
+ measurementUnit: string | null;
16
+ /** The quantity of the item being shipped. */
17
+ quantity: number | null;
18
+ /** The unit of measurement for weights. */
19
+ weightUnit: string | null;
20
+ /** Confidence score */
21
+ confidence: number;
22
+ /** The document page on which the information was found. */
23
+ pageId: number;
24
+ /**
25
+ * Contains the relative vertices coordinates (points) of a polygon containing
26
+ * the field in the document.
27
+ */
28
+ polygon: Polygon;
29
+ constructor({ prediction }: StringDict);
30
+ /**
31
+ * Default string representation.
32
+ */
33
+ toString(): string;
34
+ /**
35
+ * Output in a format suitable for inclusion in an rST table.
36
+ */
37
+ toTableLine(): string;
38
+ }
@@ -0,0 +1,117 @@
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 _BillOfLadingV1CarrierItem_instances, _BillOfLadingV1CarrierItem_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BillOfLadingV1CarrierItem = void 0;
10
+ const common_1 = require("../../parsing/common");
11
+ /**
12
+ * The goods being shipped.
13
+ */
14
+ class BillOfLadingV1CarrierItem {
15
+ constructor({ prediction = {} }) {
16
+ _BillOfLadingV1CarrierItem_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 = [];
24
+ this.description = prediction["description"];
25
+ if (prediction["gross_weight"] !== undefined &&
26
+ prediction["gross_weight"] !== null &&
27
+ !isNaN(prediction["gross_weight"])) {
28
+ this.grossWeight = +parseFloat(prediction["gross_weight"]);
29
+ }
30
+ else {
31
+ this.grossWeight = null;
32
+ }
33
+ if (prediction["measurement"] !== undefined &&
34
+ prediction["measurement"] !== null &&
35
+ !isNaN(prediction["measurement"])) {
36
+ this.measurement = +parseFloat(prediction["measurement"]);
37
+ }
38
+ else {
39
+ this.measurement = null;
40
+ }
41
+ this.measurementUnit = prediction["measurement_unit"];
42
+ if (prediction["quantity"] !== undefined &&
43
+ prediction["quantity"] !== null &&
44
+ !isNaN(prediction["quantity"])) {
45
+ this.quantity = +parseFloat(prediction["quantity"]);
46
+ }
47
+ else {
48
+ this.quantity = null;
49
+ }
50
+ this.weightUnit = prediction["weight_unit"];
51
+ this.pageId = prediction["page_id"];
52
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
53
+ if (prediction["polygon"]) {
54
+ this.polygon = prediction.polygon;
55
+ }
56
+ }
57
+ /**
58
+ * Default string representation.
59
+ */
60
+ toString() {
61
+ const printable = __classPrivateFieldGet(this, _BillOfLadingV1CarrierItem_instances, "m", _BillOfLadingV1CarrierItem_printableValues).call(this);
62
+ return ("Description: " +
63
+ printable.description +
64
+ ", Gross Weight: " +
65
+ printable.grossWeight +
66
+ ", Measurement: " +
67
+ printable.measurement +
68
+ ", Measurement Unit: " +
69
+ printable.measurementUnit +
70
+ ", Quantity: " +
71
+ printable.quantity +
72
+ ", Weight Unit: " +
73
+ printable.weightUnit);
74
+ }
75
+ /**
76
+ * Output in a format suitable for inclusion in an rST table.
77
+ */
78
+ toTableLine() {
79
+ const printable = __classPrivateFieldGet(this, _BillOfLadingV1CarrierItem_instances, "m", _BillOfLadingV1CarrierItem_printableValues).call(this);
80
+ return ("| " +
81
+ printable.description.padEnd(36) +
82
+ " | " +
83
+ printable.grossWeight.padEnd(12) +
84
+ " | " +
85
+ printable.measurement.padEnd(11) +
86
+ " | " +
87
+ printable.measurementUnit.padEnd(16) +
88
+ " | " +
89
+ printable.quantity.padEnd(8) +
90
+ " | " +
91
+ printable.weightUnit.padEnd(11) +
92
+ " |");
93
+ }
94
+ }
95
+ exports.BillOfLadingV1CarrierItem = BillOfLadingV1CarrierItem;
96
+ _BillOfLadingV1CarrierItem_instances = new WeakSet(), _BillOfLadingV1CarrierItem_printableValues = function _BillOfLadingV1CarrierItem_printableValues() {
97
+ return {
98
+ description: this.description ?
99
+ this.description.length <= 36 ?
100
+ (0, common_1.cleanSpecialChars)(this.description) :
101
+ (0, common_1.cleanSpecialChars)(this.description).slice(0, 33) + "..." :
102
+ "",
103
+ grossWeight: this.grossWeight !== undefined ? (0, common_1.floatToString)(this.grossWeight) : "",
104
+ measurement: this.measurement !== undefined ? (0, common_1.floatToString)(this.measurement) : "",
105
+ measurementUnit: this.measurementUnit ?
106
+ this.measurementUnit.length <= 16 ?
107
+ (0, common_1.cleanSpecialChars)(this.measurementUnit) :
108
+ (0, common_1.cleanSpecialChars)(this.measurementUnit).slice(0, 13) + "..." :
109
+ "",
110
+ quantity: this.quantity !== undefined ? (0, common_1.floatToString)(this.quantity) : "",
111
+ weightUnit: this.weightUnit ?
112
+ this.weightUnit.length <= 11 ?
113
+ (0, common_1.cleanSpecialChars)(this.weightUnit) :
114
+ (0, common_1.cleanSpecialChars)(this.weightUnit).slice(0, 8) + "..." :
115
+ "",
116
+ };
117
+ };
@@ -0,0 +1,34 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The party to whom the goods are being shipped.
5
+ */
6
+ export declare class BillOfLadingV1Consignee {
7
+ #private;
8
+ /** The address of the consignee. */
9
+ address: string | null;
10
+ /** The email of the shipper. */
11
+ email: string | null;
12
+ /** The name of the consignee. */
13
+ name: string | null;
14
+ /** The phone number of the consignee. */
15
+ phone: string | null;
16
+ /** Confidence score */
17
+ confidence: number;
18
+ /** The document page on which the information was found. */
19
+ pageId: number;
20
+ /**
21
+ * Contains the relative vertices coordinates (points) of a polygon containing
22
+ * the field in the document.
23
+ */
24
+ polygon: Polygon;
25
+ constructor({ prediction }: StringDict);
26
+ /**
27
+ * Default string representation.
28
+ */
29
+ toString(): string;
30
+ /**
31
+ * Output in a format suitable for inclusion in a field list.
32
+ */
33
+ toFieldList(): string;
34
+ }
@@ -0,0 +1,67 @@
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 _BillOfLadingV1Consignee_instances, _BillOfLadingV1Consignee_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BillOfLadingV1Consignee = void 0;
10
+ /**
11
+ * The party to whom the goods are being shipped.
12
+ */
13
+ class BillOfLadingV1Consignee {
14
+ constructor({ prediction = {} }) {
15
+ _BillOfLadingV1Consignee_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.address = prediction["address"];
24
+ this.email = prediction["email"];
25
+ this.name = prediction["name"];
26
+ this.phone = prediction["phone"];
27
+ this.pageId = prediction["page_id"];
28
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
29
+ if (prediction["polygon"]) {
30
+ this.polygon = prediction.polygon;
31
+ }
32
+ }
33
+ /**
34
+ * Default string representation.
35
+ */
36
+ toString() {
37
+ const printable = __classPrivateFieldGet(this, _BillOfLadingV1Consignee_instances, "m", _BillOfLadingV1Consignee_printableValues).call(this);
38
+ return ("Address: " +
39
+ printable.address +
40
+ ", Email: " +
41
+ printable.email +
42
+ ", Name: " +
43
+ printable.name +
44
+ ", Phone: " +
45
+ printable.phone);
46
+ }
47
+ /**
48
+ * Output in a format suitable for inclusion in a field list.
49
+ */
50
+ toFieldList() {
51
+ const printable = __classPrivateFieldGet(this, _BillOfLadingV1Consignee_instances, "m", _BillOfLadingV1Consignee_printableValues).call(this);
52
+ return `
53
+ :Address: ${printable.address}
54
+ :Email: ${printable.email}
55
+ :Name: ${printable.name}
56
+ :Phone: ${printable.phone}`.trimEnd();
57
+ }
58
+ }
59
+ exports.BillOfLadingV1Consignee = BillOfLadingV1Consignee;
60
+ _BillOfLadingV1Consignee_instances = new WeakSet(), _BillOfLadingV1Consignee_printableValues = function _BillOfLadingV1Consignee_printableValues() {
61
+ return {
62
+ address: this.address ?? "",
63
+ email: this.email ?? "",
64
+ name: this.name ?? "",
65
+ phone: this.phone ?? "",
66
+ };
67
+ };