mindee 4.15.0 → 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 (140) hide show
  1. package/CHANGELOG.md +15 -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/index.d.ts +1 -1
  10. package/src/parsing/standard/index.js +1 -2
  11. package/src/parsing/standard/tax.js +4 -4
  12. package/src/product/billOfLading/billOfLadingV1.d.ts +16 -0
  13. package/src/product/billOfLading/billOfLadingV1.js +27 -0
  14. package/src/product/billOfLading/billOfLadingV1Carrier.d.ts +32 -0
  15. package/src/product/billOfLading/billOfLadingV1Carrier.js +62 -0
  16. package/src/product/billOfLading/billOfLadingV1CarrierItem.d.ts +38 -0
  17. package/src/product/billOfLading/billOfLadingV1CarrierItem.js +117 -0
  18. package/src/product/billOfLading/billOfLadingV1Consignee.d.ts +34 -0
  19. package/src/product/billOfLading/billOfLadingV1Consignee.js +67 -0
  20. package/src/product/billOfLading/billOfLadingV1Document.d.ts +39 -0
  21. package/src/product/billOfLading/billOfLadingV1Document.js +95 -0
  22. package/src/product/billOfLading/billOfLadingV1NotifyParty.d.ts +34 -0
  23. package/src/product/billOfLading/billOfLadingV1NotifyParty.js +67 -0
  24. package/src/product/billOfLading/billOfLadingV1Shipper.d.ts +34 -0
  25. package/src/product/billOfLading/billOfLadingV1Shipper.js +67 -0
  26. package/src/product/billOfLading/index.d.ts +1 -0
  27. package/src/product/billOfLading/index.js +5 -0
  28. package/src/product/billOfLading/internal.d.ts +7 -0
  29. package/src/product/billOfLading/internal.js +17 -0
  30. package/src/product/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
  31. package/src/product/financialDocument/financialDocumentV1LineItem.js +47 -22
  32. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +4 -4
  33. package/src/product/fr/energyBill/energyBillV1.d.ts +16 -0
  34. package/src/product/fr/energyBill/energyBillV1.js +27 -0
  35. package/src/product/fr/energyBill/energyBillV1Document.d.ts +49 -0
  36. package/src/product/fr/energyBill/energyBillV1Document.js +143 -0
  37. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.d.ts +30 -0
  38. package/src/product/fr/energyBill/energyBillV1EnergyConsumer.js +57 -0
  39. package/src/product/fr/energyBill/energyBillV1EnergySupplier.d.ts +30 -0
  40. package/src/product/fr/energyBill/energyBillV1EnergySupplier.js +57 -0
  41. package/src/product/fr/energyBill/energyBillV1EnergyUsage.d.ts +38 -0
  42. package/src/product/fr/energyBill/energyBillV1EnergyUsage.js +117 -0
  43. package/src/product/fr/energyBill/energyBillV1MeterDetail.d.ts +32 -0
  44. package/src/product/fr/energyBill/energyBillV1MeterDetail.js +62 -0
  45. package/src/product/fr/energyBill/energyBillV1Subscription.d.ts +38 -0
  46. package/src/product/fr/energyBill/energyBillV1Subscription.js +117 -0
  47. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.d.ts +38 -0
  48. package/src/product/fr/energyBill/energyBillV1TaxesAndContribution.js +117 -0
  49. package/src/product/fr/energyBill/index.d.ts +1 -0
  50. package/src/product/fr/energyBill/index.js +5 -0
  51. package/src/product/fr/energyBill/internal.d.ts +8 -0
  52. package/src/product/fr/energyBill/internal.js +19 -0
  53. package/src/product/fr/index.d.ts +2 -0
  54. package/src/product/fr/index.js +5 -1
  55. package/src/product/fr/internal.d.ts +2 -0
  56. package/src/product/fr/internal.js +3 -1
  57. package/src/product/fr/payslip/index.d.ts +1 -0
  58. package/src/product/fr/payslip/index.js +5 -0
  59. package/src/product/fr/payslip/internal.d.ts +10 -0
  60. package/src/product/fr/payslip/internal.js +23 -0
  61. package/src/product/fr/payslip/payslipV2.d.ts +16 -0
  62. package/src/product/fr/payslip/payslipV2.js +27 -0
  63. package/src/product/fr/payslip/payslipV2BankAccountDetail.d.ts +32 -0
  64. package/src/product/fr/payslip/payslipV2BankAccountDetail.js +62 -0
  65. package/src/product/fr/payslip/payslipV2Document.d.ts +35 -0
  66. package/src/product/fr/payslip/payslipV2Document.js +80 -0
  67. package/src/product/fr/payslip/payslipV2Employee.d.ts +40 -0
  68. package/src/product/fr/payslip/payslipV2Employee.js +82 -0
  69. package/src/product/fr/payslip/payslipV2Employer.d.ts +40 -0
  70. package/src/product/fr/payslip/payslipV2Employer.js +82 -0
  71. package/src/product/fr/payslip/payslipV2Employment.d.ts +38 -0
  72. package/src/product/fr/payslip/payslipV2Employment.js +85 -0
  73. package/src/product/fr/payslip/payslipV2PayDetail.d.ts +46 -0
  74. package/src/product/fr/payslip/payslipV2PayDetail.js +168 -0
  75. package/src/product/fr/payslip/payslipV2PayPeriod.d.ts +36 -0
  76. package/src/product/fr/payslip/payslipV2PayPeriod.js +72 -0
  77. package/src/product/fr/payslip/payslipV2Pto.d.ts +32 -0
  78. package/src/product/fr/payslip/payslipV2Pto.js +84 -0
  79. package/src/product/fr/payslip/payslipV2SalaryDetail.d.ts +34 -0
  80. package/src/product/fr/payslip/payslipV2SalaryDetail.js +97 -0
  81. package/src/product/index.d.ts +2 -0
  82. package/src/product/index.js +5 -1
  83. package/src/product/internal.d.ts +2 -0
  84. package/src/product/internal.js +3 -1
  85. package/src/product/invoice/invoiceV4LineItem.d.ts +8 -8
  86. package/src/product/invoice/invoiceV4LineItem.js +47 -22
  87. package/src/product/nutritionFactsLabel/index.d.ts +1 -0
  88. package/src/product/nutritionFactsLabel/index.js +5 -0
  89. package/src/product/nutritionFactsLabel/internal.d.ts +15 -0
  90. package/src/product/nutritionFactsLabel/internal.js +33 -0
  91. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1.d.ts +16 -0
  92. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1.js +27 -0
  93. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.d.ts +32 -0
  94. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1AddedSugar.js +84 -0
  95. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.d.ts +32 -0
  96. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Calorie.js +84 -0
  97. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.d.ts +32 -0
  98. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Cholesterol.js +84 -0
  99. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.d.ts +32 -0
  100. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1DietaryFiber.js +84 -0
  101. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.d.ts +53 -0
  102. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Document.js +117 -0
  103. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.d.ts +36 -0
  104. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Nutrient.js +107 -0
  105. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.d.ts +32 -0
  106. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Protein.js +84 -0
  107. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.d.ts +32 -0
  108. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1SaturatedFat.js +84 -0
  109. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.d.ts +30 -0
  110. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1ServingSize.js +65 -0
  111. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.d.ts +34 -0
  112. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1Sodium.js +89 -0
  113. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.d.ts +32 -0
  114. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalCarbohydrate.js +84 -0
  115. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.d.ts +32 -0
  116. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalFat.js +84 -0
  117. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.d.ts +32 -0
  118. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TotalSugar.js +84 -0
  119. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.d.ts +32 -0
  120. package/src/product/nutritionFactsLabel/nutritionFactsLabelV1TransFat.js +84 -0
  121. package/src/product/receipt/receiptV5LineItem.d.ts +4 -4
  122. package/src/product/receipt/receiptV5LineItem.js +27 -12
  123. package/src/product/resume/resumeV1Certificate.d.ts +4 -4
  124. package/src/product/resume/resumeV1Certificate.js +9 -8
  125. package/src/product/resume/resumeV1Education.d.ts +7 -7
  126. package/src/product/resume/resumeV1Education.js +15 -14
  127. package/src/product/resume/resumeV1Language.d.ts +2 -2
  128. package/src/product/resume/resumeV1Language.js +5 -4
  129. package/src/product/resume/resumeV1ProfessionalExperience.d.ts +8 -8
  130. package/src/product/resume/resumeV1ProfessionalExperience.js +17 -16
  131. package/src/product/resume/resumeV1SocialNetworksUrl.d.ts +2 -2
  132. package/src/product/resume/resumeV1SocialNetworksUrl.js +5 -4
  133. package/src/product/us/healthcareCard/healthcareCardV1Copay.d.ts +2 -2
  134. package/src/product/us/healthcareCard/healthcareCardV1Copay.js +11 -6
  135. package/src/product/us/usMail/index.d.ts +1 -0
  136. package/src/product/us/usMail/index.js +5 -0
  137. package/src/product/us/usMail/usMailV2RecipientAddress.d.ts +7 -7
  138. package/src/product/us/usMail/usMailV2RecipientAddress.js +17 -15
  139. package/src/product/us/usMail/usMailV2SenderAddress.d.ts +5 -5
  140. package/src/product/us/usMail/usMailV2SenderAddress.js +5 -25
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NutritionFactsLabelV1 = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const nutritionFactsLabelV1Document_1 = require("./nutritionFactsLabelV1Document");
6
+ /**
7
+ * Nutrition Facts Label API version 1 inference prediction.
8
+ */
9
+ class NutritionFactsLabelV1 extends common_1.Inference {
10
+ constructor(rawPrediction) {
11
+ super(rawPrediction);
12
+ /** The endpoint's name. */
13
+ this.endpointName = "nutrition_facts";
14
+ /** The endpoint's version. */
15
+ this.endpointVersion = "1";
16
+ /** The document's pages. */
17
+ this.pages = [];
18
+ this.prediction = new nutritionFactsLabelV1Document_1.NutritionFactsLabelV1Document(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(nutritionFactsLabelV1Document_1.NutritionFactsLabelV1Document, page, page["id"], page["orientation"]));
23
+ }
24
+ });
25
+ }
26
+ }
27
+ exports.NutritionFactsLabelV1 = NutritionFactsLabelV1;
@@ -0,0 +1,32 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The amount of added sugars in the product.
5
+ */
6
+ export declare class NutritionFactsLabelV1AddedSugar {
7
+ #private;
8
+ /** DVs are the recommended amounts of added sugars to consume or not to exceed each day. */
9
+ dailyValue: number | null;
10
+ /** The amount of added sugars per 100g of the product. */
11
+ per100G: number | null;
12
+ /** The amount of added sugars per serving of the product. */
13
+ perServing: number | 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,84 @@
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 _NutritionFactsLabelV1AddedSugar_instances, _NutritionFactsLabelV1AddedSugar_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NutritionFactsLabelV1AddedSugar = void 0;
10
+ const common_1 = require("../../parsing/common");
11
+ /**
12
+ * The amount of added sugars in the product.
13
+ */
14
+ class NutritionFactsLabelV1AddedSugar {
15
+ constructor({ prediction = {} }) {
16
+ _NutritionFactsLabelV1AddedSugar_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
+ if (prediction["daily_value"] !== undefined &&
25
+ prediction["daily_value"] !== null &&
26
+ !isNaN(prediction["daily_value"])) {
27
+ this.dailyValue = +parseFloat(prediction["daily_value"]);
28
+ }
29
+ else {
30
+ this.dailyValue = null;
31
+ }
32
+ if (prediction["per_100g"] !== undefined &&
33
+ prediction["per_100g"] !== null &&
34
+ !isNaN(prediction["per_100g"])) {
35
+ this.per100G = +parseFloat(prediction["per_100g"]);
36
+ }
37
+ else {
38
+ this.per100G = null;
39
+ }
40
+ if (prediction["per_serving"] !== undefined &&
41
+ prediction["per_serving"] !== null &&
42
+ !isNaN(prediction["per_serving"])) {
43
+ this.perServing = +parseFloat(prediction["per_serving"]);
44
+ }
45
+ else {
46
+ this.perServing = null;
47
+ }
48
+ this.pageId = prediction["page_id"];
49
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
50
+ if (prediction["polygon"]) {
51
+ this.polygon = prediction.polygon;
52
+ }
53
+ }
54
+ /**
55
+ * Default string representation.
56
+ */
57
+ toString() {
58
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1AddedSugar_instances, "m", _NutritionFactsLabelV1AddedSugar_printableValues).call(this);
59
+ return ("Daily Value: " +
60
+ printable.dailyValue +
61
+ ", Per 100g: " +
62
+ printable.per100G +
63
+ ", Per Serving: " +
64
+ printable.perServing);
65
+ }
66
+ /**
67
+ * Output in a format suitable for inclusion in a field list.
68
+ */
69
+ toFieldList() {
70
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1AddedSugar_instances, "m", _NutritionFactsLabelV1AddedSugar_printableValues).call(this);
71
+ return `
72
+ :Daily Value: ${printable.dailyValue}
73
+ :Per 100g: ${printable.per100G}
74
+ :Per Serving: ${printable.perServing}`.trimEnd();
75
+ }
76
+ }
77
+ exports.NutritionFactsLabelV1AddedSugar = NutritionFactsLabelV1AddedSugar;
78
+ _NutritionFactsLabelV1AddedSugar_instances = new WeakSet(), _NutritionFactsLabelV1AddedSugar_printableValues = function _NutritionFactsLabelV1AddedSugar_printableValues() {
79
+ return {
80
+ dailyValue: this.dailyValue !== undefined ? (0, common_1.floatToString)(this.dailyValue) : "",
81
+ per100G: this.per100G !== undefined ? (0, common_1.floatToString)(this.per100G) : "",
82
+ perServing: this.perServing !== undefined ? (0, common_1.floatToString)(this.perServing) : "",
83
+ };
84
+ };
@@ -0,0 +1,32 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The amount of calories in the product.
5
+ */
6
+ export declare class NutritionFactsLabelV1Calorie {
7
+ #private;
8
+ /** DVs are the recommended amounts of calories to consume or not to exceed each day. */
9
+ dailyValue: number | null;
10
+ /** The amount of calories per 100g of the product. */
11
+ per100G: number | null;
12
+ /** The amount of calories per serving of the product. */
13
+ perServing: number | 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,84 @@
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 _NutritionFactsLabelV1Calorie_instances, _NutritionFactsLabelV1Calorie_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NutritionFactsLabelV1Calorie = void 0;
10
+ const common_1 = require("../../parsing/common");
11
+ /**
12
+ * The amount of calories in the product.
13
+ */
14
+ class NutritionFactsLabelV1Calorie {
15
+ constructor({ prediction = {} }) {
16
+ _NutritionFactsLabelV1Calorie_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
+ if (prediction["daily_value"] !== undefined &&
25
+ prediction["daily_value"] !== null &&
26
+ !isNaN(prediction["daily_value"])) {
27
+ this.dailyValue = +parseFloat(prediction["daily_value"]);
28
+ }
29
+ else {
30
+ this.dailyValue = null;
31
+ }
32
+ if (prediction["per_100g"] !== undefined &&
33
+ prediction["per_100g"] !== null &&
34
+ !isNaN(prediction["per_100g"])) {
35
+ this.per100G = +parseFloat(prediction["per_100g"]);
36
+ }
37
+ else {
38
+ this.per100G = null;
39
+ }
40
+ if (prediction["per_serving"] !== undefined &&
41
+ prediction["per_serving"] !== null &&
42
+ !isNaN(prediction["per_serving"])) {
43
+ this.perServing = +parseFloat(prediction["per_serving"]);
44
+ }
45
+ else {
46
+ this.perServing = null;
47
+ }
48
+ this.pageId = prediction["page_id"];
49
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
50
+ if (prediction["polygon"]) {
51
+ this.polygon = prediction.polygon;
52
+ }
53
+ }
54
+ /**
55
+ * Default string representation.
56
+ */
57
+ toString() {
58
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1Calorie_instances, "m", _NutritionFactsLabelV1Calorie_printableValues).call(this);
59
+ return ("Daily Value: " +
60
+ printable.dailyValue +
61
+ ", Per 100g: " +
62
+ printable.per100G +
63
+ ", Per Serving: " +
64
+ printable.perServing);
65
+ }
66
+ /**
67
+ * Output in a format suitable for inclusion in a field list.
68
+ */
69
+ toFieldList() {
70
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1Calorie_instances, "m", _NutritionFactsLabelV1Calorie_printableValues).call(this);
71
+ return `
72
+ :Daily Value: ${printable.dailyValue}
73
+ :Per 100g: ${printable.per100G}
74
+ :Per Serving: ${printable.perServing}`.trimEnd();
75
+ }
76
+ }
77
+ exports.NutritionFactsLabelV1Calorie = NutritionFactsLabelV1Calorie;
78
+ _NutritionFactsLabelV1Calorie_instances = new WeakSet(), _NutritionFactsLabelV1Calorie_printableValues = function _NutritionFactsLabelV1Calorie_printableValues() {
79
+ return {
80
+ dailyValue: this.dailyValue !== undefined ? (0, common_1.floatToString)(this.dailyValue) : "",
81
+ per100G: this.per100G !== undefined ? (0, common_1.floatToString)(this.per100G) : "",
82
+ perServing: this.perServing !== undefined ? (0, common_1.floatToString)(this.perServing) : "",
83
+ };
84
+ };
@@ -0,0 +1,32 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The amount of cholesterol in the product.
5
+ */
6
+ export declare class NutritionFactsLabelV1Cholesterol {
7
+ #private;
8
+ /** DVs are the recommended amounts of cholesterol to consume or not to exceed each day. */
9
+ dailyValue: number | null;
10
+ /** The amount of cholesterol per 100g of the product. */
11
+ per100G: number | null;
12
+ /** The amount of cholesterol per serving of the product. */
13
+ perServing: number | 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,84 @@
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 _NutritionFactsLabelV1Cholesterol_instances, _NutritionFactsLabelV1Cholesterol_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NutritionFactsLabelV1Cholesterol = void 0;
10
+ const common_1 = require("../../parsing/common");
11
+ /**
12
+ * The amount of cholesterol in the product.
13
+ */
14
+ class NutritionFactsLabelV1Cholesterol {
15
+ constructor({ prediction = {} }) {
16
+ _NutritionFactsLabelV1Cholesterol_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
+ if (prediction["daily_value"] !== undefined &&
25
+ prediction["daily_value"] !== null &&
26
+ !isNaN(prediction["daily_value"])) {
27
+ this.dailyValue = +parseFloat(prediction["daily_value"]);
28
+ }
29
+ else {
30
+ this.dailyValue = null;
31
+ }
32
+ if (prediction["per_100g"] !== undefined &&
33
+ prediction["per_100g"] !== null &&
34
+ !isNaN(prediction["per_100g"])) {
35
+ this.per100G = +parseFloat(prediction["per_100g"]);
36
+ }
37
+ else {
38
+ this.per100G = null;
39
+ }
40
+ if (prediction["per_serving"] !== undefined &&
41
+ prediction["per_serving"] !== null &&
42
+ !isNaN(prediction["per_serving"])) {
43
+ this.perServing = +parseFloat(prediction["per_serving"]);
44
+ }
45
+ else {
46
+ this.perServing = null;
47
+ }
48
+ this.pageId = prediction["page_id"];
49
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
50
+ if (prediction["polygon"]) {
51
+ this.polygon = prediction.polygon;
52
+ }
53
+ }
54
+ /**
55
+ * Default string representation.
56
+ */
57
+ toString() {
58
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1Cholesterol_instances, "m", _NutritionFactsLabelV1Cholesterol_printableValues).call(this);
59
+ return ("Daily Value: " +
60
+ printable.dailyValue +
61
+ ", Per 100g: " +
62
+ printable.per100G +
63
+ ", Per Serving: " +
64
+ printable.perServing);
65
+ }
66
+ /**
67
+ * Output in a format suitable for inclusion in a field list.
68
+ */
69
+ toFieldList() {
70
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1Cholesterol_instances, "m", _NutritionFactsLabelV1Cholesterol_printableValues).call(this);
71
+ return `
72
+ :Daily Value: ${printable.dailyValue}
73
+ :Per 100g: ${printable.per100G}
74
+ :Per Serving: ${printable.perServing}`.trimEnd();
75
+ }
76
+ }
77
+ exports.NutritionFactsLabelV1Cholesterol = NutritionFactsLabelV1Cholesterol;
78
+ _NutritionFactsLabelV1Cholesterol_instances = new WeakSet(), _NutritionFactsLabelV1Cholesterol_printableValues = function _NutritionFactsLabelV1Cholesterol_printableValues() {
79
+ return {
80
+ dailyValue: this.dailyValue !== undefined ? (0, common_1.floatToString)(this.dailyValue) : "",
81
+ per100G: this.per100G !== undefined ? (0, common_1.floatToString)(this.per100G) : "",
82
+ perServing: this.perServing !== undefined ? (0, common_1.floatToString)(this.perServing) : "",
83
+ };
84
+ };
@@ -0,0 +1,32 @@
1
+ import { StringDict } from "../../parsing/common";
2
+ import { Polygon } from "../../geometry";
3
+ /**
4
+ * The amount of dietary fiber in the product.
5
+ */
6
+ export declare class NutritionFactsLabelV1DietaryFiber {
7
+ #private;
8
+ /** DVs are the recommended amounts of dietary fiber to consume or not to exceed each day. */
9
+ dailyValue: number | null;
10
+ /** The amount of dietary fiber per 100g of the product. */
11
+ per100G: number | null;
12
+ /** The amount of dietary fiber per serving of the product. */
13
+ perServing: number | 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,84 @@
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 _NutritionFactsLabelV1DietaryFiber_instances, _NutritionFactsLabelV1DietaryFiber_printableValues;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NutritionFactsLabelV1DietaryFiber = void 0;
10
+ const common_1 = require("../../parsing/common");
11
+ /**
12
+ * The amount of dietary fiber in the product.
13
+ */
14
+ class NutritionFactsLabelV1DietaryFiber {
15
+ constructor({ prediction = {} }) {
16
+ _NutritionFactsLabelV1DietaryFiber_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
+ if (prediction["daily_value"] !== undefined &&
25
+ prediction["daily_value"] !== null &&
26
+ !isNaN(prediction["daily_value"])) {
27
+ this.dailyValue = +parseFloat(prediction["daily_value"]);
28
+ }
29
+ else {
30
+ this.dailyValue = null;
31
+ }
32
+ if (prediction["per_100g"] !== undefined &&
33
+ prediction["per_100g"] !== null &&
34
+ !isNaN(prediction["per_100g"])) {
35
+ this.per100G = +parseFloat(prediction["per_100g"]);
36
+ }
37
+ else {
38
+ this.per100G = null;
39
+ }
40
+ if (prediction["per_serving"] !== undefined &&
41
+ prediction["per_serving"] !== null &&
42
+ !isNaN(prediction["per_serving"])) {
43
+ this.perServing = +parseFloat(prediction["per_serving"]);
44
+ }
45
+ else {
46
+ this.perServing = null;
47
+ }
48
+ this.pageId = prediction["page_id"];
49
+ this.confidence = prediction["confidence"] ? prediction.confidence : 0.0;
50
+ if (prediction["polygon"]) {
51
+ this.polygon = prediction.polygon;
52
+ }
53
+ }
54
+ /**
55
+ * Default string representation.
56
+ */
57
+ toString() {
58
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1DietaryFiber_instances, "m", _NutritionFactsLabelV1DietaryFiber_printableValues).call(this);
59
+ return ("Daily Value: " +
60
+ printable.dailyValue +
61
+ ", Per 100g: " +
62
+ printable.per100G +
63
+ ", Per Serving: " +
64
+ printable.perServing);
65
+ }
66
+ /**
67
+ * Output in a format suitable for inclusion in a field list.
68
+ */
69
+ toFieldList() {
70
+ const printable = __classPrivateFieldGet(this, _NutritionFactsLabelV1DietaryFiber_instances, "m", _NutritionFactsLabelV1DietaryFiber_printableValues).call(this);
71
+ return `
72
+ :Daily Value: ${printable.dailyValue}
73
+ :Per 100g: ${printable.per100G}
74
+ :Per Serving: ${printable.perServing}`.trimEnd();
75
+ }
76
+ }
77
+ exports.NutritionFactsLabelV1DietaryFiber = NutritionFactsLabelV1DietaryFiber;
78
+ _NutritionFactsLabelV1DietaryFiber_instances = new WeakSet(), _NutritionFactsLabelV1DietaryFiber_printableValues = function _NutritionFactsLabelV1DietaryFiber_printableValues() {
79
+ return {
80
+ dailyValue: this.dailyValue !== undefined ? (0, common_1.floatToString)(this.dailyValue) : "",
81
+ per100G: this.per100G !== undefined ? (0, common_1.floatToString)(this.per100G) : "",
82
+ perServing: this.perServing !== undefined ? (0, common_1.floatToString)(this.perServing) : "",
83
+ };
84
+ };
@@ -0,0 +1,53 @@
1
+ import { Prediction, StringDict } from "../../parsing/common";
2
+ import { NutritionFactsLabelV1ServingSize } from "./nutritionFactsLabelV1ServingSize";
3
+ import { NutritionFactsLabelV1Calorie } from "./nutritionFactsLabelV1Calorie";
4
+ import { NutritionFactsLabelV1TotalFat } from "./nutritionFactsLabelV1TotalFat";
5
+ import { NutritionFactsLabelV1SaturatedFat } from "./nutritionFactsLabelV1SaturatedFat";
6
+ import { NutritionFactsLabelV1TransFat } from "./nutritionFactsLabelV1TransFat";
7
+ import { NutritionFactsLabelV1Cholesterol } from "./nutritionFactsLabelV1Cholesterol";
8
+ import { NutritionFactsLabelV1TotalCarbohydrate } from "./nutritionFactsLabelV1TotalCarbohydrate";
9
+ import { NutritionFactsLabelV1DietaryFiber } from "./nutritionFactsLabelV1DietaryFiber";
10
+ import { NutritionFactsLabelV1TotalSugar } from "./nutritionFactsLabelV1TotalSugar";
11
+ import { NutritionFactsLabelV1AddedSugar } from "./nutritionFactsLabelV1AddedSugar";
12
+ import { NutritionFactsLabelV1Protein } from "./nutritionFactsLabelV1Protein";
13
+ import { NutritionFactsLabelV1Sodium } from "./nutritionFactsLabelV1Sodium";
14
+ import { NutritionFactsLabelV1Nutrient } from "./nutritionFactsLabelV1Nutrient";
15
+ import { AmountField } from "../../parsing/standard";
16
+ /**
17
+ * Nutrition Facts Label API version 1.0 document data.
18
+ */
19
+ export declare class NutritionFactsLabelV1Document implements Prediction {
20
+ /** The amount of added sugars in the product. */
21
+ addedSugars: NutritionFactsLabelV1AddedSugar;
22
+ /** The amount of calories in the product. */
23
+ calories: NutritionFactsLabelV1Calorie;
24
+ /** The amount of cholesterol in the product. */
25
+ cholesterol: NutritionFactsLabelV1Cholesterol;
26
+ /** The amount of dietary fiber in the product. */
27
+ dietaryFiber: NutritionFactsLabelV1DietaryFiber;
28
+ /** The amount of nutrients in the product. */
29
+ nutrients: NutritionFactsLabelV1Nutrient[];
30
+ /** The amount of protein in the product. */
31
+ protein: NutritionFactsLabelV1Protein;
32
+ /** The amount of saturated fat in the product. */
33
+ saturatedFat: NutritionFactsLabelV1SaturatedFat;
34
+ /** The number of servings in each box of the product. */
35
+ servingPerBox: AmountField;
36
+ /** The size of a single serving of the product. */
37
+ servingSize: NutritionFactsLabelV1ServingSize;
38
+ /** The amount of sodium in the product. */
39
+ sodium: NutritionFactsLabelV1Sodium;
40
+ /** The total amount of carbohydrates in the product. */
41
+ totalCarbohydrate: NutritionFactsLabelV1TotalCarbohydrate;
42
+ /** The total amount of fat in the product. */
43
+ totalFat: NutritionFactsLabelV1TotalFat;
44
+ /** The total amount of sugars in the product. */
45
+ totalSugars: NutritionFactsLabelV1TotalSugar;
46
+ /** The amount of trans fat in the product. */
47
+ transFat: NutritionFactsLabelV1TransFat;
48
+ constructor(rawPrediction: StringDict, pageId?: number);
49
+ /**
50
+ * Default string representation.
51
+ */
52
+ toString(): string;
53
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NutritionFactsLabelV1Document = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const nutritionFactsLabelV1ServingSize_1 = require("./nutritionFactsLabelV1ServingSize");
6
+ const nutritionFactsLabelV1Calorie_1 = require("./nutritionFactsLabelV1Calorie");
7
+ const nutritionFactsLabelV1TotalFat_1 = require("./nutritionFactsLabelV1TotalFat");
8
+ const nutritionFactsLabelV1SaturatedFat_1 = require("./nutritionFactsLabelV1SaturatedFat");
9
+ const nutritionFactsLabelV1TransFat_1 = require("./nutritionFactsLabelV1TransFat");
10
+ const nutritionFactsLabelV1Cholesterol_1 = require("./nutritionFactsLabelV1Cholesterol");
11
+ const nutritionFactsLabelV1TotalCarbohydrate_1 = require("./nutritionFactsLabelV1TotalCarbohydrate");
12
+ const nutritionFactsLabelV1DietaryFiber_1 = require("./nutritionFactsLabelV1DietaryFiber");
13
+ const nutritionFactsLabelV1TotalSugar_1 = require("./nutritionFactsLabelV1TotalSugar");
14
+ const nutritionFactsLabelV1AddedSugar_1 = require("./nutritionFactsLabelV1AddedSugar");
15
+ const nutritionFactsLabelV1Protein_1 = require("./nutritionFactsLabelV1Protein");
16
+ const nutritionFactsLabelV1Sodium_1 = require("./nutritionFactsLabelV1Sodium");
17
+ const nutritionFactsLabelV1Nutrient_1 = require("./nutritionFactsLabelV1Nutrient");
18
+ const standard_1 = require("../../parsing/standard");
19
+ /**
20
+ * Nutrition Facts Label API version 1.0 document data.
21
+ */
22
+ class NutritionFactsLabelV1Document {
23
+ constructor(rawPrediction, pageId) {
24
+ /** The amount of nutrients in the product. */
25
+ this.nutrients = [];
26
+ this.addedSugars = new nutritionFactsLabelV1AddedSugar_1.NutritionFactsLabelV1AddedSugar({
27
+ prediction: rawPrediction["added_sugars"],
28
+ pageId: pageId,
29
+ });
30
+ this.calories = new nutritionFactsLabelV1Calorie_1.NutritionFactsLabelV1Calorie({
31
+ prediction: rawPrediction["calories"],
32
+ pageId: pageId,
33
+ });
34
+ this.cholesterol = new nutritionFactsLabelV1Cholesterol_1.NutritionFactsLabelV1Cholesterol({
35
+ prediction: rawPrediction["cholesterol"],
36
+ pageId: pageId,
37
+ });
38
+ this.dietaryFiber = new nutritionFactsLabelV1DietaryFiber_1.NutritionFactsLabelV1DietaryFiber({
39
+ prediction: rawPrediction["dietary_fiber"],
40
+ pageId: pageId,
41
+ });
42
+ rawPrediction["nutrients"] &&
43
+ rawPrediction["nutrients"].map((itemPrediction) => this.nutrients.push(new nutritionFactsLabelV1Nutrient_1.NutritionFactsLabelV1Nutrient({
44
+ prediction: itemPrediction,
45
+ pageId: pageId,
46
+ })));
47
+ this.protein = new nutritionFactsLabelV1Protein_1.NutritionFactsLabelV1Protein({
48
+ prediction: rawPrediction["protein"],
49
+ pageId: pageId,
50
+ });
51
+ this.saturatedFat = new nutritionFactsLabelV1SaturatedFat_1.NutritionFactsLabelV1SaturatedFat({
52
+ prediction: rawPrediction["saturated_fat"],
53
+ pageId: pageId,
54
+ });
55
+ this.servingPerBox = new standard_1.AmountField({
56
+ prediction: rawPrediction["serving_per_box"],
57
+ pageId: pageId,
58
+ });
59
+ this.servingSize = new nutritionFactsLabelV1ServingSize_1.NutritionFactsLabelV1ServingSize({
60
+ prediction: rawPrediction["serving_size"],
61
+ pageId: pageId,
62
+ });
63
+ this.sodium = new nutritionFactsLabelV1Sodium_1.NutritionFactsLabelV1Sodium({
64
+ prediction: rawPrediction["sodium"],
65
+ pageId: pageId,
66
+ });
67
+ this.totalCarbohydrate = new nutritionFactsLabelV1TotalCarbohydrate_1.NutritionFactsLabelV1TotalCarbohydrate({
68
+ prediction: rawPrediction["total_carbohydrate"],
69
+ pageId: pageId,
70
+ });
71
+ this.totalFat = new nutritionFactsLabelV1TotalFat_1.NutritionFactsLabelV1TotalFat({
72
+ prediction: rawPrediction["total_fat"],
73
+ pageId: pageId,
74
+ });
75
+ this.totalSugars = new nutritionFactsLabelV1TotalSugar_1.NutritionFactsLabelV1TotalSugar({
76
+ prediction: rawPrediction["total_sugars"],
77
+ pageId: pageId,
78
+ });
79
+ this.transFat = new nutritionFactsLabelV1TransFat_1.NutritionFactsLabelV1TransFat({
80
+ prediction: rawPrediction["trans_fat"],
81
+ pageId: pageId,
82
+ });
83
+ }
84
+ /**
85
+ * Default string representation.
86
+ */
87
+ toString() {
88
+ let nutrientsSummary = "";
89
+ if (this.nutrients && this.nutrients.length > 0) {
90
+ const nutrientsColSizes = [13, 22, 10, 13, 6];
91
+ nutrientsSummary += "\n" + (0, common_1.lineSeparator)(nutrientsColSizes, "-") + "\n ";
92
+ nutrientsSummary += "| Daily Value ";
93
+ nutrientsSummary += "| Name ";
94
+ nutrientsSummary += "| Per 100g ";
95
+ nutrientsSummary += "| Per Serving ";
96
+ nutrientsSummary += "| Unit ";
97
+ nutrientsSummary += "|\n" + (0, common_1.lineSeparator)(nutrientsColSizes, "=");
98
+ nutrientsSummary += this.nutrients.map((item) => "\n " + item.toTableLine() + "\n" + (0, common_1.lineSeparator)(nutrientsColSizes, "-")).join("");
99
+ }
100
+ const outStr = `:Serving per Box: ${this.servingPerBox}
101
+ :Serving Size: ${this.servingSize.toFieldList()}
102
+ :Calories: ${this.calories.toFieldList()}
103
+ :Total Fat: ${this.totalFat.toFieldList()}
104
+ :Saturated Fat: ${this.saturatedFat.toFieldList()}
105
+ :Trans Fat: ${this.transFat.toFieldList()}
106
+ :Cholesterol: ${this.cholesterol.toFieldList()}
107
+ :Total Carbohydrate: ${this.totalCarbohydrate.toFieldList()}
108
+ :Dietary Fiber: ${this.dietaryFiber.toFieldList()}
109
+ :Total Sugars: ${this.totalSugars.toFieldList()}
110
+ :Added Sugars: ${this.addedSugars.toFieldList()}
111
+ :Protein: ${this.protein.toFieldList()}
112
+ :sodium: ${this.sodium.toFieldList()}
113
+ :nutrients: ${nutrientsSummary}`.trimEnd();
114
+ return (0, common_1.cleanOutString)(outStr);
115
+ }
116
+ }
117
+ exports.NutritionFactsLabelV1Document = NutritionFactsLabelV1Document;