mindee 4.14.1 → 4.16.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 (163) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +2 -1
  3. package/src/client.d.ts +5 -3
  4. package/src/client.js +7 -1
  5. package/src/http/endpoint.d.ts +3 -1
  6. package/src/http/endpoint.js +12 -8
  7. package/src/http/responseValidation.js +11 -4
  8. package/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.d.ts +2 -1
  9. package/src/imageOperations/invoiceSplitterExtractor/invoiceSplitterExtractor.js +2 -1
  10. package/src/imageOperations/multiReceiptsExtractor/multiReceiptsExtractor.js +3 -1
  11. package/src/input/localResponse.d.ts +1 -0
  12. package/src/input/localResponse.js +1 -0
  13. package/src/parsing/common/document.d.ts +1 -0
  14. package/src/parsing/common/document.js +27 -6
  15. package/src/parsing/common/extras/fullTextOcrExtra.d.ts +11 -0
  16. package/src/parsing/common/extras/fullTextOcrExtra.js +20 -0
  17. package/src/parsing/common/extras/index.d.ts +3 -0
  18. package/src/parsing/common/extras/index.js +9 -0
  19. package/src/parsing/common/index.d.ts +2 -0
  20. package/src/parsing/common/index.js +28 -1
  21. package/src/parsing/common/page.d.ts +1 -0
  22. package/src/parsing/common/page.js +30 -7
  23. package/src/parsing/common/summaryHelper.d.ts +10 -0
  24. package/src/parsing/common/summaryHelper.js +27 -1
  25. package/src/parsing/generated/generatedObject.d.ts +3 -3
  26. package/src/parsing/generated/generatedObject.js +14 -5
  27. package/src/parsing/standard/amount.d.ts +0 -1
  28. package/src/parsing/standard/amount.js +4 -11
  29. package/src/parsing/standard/index.d.ts +1 -1
  30. package/src/parsing/standard/index.js +1 -2
  31. package/src/parsing/standard/tax.js +4 -4
  32. package/src/pdf/pdfOperation.d.ts +1 -1
  33. package/src/pdf/pdfOperation.js +12 -7
  34. package/src/product/billOfLading/billOfLadingV1.d.ts +16 -0
  35. package/src/product/billOfLading/billOfLadingV1.js +27 -0
  36. package/src/product/billOfLading/billOfLadingV1Carrier.d.ts +32 -0
  37. package/src/product/billOfLading/billOfLadingV1Carrier.js +62 -0
  38. package/src/product/billOfLading/billOfLadingV1CarrierItem.d.ts +38 -0
  39. package/src/product/billOfLading/billOfLadingV1CarrierItem.js +117 -0
  40. package/src/product/billOfLading/billOfLadingV1Consignee.d.ts +34 -0
  41. package/src/product/billOfLading/billOfLadingV1Consignee.js +67 -0
  42. package/src/product/billOfLading/billOfLadingV1Document.d.ts +39 -0
  43. package/src/product/billOfLading/billOfLadingV1Document.js +95 -0
  44. package/src/product/billOfLading/billOfLadingV1NotifyParty.d.ts +34 -0
  45. package/src/product/billOfLading/billOfLadingV1NotifyParty.js +67 -0
  46. package/src/product/billOfLading/billOfLadingV1Shipper.d.ts +34 -0
  47. package/src/product/billOfLading/billOfLadingV1Shipper.js +67 -0
  48. package/src/product/billOfLading/index.d.ts +1 -0
  49. package/src/product/billOfLading/index.js +5 -0
  50. package/src/product/billOfLading/internal.d.ts +7 -0
  51. package/src/product/billOfLading/internal.js +17 -0
  52. package/src/product/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
  53. package/src/product/financialDocument/financialDocumentV1LineItem.js +47 -22
  54. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +4 -4
  55. package/src/product/fr/energyBill/energyBillV1.d.ts +16 -0
  56. package/src/product/fr/energyBill/energyBillV1.js +27 -0
  57. package/src/product/fr/energyBill/energyBillV1Document.d.ts +49 -0
  58. package/src/product/fr/energyBill/energyBillV1Document.js +143 -0
  59. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.d.ts +30 -0
  60. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.js +57 -0
  61. package/src/product/fr/energyBill/energyBillV1EnergySupplier.d.ts +30 -0
  62. package/src/product/fr/energyBill/energyBillV1EnergySupplier.js +57 -0
  63. package/src/product/fr/energyBill/energyBillV1EnergyUsage.d.ts +38 -0
  64. package/src/product/fr/energyBill/energyBillV1EnergyUsage.js +117 -0
  65. package/src/product/fr/energyBill/energyBillV1MeterDetail.d.ts +32 -0
  66. package/src/product/fr/energyBill/energyBillV1MeterDetail.js +62 -0
  67. package/src/product/fr/energyBill/energyBillV1Subscription.d.ts +38 -0
  68. package/src/product/fr/energyBill/energyBillV1Subscription.js +117 -0
  69. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.d.ts +38 -0
  70. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.js +117 -0
  71. package/src/product/fr/energyBill/index.d.ts +1 -0
  72. package/src/product/fr/energyBill/index.js +5 -0
  73. package/src/product/fr/energyBill/internal.d.ts +8 -0
  74. package/src/product/fr/energyBill/internal.js +19 -0
  75. package/src/product/fr/index.d.ts +2 -0
  76. package/src/product/fr/index.js +5 -1
  77. package/src/product/fr/internal.d.ts +2 -0
  78. package/src/product/fr/internal.js +3 -1
  79. package/src/product/fr/payslip/index.d.ts +1 -0
  80. package/src/product/fr/payslip/index.js +5 -0
  81. package/src/product/fr/payslip/internal.d.ts +10 -0
  82. package/src/product/fr/payslip/internal.js +23 -0
  83. package/src/product/fr/payslip/payslipV2.d.ts +16 -0
  84. package/src/product/fr/payslip/payslipV2.js +27 -0
  85. package/src/product/fr/payslip/payslipV2BankAccountDetail.d.ts +32 -0
  86. package/src/product/fr/payslip/payslipV2BankAccountDetail.js +62 -0
  87. package/src/product/fr/payslip/payslipV2Document.d.ts +35 -0
  88. package/src/product/fr/payslip/payslipV2Document.js +80 -0
  89. package/src/product/fr/payslip/payslipV2Employee.d.ts +40 -0
  90. package/src/product/fr/payslip/payslipV2Employee.js +82 -0
  91. package/src/product/fr/payslip/payslipV2Employer.d.ts +40 -0
  92. package/src/product/fr/payslip/payslipV2Employer.js +82 -0
  93. package/src/product/fr/payslip/payslipV2Employment.d.ts +38 -0
  94. package/src/product/fr/payslip/payslipV2Employment.js +85 -0
  95. package/src/product/fr/payslip/payslipV2PayDetail.d.ts +46 -0
  96. package/src/product/fr/payslip/payslipV2PayDetail.js +168 -0
  97. package/src/product/fr/payslip/payslipV2PayPeriod.d.ts +36 -0
  98. package/src/product/fr/payslip/payslipV2PayPeriod.js +72 -0
  99. package/src/product/fr/payslip/payslipV2Pto.d.ts +32 -0
  100. package/src/product/fr/payslip/payslipV2Pto.js +84 -0
  101. package/src/product/fr/payslip/payslipV2SalaryDetail.d.ts +34 -0
  102. package/src/product/fr/payslip/payslipV2SalaryDetail.js +97 -0
  103. package/src/product/generated/generatedV1.js +2 -1
  104. package/src/product/index.d.ts +2 -0
  105. package/src/product/index.js +5 -1
  106. package/src/product/internal.d.ts +2 -0
  107. package/src/product/internal.js +3 -1
  108. package/src/product/invoice/invoiceV4LineItem.d.ts +8 -8
  109. package/src/product/invoice/invoiceV4LineItem.js +47 -22
  110. package/src/product/nutritionFactsLabel/index.d.ts +1 -0
  111. package/src/product/nutritionFactsLabel/index.js +5 -0
  112. package/src/product/nutritionFactsLabel/internal.d.ts +15 -0
  113. package/src/product/nutritionFactsLabel/internal.js +33 -0
  114. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1.d.ts +16 -0
  115. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1.js +27 -0
  116. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.d.ts +32 -0
  117. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.js +84 -0
  118. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.d.ts +32 -0
  119. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.js +84 -0
  120. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.d.ts +32 -0
  121. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.js +84 -0
  122. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.d.ts +32 -0
  123. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.js +84 -0
  124. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.d.ts +53 -0
  125. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.js +117 -0
  126. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.d.ts +36 -0
  127. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.js +107 -0
  128. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.d.ts +32 -0
  129. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.js +84 -0
  130. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.d.ts +32 -0
  131. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.js +84 -0
  132. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.d.ts +30 -0
  133. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.js +65 -0
  134. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.d.ts +34 -0
  135. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.js +89 -0
  136. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.d.ts +32 -0
  137. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.js +84 -0
  138. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.d.ts +32 -0
  139. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.js +84 -0
  140. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.d.ts +32 -0
  141. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.js +84 -0
  142. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.d.ts +32 -0
  143. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.js +84 -0
  144. package/src/product/receipt/receiptV5LineItem.d.ts +4 -4
  145. package/src/product/receipt/receiptV5LineItem.js +27 -12
  146. package/src/product/resume/resumeV1Certificate.d.ts +4 -4
  147. package/src/product/resume/resumeV1Certificate.js +9 -8
  148. package/src/product/resume/resumeV1Education.d.ts +7 -7
  149. package/src/product/resume/resumeV1Education.js +15 -14
  150. package/src/product/resume/resumeV1Language.d.ts +2 -2
  151. package/src/product/resume/resumeV1Language.js +5 -4
  152. package/src/product/resume/resumeV1ProfessionalExperience.d.ts +8 -8
  153. package/src/product/resume/resumeV1ProfessionalExperience.js +17 -16
  154. package/src/product/resume/resumeV1SocialNetworksUrl.d.ts +2 -2
  155. package/src/product/resume/resumeV1SocialNetworksUrl.js +5 -4
  156. package/src/product/us/healthcareCard/healthcareCardV1Copay.d.ts +2 -2
  157. package/src/product/us/healthcareCard/healthcareCardV1Copay.js +11 -6
  158. package/src/product/us/usMail/index.d.ts +1 -0
  159. package/src/product/us/usMail/index.js +5 -0
  160. package/src/product/us/usMail/usMailV2RecipientAddress.d.ts +7 -7
  161. package/src/product/us/usMail/usMailV2RecipientAddress.js +17 -15
  162. package/src/product/us/usMail/usMailV2SenderAddress.d.ts +5 -5
  163. package/src/product/us/usMail/usMailV2SenderAddress.js +5 -25
@@ -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
  }
@@ -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
  /**
@@ -8,7 +8,7 @@ export interface SplitPdf {
8
8
  * Cut pages from a pdf file. If pages index are out of bound, it will throw an error.
9
9
  * @param file
10
10
  * @param pageOptions
11
- * @returns the new cutted pdf file.
11
+ * @returns the new cut pdf file.
12
12
  */
13
13
  export declare function extractPages(file: Buffer, pageOptions: PageOptions): Promise<SplitPdf>;
14
14
  export declare function countPages(file: Buffer): Promise<number>;
@@ -5,27 +5,32 @@ const handler_1 = require("../errors/handler");
5
5
  const pdf_lib_1 = require("pdf-lib");
6
6
  const input_1 = require("../input");
7
7
  const errors_1 = require("../errors");
8
+ const logger_1 = require("../logger");
8
9
  /**
9
10
  * Cut pages from a pdf file. If pages index are out of bound, it will throw an error.
10
11
  * @param file
11
12
  * @param pageOptions
12
- * @returns the new cutted pdf file.
13
+ * @returns the new cut pdf file.
13
14
  */
14
15
  async function extractPages(file, pageOptions) {
15
16
  const currentPdf = await pdf_lib_1.PDFDocument.load(file, {
16
17
  ignoreEncryption: true,
17
18
  });
18
19
  const newPdf = await pdf_lib_1.PDFDocument.create();
19
- if (pageOptions.pageIndexes.length > currentPdf.getPageCount()) {
20
- handler_1.errorHandler.throw(new errors_1.MindeeError(`The total indexes of pages to cut is superior to the total page count of the file (${currentPdf.getPageCount()}).`));
21
- }
22
- if (currentPdf.getPageCount() < pageOptions.onMinPages) {
20
+ const pageCount = currentPdf.getPageCount();
21
+ if (pageCount < pageOptions.onMinPages) {
22
+ logger_1.logger.debug(`File skipped because it had less than ${pageOptions} pages (${pageCount}).`);
23
23
  return { file: file, totalPagesRemoved: 0 };
24
24
  }
25
+ if (pageOptions.pageIndexes.length > pageCount) {
26
+ handler_1.errorHandler.throw(new errors_1.MindeeError("The total indexes of pages to cut is superior to the total page count of the file (" +
27
+ pageCount +
28
+ ")."));
29
+ }
25
30
  const pageIndexes = [];
26
31
  pageOptions.pageIndexes.forEach((pageIndex) => {
27
32
  if (pageIndex < 0) {
28
- pageIndexes.push(currentPdf.getPageCount() - Math.abs(pageIndex));
33
+ pageIndexes.push(pageCount - Math.abs(pageIndex));
29
34
  }
30
35
  else {
31
36
  pageIndexes.push(pageIndex);
@@ -55,7 +60,7 @@ async function extractPages(file, pageOptions) {
55
60
  else {
56
61
  throw new Error(`The operation ${pageOptions.operation} is not available.`);
57
62
  }
58
- const sumRemovedPages = currentPdf.getPageCount() - newPdf.getPageCount();
63
+ const sumRemovedPages = pageCount - newPdf.getPageCount();
59
64
  const fileBuffer = Buffer.from(await newPdf.save());
60
65
  return { file: fileBuffer, totalPagesRemoved: sumRemovedPages };
61
66
  }
@@ -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
+ };
@@ -0,0 +1,39 @@
1
+ import { Prediction, StringDict } from "../../parsing/common";
2
+ import { BillOfLadingV1Shipper } from "./billOfLadingV1Shipper";
3
+ import { BillOfLadingV1Consignee } from "./billOfLadingV1Consignee";
4
+ import { BillOfLadingV1NotifyParty } from "./billOfLadingV1NotifyParty";
5
+ import { BillOfLadingV1Carrier } from "./billOfLadingV1Carrier";
6
+ import { BillOfLadingV1CarrierItem } from "./billOfLadingV1CarrierItem";
7
+ import { DateField, StringField } from "../../parsing/standard";
8
+ /**
9
+ * Bill of Lading API version 1.1 document data.
10
+ */
11
+ export declare class BillOfLadingV1Document implements Prediction {
12
+ /** A unique identifier assigned to a Bill of Lading document. */
13
+ billOfLadingNumber: StringField;
14
+ /** The shipping company responsible for transporting the goods. */
15
+ carrier: BillOfLadingV1Carrier;
16
+ /** The goods being shipped. */
17
+ carrierItems: BillOfLadingV1CarrierItem[];
18
+ /** The party to whom the goods are being shipped. */
19
+ consignee: BillOfLadingV1Consignee;
20
+ /** The date when the bill of lading is issued. */
21
+ dateOfIssue: DateField;
22
+ /** The date when the vessel departs from the port of loading. */
23
+ departureDate: DateField;
24
+ /** The party to be notified of the arrival of the goods. */
25
+ notifyParty: BillOfLadingV1NotifyParty;
26
+ /** The place where the goods are to be delivered. */
27
+ placeOfDelivery: StringField;
28
+ /** The port where the goods are unloaded from the vessel. */
29
+ portOfDischarge: StringField;
30
+ /** The port where the goods are loaded onto the vessel. */
31
+ portOfLoading: StringField;
32
+ /** The party responsible for shipping the goods. */
33
+ shipper: BillOfLadingV1Shipper;
34
+ constructor(rawPrediction: StringDict, pageId?: number);
35
+ /**
36
+ * Default string representation.
37
+ */
38
+ toString(): string;
39
+ }