mindee 3.10.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +103 -41
  3. package/package.json +4 -5
  4. package/src/cli.js +96 -70
  5. package/src/client.d.ts +34 -65
  6. package/src/client.js +108 -172
  7. package/src/geometry/boundingBox.d.ts +5 -0
  8. package/src/geometry/boundingBox.js +2 -0
  9. package/src/geometry/boundingBoxUtils.d.ts +22 -0
  10. package/src/geometry/boundingBoxUtils.js +66 -0
  11. package/src/geometry/index.d.ts +6 -0
  12. package/src/geometry/index.js +21 -0
  13. package/src/geometry/minMax.d.ts +4 -0
  14. package/src/geometry/minMax.js +2 -0
  15. package/src/geometry/point.d.ts +2 -0
  16. package/src/geometry/point.js +2 -0
  17. package/src/geometry/polygon.d.ts +4 -0
  18. package/src/geometry/polygon.js +7 -0
  19. package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
  20. package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
  21. package/src/http/endpoint.d.ts +44 -0
  22. package/src/http/endpoint.js +188 -0
  23. package/src/http/error.d.ts +2 -0
  24. package/src/http/error.js +9 -0
  25. package/src/http/index.d.ts +3 -0
  26. package/src/http/index.js +11 -0
  27. package/src/http/mindeeApi.d.ts +20 -0
  28. package/src/http/mindeeApi.js +73 -0
  29. package/src/index.d.ts +4 -4
  30. package/src/index.js +33 -26
  31. package/src/{inputs → input}/base.d.ts +4 -3
  32. package/src/{inputs → input}/base.js +9 -7
  33. package/src/{inputs → input}/index.d.ts +1 -1
  34. package/src/{inputs → input}/index.js +1 -2
  35. package/src/{inputs → input}/sources.d.ts +10 -11
  36. package/src/{inputs → input}/sources.js +9 -9
  37. package/src/parsing/common/apiRequest.d.ts +10 -0
  38. package/src/parsing/common/apiRequest.js +13 -0
  39. package/src/parsing/common/apiResponse.d.ts +6 -0
  40. package/src/parsing/common/apiResponse.js +10 -0
  41. package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
  42. package/src/parsing/common/asyncPredictResponse.js +39 -0
  43. package/src/parsing/common/document.d.ts +13 -0
  44. package/src/parsing/common/document.js +34 -0
  45. package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
  46. package/src/parsing/common/extras/cropperExtra.js +26 -0
  47. package/src/parsing/common/extras/extras.d.ts +11 -0
  48. package/src/parsing/common/extras/extras.js +18 -0
  49. package/src/parsing/common/index.d.ts +9 -0
  50. package/src/parsing/common/index.js +20 -0
  51. package/src/parsing/common/inference.d.ts +26 -0
  52. package/src/parsing/common/inference.js +56 -0
  53. package/src/parsing/common/mvisionV1.d.ts +8 -0
  54. package/src/parsing/common/mvisionV1.js +17 -0
  55. package/src/parsing/common/ocr.d.ts +8 -0
  56. package/src/parsing/common/ocr.js +13 -0
  57. package/src/parsing/common/ocrPage.d.ts +16 -0
  58. package/src/parsing/common/ocrPage.js +66 -0
  59. package/src/{fields → parsing/common}/orientation.d.ts +2 -2
  60. package/src/{fields → parsing/common}/orientation.js +4 -4
  61. package/src/parsing/common/page.d.ts +12 -0
  62. package/src/parsing/common/page.js +40 -0
  63. package/src/parsing/common/predictResponse.d.ts +6 -0
  64. package/src/parsing/common/predictResponse.js +12 -0
  65. package/src/parsing/common/prediction.d.ts +2 -0
  66. package/src/parsing/common/prediction.js +6 -0
  67. package/src/parsing/common/product.d.ts +4 -0
  68. package/src/parsing/common/product.js +2 -0
  69. package/src/parsing/common/stringDict.d.ts +3 -0
  70. package/src/parsing/common/stringDict.js +2 -0
  71. package/src/parsing/common/summaryHelper.d.ts +8 -0
  72. package/src/parsing/common/summaryHelper.js +22 -0
  73. package/src/parsing/custom/classificationField.d.ts +16 -0
  74. package/src/parsing/custom/classificationField.js +14 -0
  75. package/src/parsing/custom/index.d.ts +3 -0
  76. package/src/parsing/custom/index.js +12 -0
  77. package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
  78. package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
  79. package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
  80. package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
  81. package/src/parsing/index.d.ts +3 -0
  82. package/src/parsing/index.js +29 -0
  83. package/src/{fields → parsing/standard}/amount.d.ts +2 -2
  84. package/src/{fields → parsing/standard}/amount.js +5 -5
  85. package/src/{fields → parsing/standard}/base.d.ts +5 -5
  86. package/src/{fields → parsing/standard}/base.js +3 -2
  87. package/src/{fields → parsing/standard}/classification.d.ts +1 -1
  88. package/src/{fields → parsing/standard}/classification.js +3 -3
  89. package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
  90. package/src/parsing/standard/companyRegistration.js +14 -0
  91. package/src/{fields → parsing/standard}/date.d.ts +1 -1
  92. package/src/{fields → parsing/standard}/date.js +2 -2
  93. package/src/{fields → parsing/standard}/field.d.ts +3 -4
  94. package/src/{fields → parsing/standard}/field.js +6 -7
  95. package/src/parsing/standard/index.d.ts +12 -0
  96. package/src/parsing/standard/index.js +27 -0
  97. package/src/{fields → parsing/standard}/locale.d.ts +4 -4
  98. package/src/parsing/standard/locale.js +42 -0
  99. package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
  100. package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
  101. package/src/{fields → parsing/standard}/position.d.ts +2 -2
  102. package/src/{fields → parsing/standard}/position.js +5 -5
  103. package/src/{fields → parsing/standard}/tax.d.ts +3 -3
  104. package/src/{fields → parsing/standard}/tax.js +3 -3
  105. package/src/{fields → parsing/standard}/text.d.ts +2 -2
  106. package/src/{fields → parsing/standard}/text.js +4 -4
  107. package/src/parsing/standard/word.d.ts +10 -0
  108. package/src/parsing/standard/word.js +2 -0
  109. package/src/pdf/pdfOperation.d.ts +1 -1
  110. package/src/pdf/pdfOperation.js +3 -3
  111. package/src/product/cropper/cropperV1.d.ts +9 -0
  112. package/src/product/cropper/cropperV1.js +16 -0
  113. package/src/product/cropper/cropperV1Document.d.ts +8 -0
  114. package/src/product/cropper/cropperV1Document.js +26 -0
  115. package/src/product/custom/customV1.d.ts +10 -0
  116. package/src/product/custom/customV1.js +17 -0
  117. package/src/product/custom/customV1Document.d.ts +9 -0
  118. package/src/product/custom/customV1Document.js +43 -0
  119. package/src/product/custom/customV1Page.d.ts +7 -0
  120. package/src/product/custom/customV1Page.js +24 -0
  121. package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
  122. package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
  123. package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
  124. package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
  125. package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
  126. package/src/product/financialDocument/financialDocumentV1.js +16 -0
  127. package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
  128. package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
  129. package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
  130. package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
  131. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
  132. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
  133. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
  134. package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
  135. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
  136. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
  137. package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
  138. package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
  139. package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
  140. package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
  141. package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
  142. package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
  143. package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
  144. package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
  145. package/src/product/fr/idCard/idCardV1.d.ts +10 -0
  146. package/src/product/fr/idCard/idCardV1.js +17 -0
  147. package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
  148. package/src/product/fr/idCard/idCardV1Document.js +70 -0
  149. package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
  150. package/src/product/fr/idCard/idCardV1Page.js +23 -0
  151. package/src/{documents → product}/index.d.ts +2 -7
  152. package/src/{documents → product}/index.js +3 -14
  153. package/src/product/invoice/invoiceV4.d.ts +9 -0
  154. package/src/product/invoice/invoiceV4.js +16 -0
  155. package/src/product/invoice/invoiceV4Document.d.ts +44 -0
  156. package/src/product/invoice/invoiceV4Document.js +146 -0
  157. package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
  158. package/src/product/invoice/invoiceV4LineItem.js +101 -0
  159. package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
  160. package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
  161. package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
  162. package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
  163. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
  164. package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
  165. package/src/product/passport/passportV1.d.ts +9 -0
  166. package/src/product/passport/passportV1.js +16 -0
  167. package/src/product/passport/passportV1Document.d.ts +31 -0
  168. package/src/product/passport/passportV1Document.js +75 -0
  169. package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
  170. package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
  171. package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
  172. package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
  173. package/src/product/receipt/receiptV4.d.ts +9 -0
  174. package/src/product/receipt/receiptV4.js +15 -0
  175. package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
  176. package/src/product/receipt/receiptV4Document.js +67 -0
  177. package/src/product/receipt/receiptV5.d.ts +9 -0
  178. package/src/product/receipt/receiptV5.js +16 -0
  179. package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
  180. package/src/product/receipt/receiptV5Document.js +108 -0
  181. package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
  182. package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
  183. package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
  184. package/src/product/us/bankCheck/bankCheckV1.js +17 -0
  185. package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
  186. package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
  187. package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
  188. package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
  189. package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
  190. package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
  191. package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
  192. package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
  193. package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
  194. package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
  195. package/src/product/us/index.d.ts +2 -0
  196. package/src/product/us/index.js +7 -0
  197. package/src/api/documentResponse.d.ts +0 -25
  198. package/src/api/documentResponse.js +0 -50
  199. package/src/api/endpoint.d.ts +0 -63
  200. package/src/api/endpoint.js +0 -216
  201. package/src/api/index.d.ts +0 -3
  202. package/src/api/index.js +0 -13
  203. package/src/api/predictResponse.d.ts +0 -33
  204. package/src/api/predictResponse.js +0 -52
  205. package/src/documents/cropper/cropperV1.d.ts +0 -7
  206. package/src/documents/cropper/cropperV1.js +0 -35
  207. package/src/documents/custom/customV1.d.ts +0 -10
  208. package/src/documents/custom/customV1.js +0 -53
  209. package/src/documents/document.d.ts +0 -47
  210. package/src/documents/document.js +0 -76
  211. package/src/documents/documentConfig.d.ts +0 -42
  212. package/src/documents/documentConfig.js +0 -118
  213. package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
  214. package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
  215. package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
  216. package/src/documents/financialDocument/financialDocumentV0.js +0 -140
  217. package/src/documents/financialDocument/financialDocumentV1.js +0 -197
  218. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
  219. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
  220. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
  221. package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
  222. package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
  223. package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
  224. package/src/documents/fr/idCard/idCardV1.js +0 -79
  225. package/src/documents/invoice/checks.d.ts +0 -5
  226. package/src/documents/invoice/checks.js +0 -87
  227. package/src/documents/invoice/invoiceLineItem.js +0 -66
  228. package/src/documents/invoice/invoiceV3.d.ts +0 -49
  229. package/src/documents/invoice/invoiceV3.js +0 -156
  230. package/src/documents/invoice/invoiceV4.d.ts +0 -45
  231. package/src/documents/invoice/invoiceV4.js +0 -166
  232. package/src/documents/invoice/reconstruction.d.ts +0 -6
  233. package/src/documents/invoice/reconstruction.js +0 -78
  234. package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
  235. package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
  236. package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
  237. package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
  238. package/src/documents/passport/passportV1.d.ts +0 -43
  239. package/src/documents/passport/passportV1.js +0 -220
  240. package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
  241. package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
  242. package/src/documents/receipt/receiptV3.d.ts +0 -25
  243. package/src/documents/receipt/receiptV3.js +0 -136
  244. package/src/documents/receipt/receiptV4.js +0 -78
  245. package/src/documents/receipt/receiptV5.js +0 -137
  246. package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
  247. package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
  248. package/src/documents/us/index.d.ts +0 -1
  249. package/src/documents/us/index.js +0 -5
  250. package/src/fields/companyRegistration.js +0 -14
  251. package/src/fields/fullText.d.ts +0 -27
  252. package/src/fields/fullText.js +0 -92
  253. package/src/fields/index.d.ts +0 -12
  254. package/src/fields/index.js +0 -28
  255. package/src/fields/locale.js +0 -45
  256. package/src/math/index.d.ts +0 -1
  257. package/src/math/index.js +0 -5
  258. package/src/math/precision.d.ts +0 -1
  259. package/src/math/precision.js +0 -13
  260. /package/src/{inputs → input}/pageOptions.d.ts +0 -0
  261. /package/src/{inputs → input}/pageOptions.js +0 -0
  262. /package/src/{documents → product}/eu/index.d.ts +0 -0
  263. /package/src/{documents → product}/eu/index.js +0 -0
  264. /package/src/{documents → product}/fr/index.d.ts +0 -0
  265. /package/src/{documents → product}/fr/index.js +0 -0
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompanyRegistrationField = void 0;
4
+ const field_1 = require("./field");
5
+ /**
6
+ * A company registration item.
7
+ */
8
+ class CompanyRegistrationField extends field_1.Field {
9
+ constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
10
+ super({ prediction, valueKey, reconstructed, pageId });
11
+ this.type = prediction["type"];
12
+ }
13
+ }
14
+ exports.CompanyRegistrationField = CompanyRegistrationField;
@@ -10,7 +10,7 @@ export declare class DateField extends Field {
10
10
  /**
11
11
  * @param {Object} prediction - Prediction object from HTTP response
12
12
  * @param {String} valueKey - Key to use in the prediction dict
13
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
13
+ * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
14
14
  * @param {Integer} pageId - Page ID for multi-page document
15
15
  */
16
16
  constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
@@ -9,10 +9,10 @@ class DateField extends field_1.Field {
9
9
  /**
10
10
  * @param {Object} prediction - Prediction object from HTTP response
11
11
  * @param {String} valueKey - Key to use in the prediction dict
12
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
12
+ * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
13
13
  * @param {Integer} pageId - Page ID for multi-page document
14
14
  */
15
- constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
15
+ constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
16
16
  super({ prediction, valueKey, reconstructed, pageId });
17
17
  if (typeof this.value === "string") {
18
18
  this.dateObject = new Date(this.value);
@@ -1,5 +1,6 @@
1
- import { StringDict, BaseField } from "./base";
2
- import { Polygon, BoundingBox } from "../geometry";
1
+ import { BaseField } from "./base";
2
+ import { Polygon, BoundingBox } from "../../geometry";
3
+ import { StringDict } from "../common";
3
4
  export interface FieldConstructor {
4
5
  prediction: StringDict;
5
6
  valueKey?: string;
@@ -20,8 +21,6 @@ export declare class Field extends BaseField {
20
21
  * the field in the document.
21
22
  */
22
23
  polygon: Polygon;
23
- /** The document page on which the information was found. */
24
- pageId: number;
25
24
  /** The confidence score of the prediction. */
26
25
  confidence: number;
27
26
  /**
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Field = void 0;
4
4
  const base_1 = require("./base");
5
- const geometry_1 = require("../geometry");
5
+ const geometry_1 = require("../../geometry");
6
6
  /**
7
7
  * A basic field with position and page information.
8
8
  */
@@ -14,17 +14,16 @@ class Field extends base_1.BaseField {
14
14
  * @param {Integer} pageId - Page ID for multi-page document
15
15
  * @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
16
16
  */
17
- constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
18
- super({ prediction, valueKey, reconstructed });
17
+ constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
18
+ super({ prediction, valueKey, reconstructed, pageId });
19
19
  /**
20
20
  * Contains the relative vertices coordinates (points) of a polygon containing
21
21
  * the field in the document.
22
22
  */
23
23
  this.polygon = [];
24
- this.pageId = pageId !== undefined ? pageId : prediction["page_id"];
25
- this.confidence = prediction.confidence ? prediction.confidence : 0.0;
26
- if (prediction.polygon) {
27
- this.polygon = prediction.polygon;
24
+ this.confidence = prediction["confidence"] ? prediction["confidence"] : 0.0;
25
+ if (prediction["polygon"]) {
26
+ this.polygon = prediction["polygon"];
28
27
  }
29
28
  this.boundingBox = (0, geometry_1.getBoundingBox)(this.polygon);
30
29
  }
@@ -0,0 +1,12 @@
1
+ export { ClassificationField } from "./classification";
2
+ export { Taxes, TaxField } from "./tax";
3
+ export { PaymentDetailsField } from "./paymentDetails";
4
+ export { LocaleField } from "./locale";
5
+ export { AmountField, floatToString } from "./amount";
6
+ export { DateField } from "./date";
7
+ export { BaseField, BaseFieldConstructor } from "./base";
8
+ export { Word } from "./word";
9
+ export { CompanyRegistrationField } from "./companyRegistration";
10
+ export { PositionField } from "./position";
11
+ export { StringField } from "./text";
12
+ export { Field, FieldConstructor } from "./field";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Field = exports.StringField = exports.PositionField = exports.CompanyRegistrationField = exports.BaseField = exports.DateField = exports.floatToString = exports.AmountField = exports.LocaleField = exports.PaymentDetailsField = exports.TaxField = exports.Taxes = exports.ClassificationField = void 0;
4
+ var classification_1 = require("./classification");
5
+ Object.defineProperty(exports, "ClassificationField", { enumerable: true, get: function () { return classification_1.ClassificationField; } });
6
+ var tax_1 = require("./tax");
7
+ Object.defineProperty(exports, "Taxes", { enumerable: true, get: function () { return tax_1.Taxes; } });
8
+ Object.defineProperty(exports, "TaxField", { enumerable: true, get: function () { return tax_1.TaxField; } });
9
+ var paymentDetails_1 = require("./paymentDetails");
10
+ Object.defineProperty(exports, "PaymentDetailsField", { enumerable: true, get: function () { return paymentDetails_1.PaymentDetailsField; } });
11
+ var locale_1 = require("./locale");
12
+ Object.defineProperty(exports, "LocaleField", { enumerable: true, get: function () { return locale_1.LocaleField; } });
13
+ var amount_1 = require("./amount");
14
+ Object.defineProperty(exports, "AmountField", { enumerable: true, get: function () { return amount_1.AmountField; } });
15
+ Object.defineProperty(exports, "floatToString", { enumerable: true, get: function () { return amount_1.floatToString; } });
16
+ var date_1 = require("./date");
17
+ Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return date_1.DateField; } });
18
+ var base_1 = require("./base");
19
+ Object.defineProperty(exports, "BaseField", { enumerable: true, get: function () { return base_1.BaseField; } });
20
+ var companyRegistration_1 = require("./companyRegistration");
21
+ Object.defineProperty(exports, "CompanyRegistrationField", { enumerable: true, get: function () { return companyRegistration_1.CompanyRegistrationField; } });
22
+ var position_1 = require("./position");
23
+ Object.defineProperty(exports, "PositionField", { enumerable: true, get: function () { return position_1.PositionField; } });
24
+ var text_1 = require("./text");
25
+ Object.defineProperty(exports, "StringField", { enumerable: true, get: function () { return text_1.StringField; } });
26
+ var field_1 = require("./field");
27
+ Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return field_1.Field; } });
@@ -2,22 +2,22 @@ import { BaseField, BaseFieldConstructor } from "./base";
2
2
  /**
3
3
  * The locale detected on the document.
4
4
  */
5
- export declare class Locale extends BaseField {
5
+ export declare class LocaleField extends BaseField {
6
6
  /** Locale in ISO format. */
7
7
  value?: string;
8
8
  /** The confidence score of the prediction. */
9
9
  confidence: number;
10
10
  /** ISO 639-1 language code */
11
11
  language?: string;
12
- /** ISO 3166-1 alpha-2 country code */
12
+ /** ISO 3166-1 alpha-2 (or alpha-3) country code */
13
13
  country?: string;
14
14
  /** ISO 4217 currency code */
15
15
  currency?: string;
16
16
  /**
17
17
  * @param {Object} prediction - Prediction object from HTTP response
18
18
  * @param {String} valueKey - Key to use in the prediction dict
19
- * @param {boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
19
+ * @param {boolean} reconstructed - Is the object reconstructed (not extracted by the API)
20
20
  */
21
- constructor({ prediction, reconstructed }: BaseFieldConstructor);
21
+ constructor({ prediction, reconstructed, pageId, }: BaseFieldConstructor);
22
22
  toString(): string;
23
23
  }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocaleField = void 0;
4
+ const base_1 = require("./base");
5
+ /**
6
+ * The locale detected on the document.
7
+ */
8
+ class LocaleField extends base_1.BaseField {
9
+ /**
10
+ * @param {Object} prediction - Prediction object from HTTP response
11
+ * @param {String} valueKey - Key to use in the prediction dict
12
+ * @param {boolean} reconstructed - Is the object reconstructed (not extracted by the API)
13
+ */
14
+ constructor({ prediction = {}, reconstructed = false, pageId = undefined, }) {
15
+ const valueKey = prediction["value"] !== undefined ? "value" : "language";
16
+ super({ prediction, valueKey, reconstructed, pageId });
17
+ this.confidence = prediction["confidence"] ? prediction["confidence"] : 0.0;
18
+ this.language =
19
+ prediction["language"] !== undefined ? prediction["language"] : undefined;
20
+ this.country =
21
+ prediction["country"] !== undefined ? prediction["country"] : undefined;
22
+ this.currency =
23
+ prediction["currency"] !== undefined ? prediction["currency"] : undefined;
24
+ }
25
+ toString() {
26
+ let outStr = "";
27
+ if (this.value) {
28
+ outStr += `${this.value}; `;
29
+ }
30
+ if (this.language) {
31
+ outStr += `${this.language}; `;
32
+ }
33
+ if (this.country) {
34
+ outStr += `${this.country}; `;
35
+ }
36
+ if (this.currency) {
37
+ outStr += `${this.currency};`;
38
+ }
39
+ return outStr.trimEnd();
40
+ }
41
+ }
42
+ exports.LocaleField = LocaleField;
@@ -1,4 +1,4 @@
1
- import { StringDict } from "./base";
1
+ import { StringDict } from "../common";
2
2
  import { Field } from "./field";
3
3
  interface PaymentDetailsConstructor {
4
4
  prediction: StringDict;
@@ -13,7 +13,7 @@ interface PaymentDetailsConstructor {
13
13
  /**
14
14
  * Information on a single payment.
15
15
  */
16
- export declare class PaymentDetails extends Field {
16
+ export declare class PaymentDetailsField extends Field {
17
17
  #private;
18
18
  /** Synonym for the `iban` property */
19
19
  value?: string | undefined;
@@ -32,7 +32,7 @@ export declare class PaymentDetails extends Field {
32
32
  * @param {String} ibanKey - Key to use to get the IBAN in the prediction dict
33
33
  * @param {String} routingNumberKey - Key to use to get the routing number in the prediction dict
34
34
  * @param {String} swiftKey - Key to use to get the SWIFT in the prediction dict
35
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
35
+ * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
36
36
  * @param {Integer} pageId - Page ID for multi-page document
37
37
  */
38
38
  constructor({ prediction, valueKey, accountNumberKey, ibanKey, routingNumberKey, swiftKey, reconstructed, pageId, }: PaymentDetailsConstructor);
@@ -4,14 +4,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
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
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _a, _PaymentDetails_isKeySet;
7
+ var _a, _PaymentDetailsField_isKeySet;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.PaymentDetails = void 0;
9
+ exports.PaymentDetailsField = void 0;
10
10
  const field_1 = require("./field");
11
11
  /**
12
12
  * Information on a single payment.
13
13
  */
14
- class PaymentDetails extends field_1.Field {
14
+ class PaymentDetailsField extends field_1.Field {
15
15
  /**
16
16
  * @param {Object} prediction - Prediction object from HTTP response
17
17
  * @param {String} valueKey - Key to use in the prediction dict to get the iban
@@ -19,25 +19,25 @@ class PaymentDetails extends field_1.Field {
19
19
  * @param {String} ibanKey - Key to use to get the IBAN in the prediction dict
20
20
  * @param {String} routingNumberKey - Key to use to get the routing number in the prediction dict
21
21
  * @param {String} swiftKey - Key to use to get the SWIFT in the prediction dict
22
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
22
+ * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
23
23
  * @param {Integer} pageId - Page ID for multi-page document
24
24
  */
25
- constructor({ prediction, valueKey = "iban", accountNumberKey = "account_number", ibanKey = "iban", routingNumberKey = "routing_number", swiftKey = "swift", reconstructed = false, pageId = undefined, }) {
25
+ constructor({ prediction = {}, valueKey = "iban", accountNumberKey = "account_number", ibanKey = "iban", routingNumberKey = "routing_number", swiftKey = "swift", reconstructed = false, pageId = undefined, }) {
26
26
  super({ prediction, valueKey, reconstructed, pageId });
27
27
  this.accountNumber = undefined;
28
28
  this.iban = undefined;
29
29
  this.routingNumber = undefined;
30
30
  this.swift = undefined;
31
- if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[accountNumberKey])) {
31
+ if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[accountNumberKey])) {
32
32
  this.accountNumber = prediction[accountNumberKey];
33
33
  }
34
- if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[ibanKey])) {
34
+ if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[ibanKey])) {
35
35
  this.iban = prediction[ibanKey];
36
36
  }
37
- if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[routingNumberKey])) {
37
+ if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[routingNumberKey])) {
38
38
  this.routingNumber = prediction[routingNumberKey];
39
39
  }
40
- if (__classPrivateFieldGet(PaymentDetails, _a, "m", _PaymentDetails_isKeySet).call(PaymentDetails, prediction[swiftKey])) {
40
+ if (__classPrivateFieldGet(PaymentDetailsField, _a, "m", _PaymentDetailsField_isKeySet).call(PaymentDetailsField, prediction[swiftKey])) {
41
41
  this.swift = prediction[swiftKey];
42
42
  }
43
43
  }
@@ -58,7 +58,7 @@ class PaymentDetails extends field_1.Field {
58
58
  return str;
59
59
  }
60
60
  }
61
- exports.PaymentDetails = PaymentDetails;
62
- _a = PaymentDetails, _PaymentDetails_isKeySet = function _PaymentDetails_isKeySet(value) {
61
+ exports.PaymentDetailsField = PaymentDetailsField;
62
+ _a = PaymentDetailsField, _PaymentDetailsField_isKeySet = function _PaymentDetailsField_isKeySet(value) {
63
63
  return typeof value === "string" && value !== "N/A";
64
64
  };
@@ -1,5 +1,5 @@
1
- import { StringDict } from "./base";
2
- import { Polygon } from "../geometry";
1
+ import { StringDict } from "../common";
2
+ import { Polygon } from "../../geometry";
3
3
  export interface PositionFieldConstructor {
4
4
  prediction: StringDict;
5
5
  valueKey?: string;
@@ -5,12 +5,12 @@ exports.PositionField = void 0;
5
5
  * A field indicating a position or area on the document.
6
6
  */
7
7
  class PositionField {
8
- constructor({ prediction, pageId }) {
8
+ constructor({ prediction = {}, pageId }) {
9
9
  this.pageId = pageId;
10
- this.boundingBox = prediction.bounding_box;
11
- this.polygon = prediction.polygon;
12
- this.quadrangle = prediction.quadrangle;
13
- this.rectangle = prediction.rectangle;
10
+ this.boundingBox = prediction["bounding_box"];
11
+ this.polygon = prediction["polygon"];
12
+ this.quadrangle = prediction["quadrangle"];
13
+ this.rectangle = prediction["rectangle"];
14
14
  }
15
15
  toString() {
16
16
  return `Polygon with ${this.polygon.length} points.`;
@@ -1,4 +1,4 @@
1
- import { StringDict } from "./base";
1
+ import { StringDict } from "../common";
2
2
  import { Field } from "./field";
3
3
  interface TaxConstructor {
4
4
  prediction: StringDict;
@@ -30,7 +30,7 @@ export declare class TaxField extends Field {
30
30
  * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
31
31
  * @param {String} codeKey - Key to use to get the tax code in the prediction dict
32
32
  * @param {String} baseKey - Key to use to get the base tax in the prediction dict
33
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
33
+ * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
34
34
  * @param {Integer} pageNumber - Page ID for multi-page document
35
35
  */
36
36
  constructor({ prediction, valueKey, rateKey, codeKey, baseKey, reconstructed, pageId, }: TaxConstructor);
@@ -48,7 +48,7 @@ export declare class TaxField extends Field {
48
48
  */
49
49
  export declare class Taxes extends Array<TaxField> {
50
50
  #private;
51
- init(prediction: StringDict[], pageId: number | undefined): this;
51
+ init(prediction: StringDict[] | undefined, pageId: number | undefined): this;
52
52
  toString(): string;
53
53
  }
54
54
  export {};
@@ -19,10 +19,10 @@ class TaxField extends field_1.Field {
19
19
  * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
20
20
  * @param {String} codeKey - Key to use to get the tax code in the prediction dict
21
21
  * @param {String} baseKey - Key to use to get the base tax in the prediction dict
22
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
22
+ * @param {Boolean} reconstructed - Is the object reconstructed (not extracted by the API)
23
23
  * @param {Integer} pageNumber - Page ID for multi-page document
24
24
  */
25
- constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code", baseKey = "base", reconstructed = false, pageId = undefined, }) {
25
+ constructor({ prediction = {}, valueKey = "value", rateKey = "rate", codeKey = "code", baseKey = "base", reconstructed = false, pageId = undefined, }) {
26
26
  super({ prediction, valueKey, reconstructed, pageId });
27
27
  _TaxField_instances.add(this);
28
28
  /** The tax amount. */
@@ -96,7 +96,7 @@ class Taxes extends Array {
96
96
  super(...arguments);
97
97
  _Taxes_instances.add(this);
98
98
  }
99
- init(prediction, pageId) {
99
+ init(prediction = [], pageId) {
100
100
  for (const entry of prediction) {
101
101
  this.push(new TaxField({
102
102
  prediction: entry,
@@ -1,4 +1,4 @@
1
- import { StringDict } from "./base";
1
+ import { StringDict } from "../common";
2
2
  import { Field } from "./field";
3
3
  export interface FieldConstructor {
4
4
  prediction: StringDict;
@@ -9,7 +9,7 @@ export interface FieldConstructor {
9
9
  /**
10
10
  * A field containing a text value.
11
11
  */
12
- export declare class TextField extends Field {
12
+ export declare class StringField extends Field {
13
13
  /** The value. */
14
14
  value?: string;
15
15
  constructor({ prediction, valueKey, reconstructed, pageId, }: FieldConstructor);
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextField = void 0;
3
+ exports.StringField = void 0;
4
4
  const field_1 = require("./field");
5
5
  /**
6
6
  * A field containing a text value.
7
7
  */
8
- class TextField extends field_1.Field {
9
- constructor({ prediction, valueKey = "value", reconstructed = false, pageId, }) {
8
+ class StringField extends field_1.Field {
9
+ constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) {
10
10
  super({ prediction, valueKey, reconstructed, pageId });
11
11
  }
12
12
  }
13
- exports.TextField = TextField;
13
+ exports.StringField = StringField;
@@ -0,0 +1,10 @@
1
+ import * as geometry from "../../geometry";
2
+ export type Word = {
3
+ /**
4
+ * Contains the relative vertices coordinates (points) of a polygon containing
5
+ * the field in the document.
6
+ */
7
+ polygon: geometry.Polygon;
8
+ text: string;
9
+ confidence: number;
10
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { PageOptions } from "../inputs";
2
+ import { PageOptions } from "../input";
3
3
  export interface SplitPdf {
4
4
  file: Buffer;
5
5
  totalPagesRemoved: number;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.countPages = exports.extractPages = void 0;
4
4
  const handler_1 = require("../errors/handler");
5
5
  const pdf_lib_1 = require("pdf-lib");
6
- const inputs_1 = require("../inputs");
6
+ const input_1 = require("../input");
7
7
  const errors_1 = require("../errors");
8
8
  /**
9
9
  * Cut pages from a pdf file. If pages index are out of bound, it will throw an error.
@@ -37,13 +37,13 @@ async function extractPages(file, pageOptions) {
37
37
  don't exist in the file
38
38
  (${currentPdf.getPageIndices().join(", ")})`));
39
39
  }
40
- if (pageOptions.operation === inputs_1.PageOptionsOperation.KeepOnly) {
40
+ if (pageOptions.operation === input_1.PageOptionsOperation.KeepOnly) {
41
41
  const keptPages = await newPdf.copyPages(currentPdf, pageIndexes);
42
42
  keptPages.forEach((keptPage) => {
43
43
  newPdf.addPage(keptPage);
44
44
  });
45
45
  }
46
- else if (pageOptions.operation === inputs_1.PageOptionsOperation.Remove) {
46
+ else if (pageOptions.operation === input_1.PageOptionsOperation.Remove) {
47
47
  const pagesToKeep = currentPdf
48
48
  .getPageIndices()
49
49
  .filter((v) => !pageIndexes.includes(v));
@@ -0,0 +1,9 @@
1
+ import { Inference, Page, StringDict } from "../../parsing/common";
2
+ import { CropperV1Document } from "./cropperV1Document";
3
+ export declare class CropperV1 extends Inference {
4
+ endpointName: string;
5
+ endpointVersion: string;
6
+ prediction: CropperV1Document;
7
+ pages: Page<CropperV1Document>[];
8
+ constructor(rawPrediction: StringDict);
9
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CropperV1 = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const cropperV1Document_1 = require("./cropperV1Document");
6
+ class CropperV1 extends common_1.Inference {
7
+ constructor(rawPrediction) {
8
+ super(rawPrediction);
9
+ this.endpointName = "cropper";
10
+ this.endpointVersion = "1";
11
+ this.pages = [];
12
+ this.prediction = new cropperV1Document_1.CropperV1Document(rawPrediction["prediction"]);
13
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(cropperV1Document_1.CropperV1Document, page, page["id"], page["orientation"]));
14
+ }
15
+ }
16
+ exports.CropperV1 = CropperV1;
@@ -0,0 +1,8 @@
1
+ import { Prediction, StringDict } from "../../parsing/common";
2
+ import { PositionField } from "../../parsing/standard";
3
+ export declare class CropperV1Document implements Prediction {
4
+ /** A list of cropped positions. */
5
+ cropping: PositionField[];
6
+ constructor(rawPrediction: StringDict, pageId?: number);
7
+ toString(): string;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CropperV1Document = void 0;
4
+ const summaryHelper_1 = require("../../parsing/common/summaryHelper");
5
+ const standard_1 = require("../../parsing/standard");
6
+ class CropperV1Document {
7
+ constructor(rawPrediction, pageId) {
8
+ /** A list of cropped positions. */
9
+ this.cropping = [];
10
+ rawPrediction["cropping"] &&
11
+ rawPrediction["cropping"].forEach((crop) => {
12
+ this.cropping.push(new standard_1.PositionField({
13
+ prediction: crop,
14
+ pageId: pageId,
15
+ }));
16
+ });
17
+ }
18
+ toString() {
19
+ const cropping = this.cropping
20
+ .map((crop) => crop.toString())
21
+ .join("\n ");
22
+ const outStr = `:Cropping: ${cropping}`.trim();
23
+ return (0, summaryHelper_1.cleanOutString)(outStr);
24
+ }
25
+ }
26
+ exports.CropperV1Document = CropperV1Document;
@@ -0,0 +1,10 @@
1
+ import { Inference, Page, StringDict } from "../../parsing/common";
2
+ import { CustomV1Document } from "./customV1Document";
3
+ import { CustomV1Page } from "./customV1Page";
4
+ export declare class CustomV1 extends Inference {
5
+ endpointName: string;
6
+ endpointVersion: string;
7
+ prediction: CustomV1Document;
8
+ pages: Page<CustomV1Page>[];
9
+ constructor(rawPrediction: StringDict);
10
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomV1 = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const customV1Document_1 = require("./customV1Document");
6
+ const customV1Page_1 = require("./customV1Page");
7
+ class CustomV1 extends common_1.Inference {
8
+ constructor(rawPrediction) {
9
+ super(rawPrediction);
10
+ this.endpointName = "custom";
11
+ this.endpointVersion = "1";
12
+ this.pages = [];
13
+ this.prediction = new customV1Document_1.CustomV1Document(rawPrediction["prediction"]);
14
+ this.pages = rawPrediction["pages"].map((page) => new common_1.Page(customV1Page_1.CustomV1Page, page, page["id"], page["orientation"]));
15
+ }
16
+ }
17
+ exports.CustomV1 = CustomV1;
@@ -0,0 +1,9 @@
1
+ import { StringDict, Prediction } from "../../parsing/common";
2
+ import { ClassificationField, ListField } from "../../parsing/custom";
3
+ export declare class CustomV1Document implements Prediction {
4
+ fields: Map<string, ListField>;
5
+ classifications: Map<string, ClassificationField>;
6
+ constructor(rawPrediction: StringDict, pageId?: number);
7
+ protected setField(fieldName: string, fieldValue: any, pageId?: number): void;
8
+ toString(): string;
9
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomV1Document = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const custom_1 = require("../../parsing/custom");
6
+ class CustomV1Document {
7
+ constructor(rawPrediction, pageId) {
8
+ this.fields = new Map();
9
+ this.classifications = new Map();
10
+ Object.entries(rawPrediction).forEach(([fieldName, fieldValue]) => {
11
+ this.setField(fieldName, fieldValue, pageId);
12
+ });
13
+ }
14
+ setField(fieldName, fieldValue, pageId) {
15
+ // Currently, two types of fields possible in a custom API response:
16
+ // fields having a list of values, and classification fields.
17
+ if (fieldValue && fieldValue["values"] !== undefined) {
18
+ // Only value lists have the 'values' attribute.
19
+ this.fields.set(fieldName, new custom_1.ListField({
20
+ prediction: fieldValue,
21
+ pageId: pageId,
22
+ }));
23
+ }
24
+ else if (fieldValue && fieldValue["value"] !== undefined) {
25
+ // Only classifications have the 'value' attribute.
26
+ this.classifications.set(fieldName, new custom_1.ClassificationField({ prediction: fieldValue }));
27
+ }
28
+ else {
29
+ throw new Error(`Unknown API field type for field ${fieldName} : ${fieldValue}`);
30
+ }
31
+ }
32
+ toString() {
33
+ let outStr = "";
34
+ this.classifications.forEach((fieldData, name) => {
35
+ outStr += `:${name}: ${fieldData}\n`;
36
+ });
37
+ this.fields.forEach((fieldData, name) => {
38
+ outStr += `:${name}: ${fieldData}\n`;
39
+ });
40
+ return (0, common_1.cleanOutString)(outStr).trimEnd();
41
+ }
42
+ }
43
+ exports.CustomV1Document = CustomV1Document;
@@ -0,0 +1,7 @@
1
+ import { StringDict, Prediction } from "../../parsing/common";
2
+ import { ListField } from "../../parsing/custom";
3
+ export declare class CustomV1Page implements Prediction {
4
+ fields: Map<string, ListField>;
5
+ constructor(rawPrediction: StringDict, pageId?: number);
6
+ toString(): string;
7
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomV1Page = void 0;
4
+ const common_1 = require("../../parsing/common");
5
+ const custom_1 = require("../../parsing/custom");
6
+ class CustomV1Page {
7
+ constructor(rawPrediction, pageId) {
8
+ this.fields = new Map();
9
+ Object.entries(rawPrediction).forEach(([fieldName, fieldValue]) => {
10
+ this.fields.set(fieldName, new custom_1.ListField({
11
+ prediction: fieldValue,
12
+ pageId: pageId,
13
+ }));
14
+ });
15
+ }
16
+ toString() {
17
+ let outStr = "";
18
+ this.fields.forEach((fieldData, name) => {
19
+ outStr += `:${name}: ${fieldData}\n`;
20
+ });
21
+ return (0, common_1.cleanOutString)(outStr).trimEnd();
22
+ }
23
+ }
24
+ exports.CustomV1Page = CustomV1Page;